Skip to content

Commit

Permalink
Ensure VGS name contains at most 63 characters
Browse files Browse the repository at this point in the history
Signed-off-by: Benamar Mekhissi <[email protected]>
  • Loading branch information
Benamar Mekhissi committed Sep 12, 2024
1 parent d5e6554 commit c83cf3f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions internal/controller/cephfscg/volumegroupsourcehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c83cf3f

Please sign in to comment.