Skip to content

Commit a2ae4a6

Browse files
committed
Fix improper controller-runtime cache configuration
When AppWrappers are enabled, it is not correct to configure the controller-runtime cache with a filter that only allows services, secrets, etc with the RayCluster label to be cached. This breaks any AppWrapper that contains one of these resource kinds.
1 parent c028863 commit a2ae4a6

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

main.go

+26-28
Original file line numberDiff line numberDiff line change
@@ -171,36 +171,34 @@ func main() {
171171
kubeConfig.QPS = ptr.Deref(cfg.ClientConnection.QPS, rest.DefaultQPS)
172172
setupLog.V(2).Info("REST client", "qps", kubeConfig.QPS, "burst", kubeConfig.Burst)
173173

174-
selector, err := labels.Parse(controllers.RayClusterNameLabel)
175-
exitOnError(err, "unable to parse label selector")
176-
177-
cacheOpts := cache.Options{
178-
ByObject: map[client.Object]cache.ByObject{
179-
&corev1.Secret{}: {
180-
Label: selector,
181-
},
182-
&corev1.Service{}: {
183-
Label: selector,
184-
},
185-
&corev1.ServiceAccount{}: {
186-
Label: selector,
187-
},
188-
&networkingv1.Ingress{}: {
189-
Label: selector,
190-
},
191-
&networkingv1.NetworkPolicy{}: {
192-
Label: selector,
193-
},
194-
&rbacv1.ClusterRoleBinding{}: {
195-
Label: selector,
196-
},
197-
},
198-
}
199-
200-
if isOpenShift(ctx, kubeClient.DiscoveryClient) {
201-
cacheOpts.ByObject[&routev1.Route{}] = cache.ByObject{
174+
cacheOpts := cache.Options{}
175+
if cfg.AppWrapper == nil || !ptr.Deref(cfg.AppWrapper.Enabled, false) {
176+
selector, err := labels.Parse(controllers.RayClusterNameLabel)
177+
exitOnError(err, "unable to parse label selector")
178+
cacheOpts.ByObject = make(map[client.Object]cache.ByObject, 7)
179+
cacheOpts.ByObject[&corev1.Secret{}] = cache.ByObject{
180+
Label: selector,
181+
}
182+
cacheOpts.ByObject[&corev1.Service{}] = cache.ByObject{
183+
Label: selector,
184+
}
185+
cacheOpts.ByObject[&corev1.ServiceAccount{}] = cache.ByObject{
186+
Label: selector,
187+
}
188+
cacheOpts.ByObject[&networkingv1.Ingress{}] = cache.ByObject{
202189
Label: selector,
203190
}
191+
cacheOpts.ByObject[&networkingv1.NetworkPolicy{}] = cache.ByObject{
192+
Label: selector,
193+
}
194+
cacheOpts.ByObject[&rbacv1.ClusterRoleBinding{}] = cache.ByObject{
195+
Label: selector,
196+
}
197+
if isOpenShift(ctx, kubeClient.DiscoveryClient) {
198+
cacheOpts.ByObject[&routev1.Route{}] = cache.ByObject{
199+
Label: selector,
200+
}
201+
}
204202
}
205203

206204
mgr, err := ctrl.NewManager(kubeConfig, ctrl.Options{

0 commit comments

Comments
 (0)