From 30dc4f9c5e6f1c489b2084c36428c7a6c9d8eca2 Mon Sep 17 00:00:00 2001 From: Sienna Meridian Satterwhite Date: Wed, 25 Mar 2026 18:04:28 +0000 Subject: [PATCH] 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. --- sunbeam-sdk/src/manifests/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sunbeam-sdk/src/manifests/mod.rs b/sunbeam-sdk/src/manifests/mod.rs index e40bf23..45baa0d 100644 --- a/sunbeam-sdk/src/manifests/mod.rs +++ b/sunbeam-sdk/src/manifests/mod.rs @@ -617,10 +617,14 @@ async fn ensure_opensearch_ml() { already_deployed = true; break; } - "REGISTERED" | "DEPLOYING" => { - model_id = Some(id.to_string()); + // Any existing model (even DEPLOY_FAILED) — reuse it instead of + // 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()); + } } - _ => {} } }