cephfs: delete subvolume if SetAllMetadata fails

To avoid subvolume leaks if the SetAllMetadata
operations fails delete the subvolume.
If any operation fails after creating the subvolume
we will remove the omap as the omap gets
removed we will need to remove the subvolume to
avoid stale resources.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 302fead713)
This commit is contained in:
Madhu Rajanna 2022-10-14 14:24:51 +02:00 committed by mergify[bot]
parent 763aa3df03
commit d39b61334a

View File

@ -409,6 +409,11 @@ func (cs *ControllerServer) CreateVolume(
// Set Metadata on PV Create
err = volClient.SetAllMetadata(metadata)
if err != nil {
purgeErr := volClient.PurgeVolume(ctx, true)
if purgeErr != nil {
log.ErrorLog(ctx, "failed to delete volume %s: %v", vID.FsSubvolName, purgeErr)
}
return nil, status.Error(codes.Internal, err.Error())
}
}