mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #92815 from Huang-Wei/bypass-prefilter-svcaffinity
Bypass PreFilter in ServiceAfffinity if AffinityLabels arg is not present
This commit is contained in:
commit
36b4c2942b
@ -127,10 +127,13 @@ func (pl *ServiceAffinity) createPreFilterState(pod *v1.Pod) (*preFilterState, e
|
|||||||
|
|
||||||
// PreFilter invoked at the prefilter extension point.
|
// PreFilter invoked at the prefilter extension point.
|
||||||
func (pl *ServiceAffinity) PreFilter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod) *framework.Status {
|
func (pl *ServiceAffinity) PreFilter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod) *framework.Status {
|
||||||
|
if len(pl.args.AffinityLabels) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
s, err := pl.createPreFilterState(pod)
|
s, err := pl.createPreFilterState(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return framework.NewStatus(framework.Error, fmt.Sprintf("could not create preFilterState: %v", err))
|
return framework.NewStatus(framework.Error, fmt.Sprintf("could not create preFilterState: %v", err))
|
||||||
|
|
||||||
}
|
}
|
||||||
cycleState.Write(preFilterStateKey, s)
|
cycleState.Write(preFilterStateKey, s)
|
||||||
return nil
|
return nil
|
||||||
@ -138,6 +141,9 @@ func (pl *ServiceAffinity) PreFilter(ctx context.Context, cycleState *framework.
|
|||||||
|
|
||||||
// PreFilterExtensions returns prefilter extensions, pod add and remove.
|
// PreFilterExtensions returns prefilter extensions, pod add and remove.
|
||||||
func (pl *ServiceAffinity) PreFilterExtensions() framework.PreFilterExtensions {
|
func (pl *ServiceAffinity) PreFilterExtensions() framework.PreFilterExtensions {
|
||||||
|
if len(pl.args.AffinityLabels) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return pl
|
return pl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,6 +500,9 @@ func TestPreFilterStateAddRemovePod(t *testing.T) {
|
|||||||
p := &ServiceAffinity{
|
p := &ServiceAffinity{
|
||||||
sharedLister: snapshot,
|
sharedLister: snapshot,
|
||||||
serviceLister: fakeframework.ServiceLister(test.services),
|
serviceLister: fakeframework.ServiceLister(test.services),
|
||||||
|
args: config.ServiceAffinityArgs{
|
||||||
|
AffinityLabels: []string{"region", "zone"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
cycleState := framework.NewCycleState()
|
cycleState := framework.NewCycleState()
|
||||||
preFilterStatus := p.PreFilter(context.Background(), cycleState, test.pendingPod)
|
preFilterStatus := p.PreFilter(context.Background(), cycleState, test.pendingPod)
|
||||||
|
Loading…
Reference in New Issue
Block a user