fix(opensearch): make ML model registration idempotent

Reuse any existing model version (including DEPLOY_FAILED) instead of
registering a new copy. Prevents accumulation of stale model chunks
in .plugins-ml-model when OpenSearch restarts between applies.
This commit is contained in:
2026-03-25 18:04:28 +00:00
parent 3d2d16d53e
commit 30dc4f9c5e

View File

@@ -617,10 +617,14 @@ async fn ensure_opensearch_ml() {
already_deployed = true; already_deployed = true;
break; break;
} }
"REGISTERED" | "DEPLOYING" => { // Any existing model (even DEPLOY_FAILED) — reuse it instead of
model_id = Some(id.to_string()); // registering a new version. This prevents accumulating stale
// copies in .plugins-ml-model when the pod restarts.
_ => {
if model_id.is_none() && !id.is_empty() {
model_id = Some(id.to_string());
}
} }
_ => {}
} }
} }