This commit is contained in:
notpad
2020-02-11 16:51:21 +08:00
parent a7057f8df0
commit fb895056c6
11 changed files with 81 additions and 5 deletions

View File

@@ -388,7 +388,7 @@ func (pl *InterPodAffinity) RemovePod(ctx context.Context, cycleState *framework
func getPreFilterState(cycleState *framework.CycleState) (*preFilterState, error) {
c, err := cycleState.Read(preFilterStateKey)
if err != nil {
// The preFilterState wasn't pre-computed in prefilter.
// preFilterState doesn't exist, likely PreFilter wasn't invoked.
return nil, fmt.Errorf("error reading %q from cycleState: %v", preFilterStateKey, err)
}

View File

@@ -1634,6 +1634,20 @@ func TestRequiredAffinityMultipleNodes(t *testing.T) {
}
}
func TestPreFilterDisabled(t *testing.T) {
pod := &v1.Pod{}
nodeInfo := nodeinfo.NewNodeInfo()
node := v1.Node{}
nodeInfo.SetNode(&node)
p := &InterPodAffinity{}
cycleState := framework.NewCycleState()
gotStatus := p.Filter(context.Background(), cycleState, pod, nodeInfo)
wantStatus := framework.NewStatus(framework.Error, `error reading "PreFilterInterPodAffinity" from cycleState: not found`)
if !reflect.DeepEqual(gotStatus, wantStatus) {
t.Errorf("status does not match: %v, want: %v", gotStatus, wantStatus)
}
}
func TestPreFilterStateAddRemovePod(t *testing.T) {
var label1 = map[string]string{
"region": "r1",