Skip to content

Commit 541ea8c

Browse files
authored
Merge pull request #494 from nixpanic/GroupControllerServer
GetVolumeGroupSnapshot should check SnapshotIDs not SourceVolumeIDs
2 parents 2ce65b0 + a656ad3 commit 541ea8c

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)