Merge pull request #118923 from AxeZhan/volume_zone_csi

[Scheduler]Translate beta label to ga in volume_zone
This commit is contained in:
Kubernetes Prow Robot 2023-08-17 20:20:28 -07:00 committed by GitHub
commit 312dc127a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -83,6 +83,16 @@ var topologyLabels = []string{
v1.LabelTopologyRegion, v1.LabelTopologyRegion,
} }
func translateToGALabel(label string) string {
if label == v1.LabelFailureDomainBetaRegion {
return v1.LabelTopologyRegion
}
if label == v1.LabelFailureDomainBetaZone {
return v1.LabelTopologyZone
}
return label
}
// Name returns name of the plugin. It is used in logs, etc. // Name returns name of the plugin. It is used in logs, etc.
func (pl *VolumeZone) Name() string { func (pl *VolumeZone) Name() string {
return Name return Name
@ -227,6 +237,10 @@ func (pl *VolumeZone) Filter(ctx context.Context, cs *framework.CycleState, pod
for _, pvTopology := range podPVTopologies { for _, pvTopology := range podPVTopologies {
v, ok := node.Labels[pvTopology.key] v, ok := node.Labels[pvTopology.key]
if !ok {
// if we can't match the beta label, try to match pv's beta label with node's ga label
v, ok = node.Labels[translateToGALabel(pvTopology.key)]
}
if !ok || !pvTopology.values.Has(v) { if !ok || !pvTopology.values.Has(v) {
logger.V(10).Info("Won't schedule pod onto node due to volume (mismatch on label key)", "pod", klog.KObj(pod), "node", klog.KObj(node), "PV", klog.KRef("", pvTopology.pvName), "PVLabelKey", pvTopology.key) logger.V(10).Info("Won't schedule pod onto node due to volume (mismatch on label key)", "pod", klog.KObj(pod), "node", klog.KObj(node), "PV", klog.KRef("", pvTopology.pvName), "PVLabelKey", pvTopology.key)
return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict) return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict)

View File

@ -229,6 +229,31 @@ func TestSingleZone(t *testing.T) {
}, },
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict), wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
}, },
{
name: "pv with beta label,node with ga label, matched",
Pod: createPodWithVolume("pod_1", "Vol_1", "PVC_1"),
Node: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "host1",
Labels: map[string]string{
v1.LabelTopologyZone: "us-west1-a",
},
},
},
},
{
name: "pv with beta label,node with ga label, don't match",
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_1"),
Node: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "host1",
Labels: map[string]string{
v1.LabelTopologyZone: "us-west1-b",
},
},
},
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
},
} }
for _, test := range tests { for _, test := range tests {