@@ -29,6 +29,7 @@ import (
29
29
_ "k8s.io/client-go/plugin/pkg/client/auth"
30
30
31
31
corev1 "k8s.io/api/core/v1"
32
+ "k8s.io/apimachinery/pkg/fields"
32
33
"k8s.io/apimachinery/pkg/runtime"
33
34
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
34
35
"k8s.io/client-go/dynamic"
@@ -37,6 +38,7 @@ import (
37
38
"k8s.io/klog/v2"
38
39
ctrl "sigs.k8s.io/controller-runtime"
39
40
41
+ "sigs.k8s.io/controller-runtime/pkg/cache"
40
42
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
41
43
"sigs.k8s.io/controller-runtime/pkg/healthz"
42
44
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
@@ -99,13 +101,20 @@ func init() {
99
101
func main () {
100
102
bindFlags ()
101
103
must (validateFlags (), "invalid flags" )
104
+ cacheOpts := cache.Options {
105
+ DefaultTransform : cache .TransformStripManagedFields (),
106
+ }
107
+
102
108
// Build the leader election ID deterministically and based on the flags
103
109
leaderId := "208d7abd.multiarch.openshift.io"
104
110
if enableOperator {
105
111
leaderId = fmt .Sprintf ("operator-%s" , leaderId )
106
112
}
107
113
if enableClusterPodPlacementConfigOperandControllers {
108
114
leaderId = fmt .Sprintf ("ppc-controllers-%s" , leaderId )
115
+ // We need to watch the pods with the status.phase equal to Pending to be able to update the nodeAffinity.
116
+ // We can discard the other pods because they are already scheduled.
117
+ cacheOpts .DefaultFieldSelector = fields .OneTermEqualSelector ("status.phase" , "Pending" )
109
118
}
110
119
// Rapid Reset CVEs. For more information see:
111
120
// - https://github.com/advisories/GHSA-qppj-fm5r-hxr3
@@ -135,6 +144,7 @@ func main() {
135
144
HealthProbeBindAddress : probeAddr ,
136
145
LeaderElection : enableLeaderElection ,
137
146
LeaderElectionID : leaderId ,
147
+ Cache : cacheOpts ,
138
148
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
139
149
// when the Manager ends. This requires the binary to immediately end when the
140
150
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
0 commit comments