atlassian / escalator

Escalator is a batch or job optimized horizontal autoscaler for Kubernetes
Apache License 2.0
662 stars 59 forks source link

Default Pod Selector ignores Pods with affinity set to empty struct #209

Closed decayofmind closed 2 years ago

decayofmind commented 2 years ago

Some solutions such as Gitlab Runner (https://gitlab.com/gitlab-org/gitlab-runner/-/blob/main/common/config.go#L1093) if affinity is not especially set via configs will produce Pods with affinity: {}.

In this case expression pod.Spec.Affinity == nil is not valid, and Affinity is equal to &Affinity{NodeAffinity:nil,PodAffinity:nil,PodAntiAffinity:nil,}.

Affinity is still not set, so condition for Default Pod Selector is still met, however escalator will ignore such pods.

My PR extends NewPodDefaultFilterFunc() fixing this.

patrickshan commented 2 years ago

Thanks for the contribute.