diff --git a/internal/controller/cephfscg/volumegroupsourcehandler.go b/internal/controller/cephfscg/volumegroupsourcehandler.go index a6d386148b..cc292d81d8 100644 --- a/internal/controller/cephfscg/volumegroupsourcehandler.go +++ b/internal/controller/cephfscg/volumegroupsourcehandler.go @@ -100,6 +100,20 @@ func NewVolumeGroupSourceHandler( } } +func BuildVGSName(name string) string { + const maxLen = 63 + + vgsName := fmt.Sprintf(VolumeGroupSnapshotNameFormat, name) + + // If the name is already less than the max, then return the already built name + if len(vgsName) <= maxLen { + return vgsName + } + + // Otherwise, trim it up to maxLen + return vgsName[:maxLen] +} + // CreateOrUpdateVolumeGroupSnapshot create or update a VolumeGroupSnapshot func (h *volumeGroupSourceHandler) CreateOrUpdateVolumeGroupSnapshot( ctx context.Context, owner metav1.Object, @@ -138,7 +152,7 @@ func (h *volumeGroupSourceHandler) CreateOrUpdateVolumeGroupSnapshot( return err } - logger.Info("VolumeGroupSnapshot successfully be created or updated", "operation", op) + logger.Info("VolumeGroupSnapshot successfully created or updated", "operation", op) return nil } @@ -504,11 +518,6 @@ func (h *volumeGroupSourceHandler) CheckReplicationSourceForRestoredPVCsComplete return true, nil } -var GetPVCFromVolumeSnapshot func( - ctx context.Context, k8sClient client.Client, vsName string, - vsNamespace string, vgs *vgsv1alphfa1.VolumeGroupSnapshot, -) (*corev1.PersistentVolumeClaim, error) - func GetPVCfromStorageHandle( ctx context.Context, k8sClient client.Client,