From 27d0d3c0c5f4438968e85b251b19e505f7fcf5e3 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 21 Dec 2022 10:27:34 +0100 Subject: [PATCH] cephfs: skip expand for BackingSnapshot volume We should not call ExpandVolume for the BackingSnapshot subvolume as there wont be any real subvolume created for it and even if we call it the ExpandVolume will fail fail as there is no real subvolume exists. This commits fixes by adjusting the `if` check to ensure that ExpandVolume will only be called either the VolumeRequest is to create from a snapshot or volume and BackingSnapshot is not true. sample code here https://go.dev/play/p/PI2tNii5tTg Signed-off-by: Madhu Rajanna (cherry picked from commit f7796081d39874ff7d429270e2f53039b92e9b72) --- internal/cephfs/controllerserver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cephfs/controllerserver.go b/internal/cephfs/controllerserver.go index 57ba1318a..9a486c463 100644 --- a/internal/cephfs/controllerserver.go +++ b/internal/cephfs/controllerserver.go @@ -299,7 +299,7 @@ func (cs *ControllerServer) CreateVolume( if vID != nil { volClient := core.NewSubVolume(volOptions.GetConnection(), &volOptions.SubVolume, volOptions.ClusterID, cs.ClusterName, cs.SetMetadata) - if sID != nil || pvID != nil && !volOptions.BackingSnapshot { + if (sID != nil || pvID != nil) && !volOptions.BackingSnapshot { err = volClient.ExpandVolume(ctx, volOptions.Size) if err != nil { purgeErr := volClient.PurgeVolume(ctx, false)