Skip to content

Commit 95d8bcf

Browse files
committed
allow appwrapper controller to be disabled in config
1 parent a9155aa commit 95d8bcf

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

main.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ func main() {
109109
QPS: ptr.To(float32(50)),
110110
Burst: ptr.To(int32(100)),
111111
},
112-
AppWrapper: awconfig.NewConfig(namespace),
112+
AppWrapper: &config.AppWrapperConfiguration{
113+
Enabled: ptr.To(true),
114+
Config: awconfig.NewConfig(namespace),
115+
},
113116
ControllerManager: config.ControllerManager{
114117
Metrics: config.MetricsConfiguration{
115118
BindAddress: ":8080",
@@ -126,10 +129,10 @@ func main() {
126129
RayDashboardOAuthEnabled: ptr.To(true),
127130
},
128131
}
129-
cfg.AppWrapper.CertManagement.WebhookSecretName = "codeflare-operator-webhook-server-cert"
130-
cfg.AppWrapper.CertManagement.WebhookServiceName = "codeflare-operator-webhook-service"
131-
cfg.AppWrapper.CertManagement.MutatingWebhookConfigName = "codeflare-operator-mutating-webhook-configuration"
132-
cfg.AppWrapper.CertManagement.ValidatingWebhookConfigName = "codeflare-operator-validating-webhook-configuration"
132+
cfg.AppWrapper.Config.CertManagement.WebhookSecretName = "codeflare-operator-webhook-server-cert"
133+
cfg.AppWrapper.Config.CertManagement.WebhookServiceName = "codeflare-operator-webhook-service"
134+
cfg.AppWrapper.Config.CertManagement.MutatingWebhookConfigName = "codeflare-operator-mutating-webhook-configuration"
135+
cfg.AppWrapper.Config.CertManagement.ValidatingWebhookConfigName = "codeflare-operator-validating-webhook-configuration"
133136

134137
kubeConfig, err := ctrl.GetConfig()
135138
exitOnError(err, "unable to get client config")
@@ -140,7 +143,7 @@ func main() {
140143
exitOnError(err, "unable to create Kubernetes client")
141144

142145
exitOnError(loadIntoOrCreate(ctx, kubeClient, namespaceOrDie(), configMapName, cfg), "unable to initialise configuration")
143-
exitOnError(awconfig.ValidateConfig(cfg.AppWrapper), "invalid AppWrapper configuration")
146+
exitOnError(awconfig.ValidateConfig(cfg.AppWrapper.Config), "invalid AppWrapper configuration")
144147

145148
kubeConfig.Burst = int(ptr.Deref(cfg.ClientConnection.Burst, int32(rest.DefaultBurst)))
146149
kubeConfig.QPS = ptr.Deref(cfg.ClientConnection.QPS, rest.DefaultQPS)
@@ -183,7 +186,7 @@ func main() {
183186
if os.Getenv("ENABLE_WEBHOOKS") == "false" {
184187
close(certsReady)
185188
} else {
186-
exitOnError(awctrl.SetupCertManagement(mgr, &cfg.AppWrapper.CertManagement, certsReady), "unable to set up cert rotation")
189+
exitOnError(awctrl.SetupCertManagement(mgr, &cfg.AppWrapper.Config.CertManagement, certsReady), "unable to set up cert rotation")
187190
}
188191

189192
v, err := HasAPIResourceForGVK(kubeClient.DiscoveryClient, rayv1.GroupVersion.WithKind("RayCluster"))
@@ -196,12 +199,15 @@ func main() {
196199

197200
v1, err1 := HasAPIResourceForGVK(kubeClient.DiscoveryClient, kueue.GroupVersion.WithKind("Workload"))
198201
v2, err2 := HasAPIResourceForGVK(kubeClient.DiscoveryClient, mcadv1beta2.GroupVersion.WithKind("AppWrapper"))
199-
if v1 && v2 {
202+
if v1 && v2 && *cfg.AppWrapper.Enabled {
200203
// Ascynchronous because controllers need to wait for certificate to be ready for webhooks to work
201-
go awctrl.SetupControllers(ctx, mgr, cfg.AppWrapper, certsReady, setupLog)
202-
exitOnError(awctrl.SetupIndexers(ctx, mgr, cfg.AppWrapper), "unable to setup indexers")
204+
go awctrl.SetupControllers(ctx, mgr, cfg.AppWrapper.Config, certsReady, setupLog)
205+
exitOnError(awctrl.SetupIndexers(ctx, mgr, cfg.AppWrapper.Config), "unable to setup indexers")
203206
} else if err1 != nil || err2 != nil {
204207
exitOnError(err, "Could not determine if AppWrapper and Workload CRs present on cluster.")
208+
} else {
209+
setupLog.Info("AppWrapper controller disabled", "Workload present", v1,
210+
"AppWrapper present", v2, "Config Flag", *cfg.AppWrapper.Enabled)
205211
}
206212

207213
exitOnError(awctrl.SetupProbeEndpoints(mgr, certsReady), "unable to setup probe endpoints")

pkg/config/config.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ type CodeFlareOperatorConfiguration struct {
3333
KubeRay *KubeRayConfiguration `json:"kuberay,omitempty"`
3434

3535
// AppWrapper contains the AppWrapper controller configuration
36-
AppWrapper *awconfig.AppWrapperConfig `json:"appwrapper,omitempty"`
36+
AppWrapper *AppWrapperConfiguration `json:"appwrapper,omitempty"`
37+
}
38+
39+
type AppWrapperConfiguration struct {
40+
// Enabled controls whether or not the AppWrapper Controller is enababled
41+
Enabled *bool `json:"appWrapperControllerEnabled"`
42+
// AppWrapper contains the AppWrapper controller configuration
43+
Config *awconfig.AppWrapperConfig `json:"appwrapper,omitempty"`
3744
}
3845

3946
type KubeRayConfiguration struct {

0 commit comments

Comments
 (0)