mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Merge pull request #112635 from humblec/rbd-image-prefix
rbd: try to tolerate the images without 'kubernetes-dynamic-pvc' prefix
This commit is contained in:
commit
664f0f5677
@ -294,7 +294,7 @@ func composeMigVolID(mons string, pool string, image string) string {
|
|||||||
clusterIDInHandle := md5.Sum([]byte(mons))
|
clusterIDInHandle := md5.Sum([]byte(mons))
|
||||||
clusterField := monsPfx + fmt.Sprintf("%x", clusterIDInHandle)
|
clusterField := monsPfx + fmt.Sprintf("%x", clusterIDInHandle)
|
||||||
poolHashInHandle := hex.EncodeToString([]byte(pool))
|
poolHashInHandle := hex.EncodeToString([]byte(pool))
|
||||||
imageHashInHandle := strings.Split(image, defaultIntreeImagePfx)[1]
|
imageHashInHandle := strings.TrimPrefix(image, defaultIntreeImagePfx)
|
||||||
imageField := imgPfx + imageHashInHandle
|
imageField := imgPfx + imageHashInHandle
|
||||||
volHash := strings.Join([]string{migVolPfx, clusterField, imageField, poolHashInHandle}, "_")
|
volHash := strings.Join([]string{migVolPfx, clusterField, imageField, poolHashInHandle}, "_")
|
||||||
return volHash
|
return volHash
|
||||||
|
@ -305,6 +305,79 @@ func TestTranslateRBDInTreePVToCSI(t *testing.T) {
|
|||||||
},
|
},
|
||||||
errExpected: false,
|
errExpected: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "normal-pvc-without-dynamic-provisioner-pfx-set",
|
||||||
|
inTree: &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: RBDDriverName,
|
||||||
|
},
|
||||||
|
Spec: v1.PersistentVolumeSpec{
|
||||||
|
AccessModes: []v1.PersistentVolumeAccessMode{
|
||||||
|
v1.ReadWriteOnce,
|
||||||
|
},
|
||||||
|
ClaimRef: &v1.ObjectReference{
|
||||||
|
Name: "test-pvc",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
|
RBD: &v1.RBDPersistentVolumeSource{
|
||||||
|
CephMonitors: []string{"10.70.53.126:6789"},
|
||||||
|
RBDPool: "replicapool",
|
||||||
|
RBDImage: "e4111eb6-4088-11ec-b823-0242ac110003",
|
||||||
|
RadosUser: "admin",
|
||||||
|
FSType: "ext4",
|
||||||
|
ReadOnly: false,
|
||||||
|
SecretRef: &v1.SecretReference{
|
||||||
|
Name: "ceph-secret",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
csi: &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: RBDDriverName,
|
||||||
|
},
|
||||||
|
Spec: v1.PersistentVolumeSpec{
|
||||||
|
AccessModes: []v1.PersistentVolumeAccessMode{
|
||||||
|
v1.ReadWriteOnce,
|
||||||
|
},
|
||||||
|
ClaimRef: &v1.ObjectReference{
|
||||||
|
Name: "test-pvc",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
PersistentVolumeSource: v1.PersistentVolumeSource{
|
||||||
|
CSI: &v1.CSIPersistentVolumeSource{
|
||||||
|
Driver: RBDDriverName,
|
||||||
|
VolumeHandle: "mig_mons-b7f67366bb43f32e07d8a261a7840da9_image-e4111eb6-4088-11ec-b823-0242ac110003_7265706c696361706f6f6c",
|
||||||
|
ReadOnly: false,
|
||||||
|
FSType: "ext4",
|
||||||
|
VolumeAttributes: map[string]string{
|
||||||
|
"clusterID": "b7f67366bb43f32e07d8a261a7840da9",
|
||||||
|
"imageFeatures": "layering",
|
||||||
|
"imageFormat": "",
|
||||||
|
"imageName": "e4111eb6-4088-11ec-b823-0242ac110003",
|
||||||
|
"journalPool": "",
|
||||||
|
"migration": "true",
|
||||||
|
"pool": "replicapool",
|
||||||
|
"staticVolume": "true",
|
||||||
|
"tryOtherMounters": "true",
|
||||||
|
},
|
||||||
|
NodeStageSecretRef: &v1.SecretReference{
|
||||||
|
Name: "ceph-secret",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
ControllerExpandSecretRef: &v1.SecretReference{
|
||||||
|
Name: "ceph-secret",
|
||||||
|
Namespace: "default",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
errExpected: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "nil PV",
|
name: "nil PV",
|
||||||
inTree: nil,
|
inTree: nil,
|
||||||
|
Loading…
Reference in New Issue
Block a user