diff --git a/pkg/scheduler/framework/plugins/volumezone/volume_zone.go b/pkg/scheduler/framework/plugins/volumezone/volume_zone.go index b0504ea7f78..b014130b64a 100644 --- a/pkg/scheduler/framework/plugins/volumezone/volume_zone.go +++ b/pkg/scheduler/framework/plugins/volumezone/volume_zone.go @@ -83,6 +83,16 @@ var topologyLabels = []string{ 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. func (pl *VolumeZone) Name() string { return Name @@ -227,6 +237,10 @@ func (pl *VolumeZone) Filter(ctx context.Context, cs *framework.CycleState, pod for _, pvTopology := range podPVTopologies { 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) { 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) diff --git a/pkg/scheduler/framework/plugins/volumezone/volume_zone_test.go b/pkg/scheduler/framework/plugins/volumezone/volume_zone_test.go index bce393048fa..2d9859c9eb2 100644 --- a/pkg/scheduler/framework/plugins/volumezone/volume_zone_test.go +++ b/pkg/scheduler/framework/plugins/volumezone/volume_zone_test.go @@ -229,6 +229,31 @@ func TestSingleZone(t *testing.T) { }, 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 {