From ac11628ee437be901439a6db71275077e5bcc5b2 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Thu, 22 Oct 2026 15:35:18 -0600 Subject: [PATCH] fix: require same namespace for snapshot restore --- lib/jeannie/commands.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 3462679..a7fa353 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -3413,6 +3413,10 @@ EOF local snapshot_resource="${snapshot_ref#*/}" namespace="${pvc_ref%%/*}" pvc="${pvc_ref#*/}" + if [[ "${snapshot_namespace}" != "${namespace}" ]]; then + echo "Snapshot and restored PVC must be in the same namespace (${snapshot_namespace} != ${namespace})." >&2 + return 1 + fi kubectl --kubeconfig "${kubeconfig}" -n "${snapshot_namespace}" get volumesnapshot "${snapshot_resource}" >/dev/null if [[ "$(kubectl --kubeconfig "${kubeconfig}" -n "${snapshot_namespace}" get volumesnapshot "${snapshot_resource}" -o jsonpath='{.status.readyToUse}' 2>/dev/null)" != "true" ]]; then echo "VolumeSnapshot ${snapshot_namespace}/${snapshot_resource} is not ready to use." >&2