Skip to content

Commit 4623dcc

Browse files
authored
Merge pull request #2332 from k8s-infra-cherrypick-robot/cherry-pick-2331-to-release-1.31
[release-1.31] fix: revert appending subsid into snapshotid
2 parents 4ea067e + a595fa1 commit 4623dcc

File tree

3 files changed

+3
-60
lines changed

3 files changed

+3
-60
lines changed

pkg/azurefile/controllerserver.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,13 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
864864
return nil, status.Error(codes.InvalidArgument, "CreateSnapshot Source Volume ID must be provided")
865865
}
866866

867-
rgName, accountName, fileShareName, _, _, srcVolSubsID, err := GetFileShareInfo(sourceVolumeID) //nolint:dogsled
867+
rgName, accountName, fileShareName, _, _, subsID, err := GetFileShareInfo(sourceVolumeID) //nolint:dogsled
868868
if err != nil {
869869
return nil, status.Error(codes.Internal, fmt.Sprintf("GetFileShareInfo(%s) failed with error: %v", sourceVolumeID, err))
870870
}
871871
if rgName == "" {
872872
rgName = d.cloud.ResourceGroup
873873
}
874-
subsID := srcVolSubsID
875874
if subsID == "" {
876875
subsID = d.cloud.SubscriptionID
877876
}
@@ -908,7 +907,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
908907
return &csi.CreateSnapshotResponse{
909908
Snapshot: &csi.Snapshot{
910909
SizeBytes: volumehelper.GiBToBytes(int64(itemSnapshotQuota)),
911-
SnapshotId: getSnapshotID(srcVolSubsID, sourceVolumeID, itemSnapshot, subsID),
910+
SnapshotId: sourceVolumeID + "#" + itemSnapshot,
912911
SourceVolumeId: sourceVolumeID,
913912
CreationTime: timestamppb.New(itemSnapshotTime),
914913
// Since the snapshot of azurefile has no field of ReadyToUse, here ReadyToUse is always set to true.
@@ -979,7 +978,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
979978
createResp := &csi.CreateSnapshotResponse{
980979
Snapshot: &csi.Snapshot{
981980
SizeBytes: volumehelper.GiBToBytes(int64(itemSnapshotQuota)),
982-
SnapshotId: getSnapshotID(srcVolSubsID, sourceVolumeID, itemSnapshot, subsID),
981+
SnapshotId: sourceVolumeID + "#" + itemSnapshot,
983982
SourceVolumeId: sourceVolumeID,
984983
CreationTime: timestamppb.New(itemSnapshotTime),
985984
// Since the snapshot of azurefile has no field of ReadyToUse, here ReadyToUse is always set to true.

pkg/azurefile/utils.go

-14
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,3 @@ func isConfidentialRuntimeClass(ctx context.Context, kubeClient clientset.Interf
345345
klog.Infof("runtimeClass %s handler: %s", runtimeClassName, runtimeClass.Handler)
346346
return runtimeClass.Handler == confidentialRuntimeClassHandler, nil
347347
}
348-
349-
// getSnapshotID returns snapshotID based on srcVolSubsID, srcVolumeID, itemSnapshot and subsID
350-
func getSnapshotID(srcVolSubsID, srcVolumeID, itemSnapshot, subsID string) string {
351-
snapshotID := srcVolumeID + "#" + itemSnapshot
352-
if srcVolSubsID == "" {
353-
// if srcVolumeID does not contain subscription id, append it to snapshotID
354-
if strings.HasSuffix(srcVolumeID, "#") {
355-
snapshotID = srcVolumeID + subsID + "#" + itemSnapshot
356-
} else {
357-
snapshotID = srcVolumeID + "#" + subsID + "#" + itemSnapshot
358-
}
359-
}
360-
return snapshotID
361-
}

pkg/azurefile/utils_test.go

-42
Original file line numberDiff line numberDiff line change
@@ -815,48 +815,6 @@ func TestIsConfidentialRuntimeClass(t *testing.T) {
815815
}
816816
}
817817

818-
func TestGetSnapshotID(t *testing.T) {
819-
tests := []struct {
820-
desc string
821-
srcVolumeSubsID string
822-
srcVolumeID string
823-
itemSnapshot string
824-
subsID string
825-
expected string
826-
}{
827-
{
828-
desc: "srcVolumeSubsID contains subsID",
829-
srcVolumeSubsID: "subsID",
830-
srcVolumeID: "rg#f5713de20cde511e8ba4900#fileShareName#diskname.vhd#uuid#namespace#subsID",
831-
itemSnapshot: "snapshot",
832-
expected: "rg#f5713de20cde511e8ba4900#fileShareName#diskname.vhd#uuid#namespace#subsID#snapshot",
833-
},
834-
{
835-
desc: "srcVolumeSubsID is empty",
836-
srcVolumeSubsID: "",
837-
srcVolumeID: "rg#f5713de20cde511e8ba4900#fileShareName#diskname.vhd#uuid#namespace",
838-
itemSnapshot: "snapshot",
839-
subsID: "subsID",
840-
expected: "rg#f5713de20cde511e8ba4900#fileShareName#diskname.vhd#uuid#namespace#subsID#snapshot",
841-
},
842-
{
843-
desc: "srcVolumeSubsID is empty but contains # at the end",
844-
srcVolumeSubsID: "",
845-
srcVolumeID: "rg#f5713de20cde511e8ba4900#fileShareName#diskname.vhd#uuid#namespace#",
846-
itemSnapshot: "snapshot",
847-
subsID: "subsID",
848-
expected: "rg#f5713de20cde511e8ba4900#fileShareName#diskname.vhd#uuid#namespace#subsID#snapshot",
849-
},
850-
}
851-
852-
for _, test := range tests {
853-
result := getSnapshotID(test.srcVolumeSubsID, test.srcVolumeID, test.itemSnapshot, test.subsID)
854-
if result != test.expected {
855-
t.Errorf("test[%s]: unexpected output: %v, expected result: %v", test.desc, result, test.expected)
856-
}
857-
}
858-
}
859-
860818
func TestIsThrottlingError(t *testing.T) {
861819
tests := []struct {
862820
desc string

0 commit comments

Comments
 (0)