Skip to content

Commit 8d62c77

Browse files
RomanBednark8s-infra-cherrypick-robot
authored andcommitted
allow deleting cross-subscription snapshots
DeleteSnapshot should try to get subscription ID from snapshot ID before proceeding with deletion to ensure we can delete a snapshot that could have been created under different subscription ID. If a cross-subscription snapshot deletion is attempted without it, the driver will use the default subscription ID and fail with `ResourceGroupNotFound` when `Delete` is executed with file share client. This is relevant only for ARM/Control Plane client authentication.
1 parent 0e2fd9d commit 8d62c77

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/azurefile/controllerserver.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ func (d *Driver) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequ
10211021
if len(req.SnapshotId) == 0 {
10221022
return nil, status.Error(codes.InvalidArgument, "Snapshot ID must be provided")
10231023
}
1024-
rgName, accountName, fileShareName, _, _, _, err := GetFileShareInfo(req.SnapshotId) //nolint:dogsled
1024+
rgName, accountName, fileShareName, _, _, subsID, err := GetFileShareInfo(req.SnapshotId) //nolint:dogsled
10251025
if fileShareName == "" || err != nil {
10261026
// According to CSI Driver Sanity Tester, should succeed when an invalid snapshot id is used
10271027
klog.V(4).Infof("failed to get share url with (%s): %v, returning with success", req.SnapshotId, err)
@@ -1035,7 +1035,10 @@ func (d *Driver) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequ
10351035
if rgName == "" {
10361036
rgName = d.cloud.ResourceGroup
10371037
}
1038-
subsID := d.cloud.SubscriptionID
1038+
if subsID == "" {
1039+
subsID = d.cloud.SubscriptionID
1040+
}
1041+
10391042
mc := metrics.NewMetricContext(azureFileCSIDriverName, "controller_delete_snapshot", rgName, subsID, d.Name)
10401043
isOperationSucceeded := false
10411044
defer func() {

0 commit comments

Comments
 (0)