Merge pull request #115052 from kidddddddddddddddddddddd/fix/volume_zone

fix volume_zone, iterate all topologyLabels when check node
This commit is contained in:
Kubernetes Prow Robot 2023-01-18 10:54:46 -08:00 committed by GitHub
commit 98da10e4f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
storage "k8s.io/api/storage/v1" storage "k8s.io/api/storage/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors"
@ -209,8 +210,8 @@ func (pl *VolumeZone) Filter(ctx context.Context, cs *framework.CycleState, pod
node := nodeInfo.Node() node := nodeInfo.Node()
hasAnyNodeConstraint := false hasAnyNodeConstraint := false
for _, pvTopology := range podPVTopologies { for _, topologyLabel := range topologyLabels {
if _, ok := node.Labels[pvTopology.key]; ok { if _, ok := node.Labels[topologyLabel]; ok {
hasAnyNodeConstraint = true hasAnyNodeConstraint = true
break break
} }

View File

@ -215,6 +215,19 @@ func TestSingleZone(t *testing.T) {
}, },
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict), wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
}, },
{
name: "pv with zone,node with beta zone",
Pod: createPodWithVolume("pod_1", "Vol_Stable_1", "PVC_Stable_1"),
Node: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "host1",
Labels: map[string]string{
v1.LabelFailureDomainBetaZone: "us-west1-a",
},
},
},
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
},
} }
for _, test := range tests { for _, test := range tests {