mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #99367 from jsafrane/cinder-translation-labels
cinder: Translate CSI topology affinity into in-tree labels
This commit is contained in:
commit
e7d9320b0d
@ -421,6 +421,48 @@ func TestTranslateTopologyFromCSIToInTree(t *testing.T) {
|
|||||||
v1.LabelTopologyRegion: "us-east1",
|
v1.LabelTopologyRegion: "us-east1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "cinder translation",
|
||||||
|
key: CinderTopologyKey,
|
||||||
|
expErr: false,
|
||||||
|
regionParser: nil,
|
||||||
|
pv: &v1.PersistentVolume{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "cinder", Namespace: "myns",
|
||||||
|
},
|
||||||
|
Spec: v1.PersistentVolumeSpec{
|
||||||
|
NodeAffinity: &v1.VolumeNodeAffinity{
|
||||||
|
Required: &v1.NodeSelector{
|
||||||
|
NodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{
|
||||||
|
{
|
||||||
|
Key: CinderTopologyKey,
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"nova"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedNodeSelectorTerms: []v1.NodeSelectorTerm{
|
||||||
|
{
|
||||||
|
MatchExpressions: []v1.NodeSelectorRequirement{
|
||||||
|
{
|
||||||
|
Key: v1.LabelTopologyZone,
|
||||||
|
Operator: v1.NodeSelectorOpIn,
|
||||||
|
Values: []string{"nova"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedLabels: map[string]string{
|
||||||
|
v1.LabelTopologyZone: "nova",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
@ -144,6 +144,12 @@ func (t *osCinderCSITranslator) TranslateCSIPVToInTree(pv *v1.PersistentVolume)
|
|||||||
ReadOnly: csiSource.ReadOnly,
|
ReadOnly: csiSource.ReadOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// translate CSI topology to In-tree topology for rollback compatibility.
|
||||||
|
// It is not possible to guess Cinder Region from the Zone, therefore leave it empty.
|
||||||
|
if err := translateTopologyFromCSIToInTree(pv, CinderTopologyKey, nil); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to translate topology. PV:%+v. Error:%v", *pv, err)
|
||||||
|
}
|
||||||
|
|
||||||
pv.Spec.CSI = nil
|
pv.Spec.CSI = nil
|
||||||
pv.Spec.Cinder = cinderSource
|
pv.Spec.Cinder = cinderSource
|
||||||
return pv, nil
|
return pv, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user