Skip to content

Commit a656ad3

Browse files
committed
GetVolumeGroupSnapshot should check SnapshoIDs not SourceVolumeIDs
Due to this bug in GetVolumeGroupSnapshot, creating pre-provisioned VolumeGroupSnapshots was not working. Pre-provisioned VolumeGroupSnapshots refer to a list of SnapshotIDs that are part of the VolumeGroupSnapshot, the SourceVolumeIDs are not used in that case.
1 parent a427b6f commit a656ad3

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pkg/hostpath/groupcontrollerserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (hp *hostPath) GetVolumeGroupSnapshot(ctx context.Context, req *csi.GetVolu
237237
return nil, err
238238
}
239239

240-
if !groupSnapshot.MatchesSourceVolumeIDs(req.GetSnapshotIds()) {
240+
if !groupSnapshot.MatchesSnapshotIDs(req.GetSnapshotIds()) {
241241
return nil, status.Error(codes.InvalidArgument, "Snapshot IDs do not match the GroupSnapshot IDs")
242242
}
243243

pkg/state/state.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,24 @@ func (s *state) DeleteGroupSnapshot(groupSnapshotID string) error {
338338
}
339339

340340
func (gs *GroupSnapshot) MatchesSourceVolumeIDs(sourceVolumeIDs []string) bool {
341-
stateSourceVolumeIDs := gs.SourceVolumeIDs
341+
return equalIDs(gs.SourceVolumeIDs, sourceVolumeIDs)
342+
}
343+
344+
func (gs *GroupSnapshot) MatchesSnapshotIDs(snapshotIDs []string) bool {
345+
return equalIDs(gs.SnapshotIDs, snapshotIDs)
346+
}
342347

343-
if len(stateSourceVolumeIDs) != len(sourceVolumeIDs) {
348+
func equalIDs(a, b []string) bool {
349+
if len(a) != len(b) {
344350
return false
345351
}
346352

347353
// sort slices so that values are at the same location
348-
sort.Strings(stateSourceVolumeIDs)
349-
sort.Strings(sourceVolumeIDs)
354+
sort.Strings(a)
355+
sort.Strings(b)
350356

351-
for i, v := range stateSourceVolumeIDs {
352-
if v != sourceVolumeIDs[i] {
357+
for i, v := range a {
358+
if v != b[i] {
353359
return false
354360
}
355361
}

0 commit comments

Comments
 (0)