@@ -104,16 +104,7 @@ func handle() {
104
104
LeaderElection : enableLeaderElection ,
105
105
LeaderElectionNamespace : leaderElectionNamespace ,
106
106
LeaderElectionID : "fluidapp.data.fluid.io" ,
107
- Cache : cache.Options {
108
- Scheme : scheme ,
109
- ByObject : map [client.Object ]cache.ByObject {
110
- & corev1.Pod {}: {
111
- Label : labels .SelectorFromSet (labels.Set {
112
- common .InjectSidecarDone : common .True ,
113
- }),
114
- },
115
- },
116
- },
107
+ Cache : newCacheOptions (),
117
108
})
118
109
if err != nil {
119
110
setupLog .Error (err , "unable to start fluid app manager" )
@@ -150,10 +141,9 @@ func handle() {
150
141
}
151
142
}
152
143
153
- func NewCache ( scheme * runtime. Scheme ) cache.NewCacheFunc {
144
+ func newCacheOptions ( ) cache.Options {
154
145
options := cache.Options {
155
- Scheme : scheme ,
156
- SelectorsByObject : cache.SelectorsByObject {
146
+ ByObject : map [client.Object ]cache.ByObject {
157
147
& corev1.Pod {}: {
158
148
Label : labels .SelectorFromSet (labels.Set {
159
149
// watch pods managed by fluid, like data operation pods, serverless app pods.
@@ -163,13 +153,13 @@ func NewCache(scheme *runtime.Scheme) cache.NewCacheFunc {
163
153
},
164
154
}
165
155
if dataflow .Enabled (dataflow .DataflowAffinity ) {
166
- options .SelectorsByObject [& batchv1.Job {}] = cache.ObjectSelector {
156
+ options .ByObject [& batchv1.Job {}] = cache.ByObject {
167
157
// watch data operation job
168
158
Label : labels .SelectorFromSet (labels.Set {
169
159
// only data operations create job resource and the jobs created by cronjob do not have this label.
170
160
common .LabelAnnotationManagedBy : common .Fluid ,
171
161
}),
172
162
}
173
163
}
174
- return cache . BuilderWithOptions ( options )
164
+ return options
175
165
}
0 commit comments