mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #114896 from kidddddddddddddddddddddd/volume_zone
feature(volume_zone): return Skip in PreFilter
This commit is contained in:
commit
eabb70833a
@ -98,6 +98,9 @@ func (pl *VolumeZone) PreFilter(ctx context.Context, cs *framework.CycleState, p
|
|||||||
if !status.IsSuccess() {
|
if !status.IsSuccess() {
|
||||||
return nil, status
|
return nil, status
|
||||||
}
|
}
|
||||||
|
if len(podPVTopologies) == 0 {
|
||||||
|
return nil, framework.NewStatus(framework.Skip)
|
||||||
|
}
|
||||||
cs.Write(preFilterStateKey, &stateData{podPVTopologies: podPVTopologies})
|
cs.Write(preFilterStateKey, &stateData{podPVTopologies: podPVTopologies})
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,8 @@ func TestSingleZone(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
Pod *v1.Pod
|
Pod *v1.Pod
|
||||||
Node *v1.Node
|
Node *v1.Node
|
||||||
wantStatus *framework.Status
|
wantPreFilterStatus *framework.Status
|
||||||
|
wantFilterStatus *framework.Status
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "pod without volume",
|
name: "pod without volume",
|
||||||
@ -106,6 +107,7 @@ func TestSingleZone(t *testing.T) {
|
|||||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a"},
|
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-a"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
wantPreFilterStatus: framework.NewStatus(framework.Skip),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "node without labels",
|
name: "node without labels",
|
||||||
@ -145,7 +147,7 @@ func TestSingleZone(t *testing.T) {
|
|||||||
Labels: map[string]string{v1.LabelFailureDomainBetaRegion: "no_us-west1", "uselessLabel": "none"},
|
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",
|
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"},
|
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",
|
name: "zone label matched",
|
||||||
@ -187,7 +189,7 @@ func TestSingleZone(t *testing.T) {
|
|||||||
Labels: map[string]string{v1.LabelTopologyRegion: "no_us-west1", "uselessLabel": "none"},
|
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",
|
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"},
|
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",
|
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),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,17 +230,13 @@ func TestSingleZone(t *testing.T) {
|
|||||||
pvcLister,
|
pvcLister,
|
||||||
nil,
|
nil,
|
||||||
}
|
}
|
||||||
|
_, preFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||||
_, gotPreFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
if diff := cmp.Diff(preFilterStatus, test.wantPreFilterStatus); diff != "" {
|
||||||
if !gotPreFilterStatus.IsSuccess() {
|
t.Errorf("PreFilter: status does not match (-want,+got):\n%s", diff)
|
||||||
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 != "" {
|
|
||||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
|
||||||
}
|
}
|
||||||
|
filterStatus := p.Filter(ctx, state, test.Pod, node)
|
||||||
|
if diff := cmp.Diff(filterStatus, test.wantFilterStatus); diff != "" {
|
||||||
|
t.Errorf("Filter: status does not match (-want,+got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -294,7 +292,8 @@ func TestMultiZone(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
Pod *v1.Pod
|
Pod *v1.Pod
|
||||||
Node *v1.Node
|
Node *v1.Node
|
||||||
wantStatus *framework.Status
|
wantPreFilterStatus *framework.Status
|
||||||
|
wantFilterStatus *framework.Status
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "node without labels",
|
name: "node without labels",
|
||||||
@ -324,7 +323,7 @@ func TestMultiZone(t *testing.T) {
|
|||||||
Labels: map[string]string{v1.LabelFailureDomainBetaZone: "us-west1-b", "uselessLabel": "none"},
|
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",
|
name: "zone label matched",
|
||||||
@ -345,7 +344,7 @@ func TestMultiZone(t *testing.T) {
|
|||||||
Labels: map[string]string{v1.LabelTopologyZone: "us-west1-b", "uselessLabel": "none"},
|
Labels: map[string]string{v1.LabelTopologyZone: "us-west1-b", "uselessLabel": "none"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonConflict),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,16 +361,13 @@ func TestMultiZone(t *testing.T) {
|
|||||||
pvcLister,
|
pvcLister,
|
||||||
nil,
|
nil,
|
||||||
}
|
}
|
||||||
_, gotPreFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
_, preFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||||
if !gotPreFilterStatus.IsSuccess() {
|
if diff := cmp.Diff(preFilterStatus, test.wantPreFilterStatus); diff != "" {
|
||||||
if diff := cmp.Diff(gotPreFilterStatus, test.wantStatus); diff != "" {
|
t.Errorf("PreFilter: status does not match (-want,+got):\n%s", 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 != "" {
|
|
||||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
|
||||||
}
|
}
|
||||||
|
filterStatus := p.Filter(ctx, state, test.Pod, node)
|
||||||
|
if diff := cmp.Diff(filterStatus, test.wantFilterStatus); diff != "" {
|
||||||
|
t.Errorf("Filter: status does not match (-want,+got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -435,7 +431,8 @@ func TestWithBinding(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
Pod *v1.Pod
|
Pod *v1.Pod
|
||||||
Node *v1.Node
|
Node *v1.Node
|
||||||
wantStatus *framework.Status
|
wantPreFilterStatus *framework.Status
|
||||||
|
wantFilterStatus *framework.Status
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "label zone failure domain matched",
|
name: "label zone failure domain matched",
|
||||||
@ -446,26 +443,32 @@ func TestWithBinding(t *testing.T) {
|
|||||||
name: "unbound volume empty storage class",
|
name: "unbound volume empty storage class",
|
||||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_EmptySC"),
|
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_EmptySC"),
|
||||||
Node: testNode,
|
Node: testNode,
|
||||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||||
|
"PersistentVolumeClaim had no pv name and storageClass name"),
|
||||||
|
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||||
"PersistentVolumeClaim had no pv name and storageClass name"),
|
"PersistentVolumeClaim had no pv name and storageClass name"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "unbound volume no storage class",
|
name: "unbound volume no storage class",
|
||||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_NoSC"),
|
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_NoSC"),
|
||||||
Node: testNode,
|
Node: testNode,
|
||||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||||
|
"unable to find storage class: Class_0"),
|
||||||
|
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable,
|
||||||
"unable to find storage class: Class_0"),
|
"unable to find storage class: Class_0"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "unbound volume immediate binding mode",
|
name: "unbound volume immediate binding mode",
|
||||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_ImmediateSC"),
|
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_ImmediateSC"),
|
||||||
Node: testNode,
|
Node: testNode,
|
||||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "VolumeBindingMode not set for StorageClass \"Class_Immediate\""),
|
wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "VolumeBindingMode not set for StorageClass \"Class_Immediate\""),
|
||||||
|
wantFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "VolumeBindingMode not set for StorageClass \"Class_Immediate\""),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "unbound volume wait binding mode",
|
name: "unbound volume wait binding mode",
|
||||||
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_WaitSC"),
|
Pod: createPodWithVolume("pod_1", "vol_1", "PVC_WaitSC"),
|
||||||
Node: testNode,
|
Node: testNode,
|
||||||
|
wantPreFilterStatus: framework.NewStatus(framework.Skip),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,16 +485,13 @@ func TestWithBinding(t *testing.T) {
|
|||||||
pvcLister,
|
pvcLister,
|
||||||
scLister,
|
scLister,
|
||||||
}
|
}
|
||||||
_, gotPreFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
_, preFilterStatus := p.PreFilter(ctx, state, test.Pod)
|
||||||
if !gotPreFilterStatus.IsSuccess() {
|
if diff := cmp.Diff(preFilterStatus, test.wantPreFilterStatus); diff != "" {
|
||||||
if diff := cmp.Diff(gotPreFilterStatus, test.wantStatus); diff != "" {
|
t.Errorf("PreFilter: status does not match (-want,+got):\n%s", 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 != "" {
|
|
||||||
t.Errorf("status does not match (-want,+got):\n%s", diff)
|
|
||||||
}
|
}
|
||||||
|
filterStatus := p.Filter(ctx, state, test.Pod, node)
|
||||||
|
if diff := cmp.Diff(filterStatus, test.wantFilterStatus); diff != "" {
|
||||||
|
t.Errorf("Filter: status does not match (-want,+got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user