Skip to content

Commit

Permalink
rbd: preserve the vol connection
Browse files Browse the repository at this point in the history
preserve the vol connection as its
required to handle the flattening
and delete the connections of all
the volumes at last.

Signed-off-by: Madhu Rajanna <[email protected]>
  • Loading branch information
Madhu-1 committed Jul 30, 2024
1 parent 09f91db commit 9131288
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions internal/csi-addons/rbd/volumegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ func (vs *VolumeGroupServer) CreateVolumeGroup(

// resolve all volumes
volumes := make([]types.Volume, len(req.GetVolumeIds()))
defer func() {
// Destroy all volumes at last
for _, vol := range volumes {
vol.Destroy(ctx)
}
}()
for i, id := range req.GetVolumeIds() {
vol, err := mgr.GetVolumeByID(ctx, id)
if err != nil {
Expand All @@ -97,9 +103,6 @@ func (vs *VolumeGroupServer) CreateVolumeGroup(
req.GetName(),
err.Error())
}

//nolint:gocritic // need to call .Destroy() for all volumes
defer vol.Destroy(ctx)
volumes[i] = vol
}

Expand Down Expand Up @@ -343,6 +346,12 @@ func (vs *VolumeGroupServer) ModifyVolumeGroupMembership(

// resolve all volumes
volumes := make([]types.Volume, len(toAdd))
defer func() {
// Destroy all volumes at last
for _, vol := range volumes {
vol.Destroy(ctx)
}
}()
for i, id := range toAdd {
var vol types.Volume
vol, err = mgr.GetVolumeByID(ctx, id)
Expand All @@ -353,9 +362,6 @@ func (vs *VolumeGroupServer) ModifyVolumeGroupMembership(
id,
err)
}

//nolint:gocritic // need to call .Destroy() for all volumes
defer vol.Destroy(ctx)
volumes[i] = vol
}

Expand Down

0 comments on commit 9131288

Please sign in to comment.