fix: require same namespace for snapshot restore
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-10-22 15:35:18 -06:00
parent 556bd168af
commit ac11628ee4
1 changed files with 4 additions and 0 deletions

View File

@ -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