Skip to content

Commit c5234c7

Browse files
authored
Ensure cross namespace cloning fails without TVR
1 parent ecb15b2 commit c5234c7

File tree

1 file changed

+10
-0
lines changed
  • frontend/csi/controller_helpers/kubernetes

1 file changed

+10
-0
lines changed

frontend/csi/controller_helpers/kubernetes/helper.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ func (h *helper) getSnapshotCloneSourceInfo(
336336
if !h.matchNamespaceToAnnotation(clonePVC.Namespace, sourceCloneToNamespaces) {
337337
return "", "", fmt.Errorf("cloning to namespace %s is not allowed, it is not listed in cloneToNamespace annotation", clonePVC.Namespace)
338338
}
339+
// Get the volume reference CR
340+
_, err = h.getCachedVolumeReference(ctx, clonePVC.Namespace, snapSourcePVC.Name, namespace)
341+
if err != nil {
342+
return "", "", fmt.Errorf("volume reference not found: %v", err)
343+
}
339344

340345
}
341346
// If the clone from PVC annotation is also set, ensure it matches the snapshot
@@ -423,6 +428,11 @@ func (h *helper) getCloneSourceInfo(ctx context.Context, clonePVC *v1.Persistent
423428
if !h.matchNamespaceToAnnotation(clonePVC.Namespace, sourceCloneToNamespaces) {
424429
return "", fmt.Errorf("cloning to namespace %s is not allowed, it is not listed in cloneToNamespace annotation", clonePVC.Namespace)
425430
}
431+
// Get the volume reference CR
432+
_, err := h.getCachedVolumeReference(ctx, clonePVC.Namespace, sourcePVCName, namespace)
433+
if err != nil {
434+
return "", fmt.Errorf("volume reference not found: %v", err)
435+
}
426436
}
427437

428438
// Check that both source and clone PVCs have the same storage class

0 commit comments

Comments
 (0)