From 5a7115d61de02905b540bff64c671a3c2f891216 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 14 Feb 2024 14:23:32 +0100 Subject: [PATCH] Add snapshot size to VSC created for VGS Currently the RestoreSize is missing when the corresponding VSC are created for the the volumesnapshotgroup, This PR adds the missing RestoreSize for VSC. Signed-off-by: Madhu Rajanna --- pkg/sidecar-controller/groupsnapshot_helper.go | 5 +++++ pkg/sidecar-controller/snapshot_controller.go | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/sidecar-controller/groupsnapshot_helper.go b/pkg/sidecar-controller/groupsnapshot_helper.go index b5ec02dd..89c51c6b 100644 --- a/pkg/sidecar-controller/groupsnapshot_helper.go +++ b/pkg/sidecar-controller/groupsnapshot_helper.go @@ -477,6 +477,11 @@ func (ctrl *csiSnapshotSideCarController) createGroupSnapshotWrapper(groupSnapsh if err != nil { return groupSnapshotContent, err } + + _, err = ctrl.updateSnapshotContentStatus(volumeSnapshotContent, snapshot.SnapshotId, snapshot.ReadyToUse, snapshot.CreationTime.AsTime().UnixNano(), snapshot.SizeBytes, groupSnapshotID) + if err != nil { + return groupSnapshotContent, err + } } newGroupSnapshotContent, err := ctrl.updateGroupSnapshotContentStatus(groupSnapshotContent, groupSnapshotID, readyToUse, creationTime.UnixNano(), snapshotContentNames) diff --git a/pkg/sidecar-controller/snapshot_controller.go b/pkg/sidecar-controller/snapshot_controller.go index 3be0c249..2bec8a82 100644 --- a/pkg/sidecar-controller/snapshot_controller.go +++ b/pkg/sidecar-controller/snapshot_controller.go @@ -446,11 +446,13 @@ func (ctrl *csiSnapshotSideCarController) updateSnapshotContentStatus( SnapshotHandle: &snapshotHandle, ReadyToUse: &readyToUse, CreationTime: &createdAt, - RestoreSize: &size, } if groupSnapshotID != "" { newStatus.VolumeGroupSnapshotHandle = &groupSnapshotID } + if size > 0 { + newStatus.RestoreSize = &size + } updated = true } else { newStatus = contentObj.Status.DeepCopy() @@ -469,7 +471,7 @@ func (ctrl *csiSnapshotSideCarController) updateSnapshotContentStatus( newStatus.CreationTime = &createdAt updated = true } - if newStatus.RestoreSize == nil { + if newStatus.RestoreSize == nil && size > 0 { newStatus.RestoreSize = &size updated = true }