Unverified Commit 18cc4bf4 authored by Travis Nielsen's avatar Travis Nielsen Committed by GitHub
Browse files

Merge pull request #6312 from travisn/backport-pvc-template-name

ceph: Allow osd pvc template name set to any value (bp #6307)
parents f5379ae2 20ee66b6
Showing with 23 additions and 3 deletions
+23 -3
......@@ -56,12 +56,19 @@ func (c *Cluster) prepareStorageClassDeviceSets(config *provisionConfig) []rookv
continue
}
if pvcTemplate.Name == bluestorePVCData {
// The PVC type must be from a predefined set such as "data" and "metadata". These names must be enforced if the wal/db are specified
// with a separate device, but if there is a single volume template we can assume it is always the data template.
pvcType := pvcTemplate.Name
if len(storageClassDeviceSet.VolumeClaimTemplates) == 1 {
pvcType = bluestorePVCData
}
if pvcType == bluestorePVCData {
pvcSize := pvc.Spec.Resources.Requests[v1.ResourceStorage]
dataSize = pvcSize.String()
crushDeviceClass = pvcTemplate.Annotations["crushDeviceClass"]
}
pvcSources[pvcTemplate.Name] = v1.PersistentVolumeClaimVolumeSource{
pvcSources[pvcType] = v1.PersistentVolumeClaimVolumeSource{
ClaimName: pvc.GetName(),
ReadOnly: false,
}
......
......@@ -16,6 +16,7 @@ limitations under the License.
package osd
import (
"fmt"
"testing"
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
......@@ -28,6 +29,11 @@ import (
)
func TestPrepareDeviceSets(t *testing.T) {
testPrepareDeviceSets(t, true)
testPrepareDeviceSets(t, false)
}
func testPrepareDeviceSets(t *testing.T, setTemplateName bool) {
clientset := testexec.New(t, 1)
context := &clusterd.Context{
Clientset: clientset,
......@@ -36,6 +42,9 @@ func TestPrepareDeviceSets(t *testing.T) {
claim := v1.PersistentVolumeClaim{Spec: v1.PersistentVolumeClaimSpec{
StorageClassName: &storageClass,
}}
if setTemplateName {
claim.Name = "randomname"
}
deviceSet := rookv1.StorageClassDeviceSet{
Name: "mydata",
Count: 1,
......@@ -62,7 +71,11 @@ func TestPrepareDeviceSets(t *testing.T) {
pvcs, err := clientset.CoreV1().PersistentVolumeClaims(cluster.Namespace).List(metav1.ListOptions{})
assert.NoError(t, err)
assert.Equal(t, 1, len(pvcs.Items))
assert.Equal(t, "mydata-data-0-", pvcs.Items[0].GenerateName)
expectedName := claim.Name
if !setTemplateName {
expectedName = "data"
}
assert.Equal(t, fmt.Sprintf("mydata-%s-0-", expectedName), pvcs.Items[0].GenerateName)
assert.Equal(t, cluster.Namespace, pvcs.Items[0].Namespace)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment