osd: revert limit storageClassDeviceSets to 63 chars

This reverts commit 6f5cc9b01d.

Signed-off-by: subhamkrai <srai@redhat.com>
This commit is contained in:
subhamkrai committed 2024-06-21 11:24:25 +05:30
1 parent c7d07562c4
commit e8aeb0d263
5 files changed
+9 -24

No files matched your search

@@ -3556,7 +3556,6 @@ spec:
type: boolean
name:
description: Name is a unique identifier for the set
maxLength: 40
type: string
placement:
nullable: true
-1
View File
@@ -3554,7 +3554,6 @@ spec:
type: boolean
name:
description: Name is a unique identifier for the set
maxLength: 40
type: string
placement:
nullable: true
-1
View File
@@ -2968,7 +2968,6 @@ type PriorityClassNamesSpec map[KeyType]string
// +nullable
type StorageClassDeviceSet struct {
// Name is a unique identifier for the set
// +kubebuilder:validation:MaxLength=40
Name string `json:"name"`
// Count is the number of devices in this set
// +kubebuilder:validation:Minimum=1
+4 -12
View File
@@ -205,20 +205,16 @@ func (c *Cluster) createDeviceSetPVC(existingPVCs map[string]*v1.PersistentVolum
// old labels and PVC ID for backward compatibility
pvcID := legacyDeviceSetPVCID(deviceSetName, setIndex)
var err error
// check for the existence of the pvc
existingPVC, ok := existingPVCs[pvcID]
if !ok {
// The old name of the PVC didn't exist, now try the new PVC name and label
pvcID, err = deviceSetPVCID(deviceSetName, pvcTemplate.GetName(), setIndex)
if err != nil {
return nil, err
}
pvcID = deviceSetPVCID(deviceSetName, pvcTemplate.GetName(), setIndex)
existingPVC = existingPVCs[pvcID]
}
pvc := makeDeviceSetPVC(deviceSetName, pvcID, setIndex, pvcTemplate, c.clusterInfo.Namespace, createValidImageVersionLabel(c.spec.CephVersion.Image), createValidImageVersionLabel(c.rookVersion))
err = c.clusterInfo.OwnerInfo.SetControllerReference(pvc)
err := c.clusterInfo.OwnerInfo.SetControllerReference(pvc)
if err != nil {
return nil, errors.Wrapf(err, "failed to set owner reference to osd pvc %q", pvc.Name)
}
@@ -295,14 +291,10 @@ func legacyDeviceSetPVCID(deviceSetName string, setIndex int) string {
// This is the new function that generates the labels
// It includes the pvcTemplateName in it
func deviceSetPVCID(deviceSetName, pvcTemplateName string, setIndex int) (string, error) {
func deviceSetPVCID(deviceSetName, pvcTemplateName string, setIndex int) string {
cleanName := strings.Replace(pvcTemplateName, " ", "-", -1)
deviceSetName = strings.Replace(deviceSetName, ".", "-", -1)
pvcID := fmt.Sprintf("%s-%s-%d", deviceSetName, cleanName, setIndex)
if len(pvcID) > 62 {
return "", fmt.Errorf("the OSD PVC name requested is %q (length %d) is too long and must be less than 63 characters, shorten either the storageClassDeviceSet name or the storage class name", pvcID, len(pvcID))
}
return pvcID, nil
return fmt.Sprintf("%s-%s-%d", deviceSetName, cleanName, setIndex)
}
func createValidImageVersionLabel(image string) string {
@@ -280,20 +280,16 @@ func TestPrepareDeviceSetsWithCrushParams(t *testing.T) {
}
func TestPVCName(t *testing.T) {
id, err := deviceSetPVCID("mydeviceset-making-the-length-of-pvc-id-greater-than-the-limit-63", "a", 0)
assert.Error(t, err)
assert.Equal(t, "", id)
id := deviceSetPVCID("mydeviceset", "a", 0)
assert.Equal(t, "mydeviceset-a-0", id)
id, err = deviceSetPVCID("mydeviceset", "a", 10)
assert.NoError(t, err)
id = deviceSetPVCID("mydeviceset", "a", 10)
assert.Equal(t, "mydeviceset-a-10", id)
id, err = deviceSetPVCID("device-set", "a", 10)
assert.NoError(t, err)
id = deviceSetPVCID("device-set", "a", 10)
assert.Equal(t, "device-set-a-10", id)
id, err = deviceSetPVCID("device.set.with.dots", "b", 10)
assert.NoError(t, err)
id = deviceSetPVCID("device.set.with.dots", "b", 10)
assert.Equal(t, "device-set-with-dots-b-10", id)
}