fix(k8s): tailor mount-mismatch error to cluster's umbrella state

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) <noreply@anthropic.com>
pull/748/head
Prathamesh Musale 2026-04-20 10:37:49 +00:00
parent 1e274610d6
commit f1250a3da1
1 changed files with 39 additions and 16 deletions

View File

@ -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.append("")
cluster_umbrella = live.get("/mnt")
if cluster_umbrella:
lines.extend(
[
f"The running cluster has an umbrella mount: "
f"'{cluster_umbrella}' -> /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 "
"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.",
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))