Skip to content

Commit

Permalink
Merge pull request #14362 from subhamkrai/revert-crd-limit-scds
Browse files Browse the repository at this point in the history
core: revert increase storage deviceset name limit to 50
  • Loading branch information
BlaineEXE committed Jun 21, 2024
2 parents 6439862 + e8aeb0d commit d1e4f96
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 24 deletions.
1 change: 0 additions & 1 deletion deploy/charts/rook-ceph/templates/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3556,7 +3556,6 @@ spec:
type: boolean
name:
description: Name is a unique identifier for the set
maxLength: 50
type: string
placement:
nullable: true
Expand Down
1 change: 0 additions & 1 deletion deploy/examples/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3554,7 +3554,6 @@ spec:
type: boolean
name:
description: Name is a unique identifier for the set
maxLength: 50
type: string
placement:
nullable: true
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/ceph.rook.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2968,7 +2968,6 @@ type PriorityClassNamesSpec map[KeyType]string
// +nullable
type StorageClassDeviceSet struct {
// Name is a unique identifier for the set
// +kubebuilder:validation:MaxLength=50
Name string `json:"name"`
// Count is the number of devices in this set
// +kubebuilder:validation:Minimum=1
Expand Down
16 changes: 4 additions & 12 deletions pkg/operator/ceph/cluster/osd/deviceSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 5 additions & 9 deletions pkg/operator/ceph/cluster/osd/deviceset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit d1e4f96

Please sign in to comment.