From f1250a3da1cce15a86a6c3f4375cfdcf213d01ee Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 20 Apr 2026 10:37:49 +0000 Subject: [PATCH] fix(k8s): tailor mount-mismatch error to cluster's umbrella state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original error always prescribed cluster recreate. When the running cluster already has an umbrella at /mnt, that's misleading — the right fix is to align the new deployment to the existing umbrella (set kind-mount-root to the cluster's umbrella source and move host paths under it). Recreate is only correct when no umbrella exists. Branch the error message on whether the cluster has a /mnt bind. With umbrella: show its host source and tell the user to set kind-mount-root to that value. Without: keep the recreate guidance. Co-Authored-By: Claude Opus 4.7 (1M context) --- stack_orchestrator/deploy/k8s/helpers.py | 55 +++++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/stack_orchestrator/deploy/k8s/helpers.py b/stack_orchestrator/deploy/k8s/helpers.py index 03aa5ed7..8f3525ef 100644 --- a/stack_orchestrator/deploy/k8s/helpers.py +++ b/stack_orchestrator/deploy/k8s/helpers.py @@ -309,7 +309,7 @@ def check_mounts_compatible(cluster_name: str, config_file: str) -> None: if not mismatches: return lines = [ - f"This deployment declares extraMounts that are not active on the " + f"This deployment declares extraMounts incompatible with the " f"running cluster '{cluster_name}':", ] for dest, want, have in mismatches: @@ -317,21 +317,44 @@ def check_mounts_compatible(cluster_name: str, config_file: str) -> None: f" - {dest}: expected host path '{want}', " f"actual '{have or 'NOT MOUNTED'}'" ) - lines.extend( - [ - "", - "Kind applies extraMounts only at cluster creation — neither " - "kind nor Docker supports adding bind mounts to a running " - "container. Without a recreate, any PV backed by one of the " - "missing mounts will silently fall through to the node's " - "overlay filesystem and lose data on cluster destroy.", - "", - "Fix: destroy and recreate the cluster with a kind-config that " - "includes an umbrella mount via 'kind-mount-root'. All stacks " - "sharing the cluster must agree on 'kind-mount-root' and place " - "their host paths under it. See docs/deployment_patterns.md.", - ] - ) + lines.append("") + + cluster_umbrella = live.get("/mnt") + if cluster_umbrella: + lines.extend( + [ + f"The running cluster has an umbrella mount: " + f"'{cluster_umbrella}' -> /mnt.", + "", + f"Fix: set 'kind-mount-root: {cluster_umbrella}' in this " + "deployment's spec and place host paths for its volumes " + f"under '{cluster_umbrella}/'. Kind applies extraMounts " + "only at cluster creation, so new bind mounts cannot be " + "added to the running cluster without a recreate — but " + "the existing umbrella already covers any subdirectory " + "you create on the host.", + ] + ) + else: + lines.extend( + [ + "The running cluster has no umbrella mount " + "(no extraMount with containerPath=/mnt).", + "", + "Kind applies extraMounts only at cluster creation — " + "neither kind nor Docker supports adding bind mounts to " + "a running container. Without a recreate, any PV backed " + "by one of the missing mounts will silently fall through " + "to the node's overlay filesystem and lose data on " + "cluster destroy.", + "", + "Fix: destroy and recreate the cluster with a kind-config " + "that sets 'kind-mount-root' so future stacks can share " + "an umbrella without recreating.", + ] + ) + lines.append("") + lines.append("See docs/deployment_patterns.md.") raise DeployerException("\n".join(lines))