fix: require same namespace for snapshot restore
This commit is contained in:
parent
556bd168af
commit
ac11628ee4
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue