mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
return skip
This commit is contained in:
parent
ca5c522080
commit
de7c8db7cb
@ -98,6 +98,9 @@ func (pl *VolumeZone) PreFilter(ctx context.Context, cs *framework.CycleState, p
|
||||
if !status.IsSuccess() {
|
||||
return nil, status
|
||||
}
|
||||
if len(podPVTopologies) == 0 {
|
||||
return nil, framework.NewStatus(framework.Skip)
|
||||
}
|
||||
cs.Write(preFilterStateKey, &stateData{podPVTopologies: podPVTopologies})
|
||||
return nil, nil
|
||||
}
|
||||
@ -186,11 +189,6 @@ func (pl *VolumeZone) PreFilterExtensions() framework.PreFilterExtensions {
|
||||
// require calling out to the cloud provider. It seems that we are moving away
|
||||
// from inline volume declarations anyway.
|
||||
func (pl *VolumeZone) Filter(ctx context.Context, cs *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status {
|
||||
// If a pod doesn't have any volume attached to it, the predicate will always be true.
|
||||
// Thus we make a fast path for it, to avoid unnecessary computations in this case.
|
||||
if len(pod.Spec.Volumes) == 0 {
|
||||
return nil
|
||||
}
|
||||
var podPVTopologies []pvTopology
|
||||
state, err := getStateData(cs)
|
||||
if err != nil {
|
||||
|
@ -92,10 +92,11 @@ func TestSingleZone(t *testing.T) {
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
Pod *v1.Pod
|
||||
Node *v1.Node
|
||||
wantStatus *framework.Status
|
||||
name string
|
||||
Pod *v1.Pod
|
||||
Node *v1.Node
|
||||
wantPreFilterStatus *framework.Status
|
||||
wantFilterStatus *framework.Status
|
||||
}{
|
||||
{
|
||||
name: "pod without volume",
|
||||
@ -106,6 +107,7 @@ func TestSingleZone(t *testing.T) {
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a"},
|
||||
},
|
||||
},
|
||||
wantPreFilterStatus: framework.NewStatus(framework.Skip),
|
||||
},
|
||||
{
|
||||
name: "node without labels",
|
||||
@ -145,7 +147,7 @@ func TestSingleZone(t *testing.T) {
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaRegion: "no_us-west1", "uselessLabel": "none"},
|
||||
},
|
||||
},
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
},
|
||||
{
|
||||
name: "beta zone label doesn't match",
|
||||
@ -156,7 +158,7 @@ func TestSingleZone(t *testing.T) {
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "no_us-west1-a", "uselessLabel": "none"},
|
||||
},
|
||||
},
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
},
|
||||
{
|
||||
name: "zone label matched",
|
||||
@ -187,7 +189,7 @@ func TestSingleZone(t *testing.T) {
|
||||
Labels: map[string]string{v1.LabelTopologyRegion: "no_us-west1", "uselessLabel": "none"},
|
||||
},
|
||||
},
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
},
|
||||
{
|
||||
name: "zone label doesn't match",
|
||||
@ -198,7 +200,7 @@ func TestSingleZone(t *testing.T) {
|
||||
Labels: map[string]string{v1.LabelTopologyZone: "no_us-west1-a", "uselessLabel": "none"},
|
||||
},
|
||||
},
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
},
|
||||
{
|
||||
name: "pv with zone and region, node with only zone",
|
||||
@ -211,7 +213,7 @@ func TestSingleZone(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
},
|
||||
}
|
||||
|
||||
@ -229,14 +231,13 @@ func TestSingleZone(t *testing.T) {
|
||||
nil,
|
||||
}
|
||||
|
||||
_, gotPreFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||
if !gotPreFilterStatus.IsSuccess() {
|
||||
if diff := cmp.Diff(gotPreFilterStatus, test.wantStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
} else {
|
||||
gotStatus := p.Filter(ctx, state, test.Pod, node)
|
||||
if diff := cmp.Diff(gotStatus, test.wantStatus); diff != "" {
|
||||
_, preFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||
if diff := cmp.Diff(preFilterStatus, test.wantPreFilterStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
if preFilterStatus.IsSuccess() {
|
||||
filterStatus := p.Filter(ctx, state, test.Pod, node)
|
||||
if diff := cmp.Diff(filterStatus, test.wantFilterStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
@ -291,10 +292,11 @@ func TestMultiZone(t *testing.T) {
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
Pod *v1.Pod
|
||||
Node *v1.Node
|
||||
wantStatus *framework.Status
|
||||
name string
|
||||
Pod *v1.Pod
|
||||
Node *v1.Node
|
||||
wantPreFilterStatus *framework.Status
|
||||
wantFilterStatus *framework.Status
|
||||
}{
|
||||
{
|
||||
name: "node without labels",
|
||||
@ -324,7 +326,7 @@ func TestMultiZone(t *testing.T) {
|
||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-b", "uselessLabel": "none"},
|
||||
},
|
||||
},
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
},
|
||||
{
|
||||
name: "zone label matched",
|
||||
@ -345,7 +347,7 @@ func TestMultiZone(t *testing.T) {
|
||||
Labels: map[string]string{v1.LabelTopologyZone: "us-west1-b", "uselessLabel": "none"},
|
||||
},
|
||||
},
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||
},
|
||||
}
|
||||
|
||||
@ -362,14 +364,13 @@ func TestMultiZone(t *testing.T) {
|
||||
pvcLister,
|
||||
nil,
|
||||
}
|
||||
_, gotPreFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||
if !gotPreFilterStatus.IsSuccess() {
|
||||
if diff := cmp.Diff(gotPreFilterStatus, test.wantStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
} else {
|
||||
gotStatus := p.Filter(context.Background(), state, test.Pod, node)
|
||||
if diff := cmp.Diff(gotStatus, test.wantStatus); diff != "" {
|
||||
_, preFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||
if diff := cmp.Diff(preFilterStatus, test.wantPreFilterStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
if preFilterStatus.IsSuccess() {
|
||||
filterStatus := p.Filter(context.Background(), state, test.Pod, node)
|
||||
if diff := cmp.Diff(filterStatus, test.wantFilterStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
@ -432,10 +433,11 @@ func TestWithBinding(t *testing.T) {
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
Pod *v1.Pod
|
||||
Node *v1.Node
|
||||
wantStatus *framework.Status
|
||||
name string
|
||||
Pod *v1.Pod
|
||||
Node *v1.Node
|
||||
wantPreFilterStatus *framework.Status
|
||||
wantFilterStatus *framework.Status
|
||||
}{
|
||||
{
|
||||
name: "label zone failure domain matched",
|
||||
@ -446,26 +448,27 @@ func TestWithBinding(t *testing.T) {
|
||||
name: "unbound volume empty storage class",
|
||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_EmptySC"),
|
||||
Node: testNode,
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||
wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||
"PersistentVolumeClaim had no pv name and storageClass name"),
|
||||
},
|
||||
{
|
||||
name: "unbound volume no storage class",
|
||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_NoSC"),
|
||||
Node: testNode,
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||
wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||
"unable to find storage class: Class_0"),
|
||||
},
|
||||
{
|
||||
name: "unbound volume immediate binding mode",
|
||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_ImmediateSC"),
|
||||
Node: testNode,
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "VolumeBindingMode not set for StorageClass \"Class_Immediate\""),
|
||||
name: "unbound volume immediate binding mode",
|
||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_ImmediateSC"),
|
||||
Node: testNode,
|
||||
wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "VolumeBindingMode not set for StorageClass \"Class_Immediate\""),
|
||||
},
|
||||
{
|
||||
name: "unbound volume wait binding mode",
|
||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_WaitSC"),
|
||||
Node: testNode,
|
||||
name: "unbound volume wait binding mode",
|
||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_WaitSC"),
|
||||
Node: testNode,
|
||||
wantPreFilterStatus: framework.NewStatus(framework.Skip),
|
||||
},
|
||||
}
|
||||
|
||||
@ -482,14 +485,13 @@ func TestWithBinding(t *testing.T) {
|
||||
pvcLister,
|
||||
scLister,
|
||||
}
|
||||
_, gotPreFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||
if !gotPreFilterStatus.IsSuccess() {
|
||||
if diff := cmp.Diff(gotPreFilterStatus, test.wantStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
} else {
|
||||
gotStatus := p.Filter(ctx, state, test.Pod, node)
|
||||
if diff := cmp.Diff(gotStatus, test.wantStatus); diff != "" {
|
||||
_, preFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||
if diff := cmp.Diff(preFilterStatus, test.wantPreFilterStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
if preFilterStatus.IsSuccess() {
|
||||
filterStatus := p.Filter(ctx, state, test.Pod, node)
|
||||
if diff := cmp.Diff(filterStatus, test.wantFilterStatus); diff != "" {
|
||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user