Skip to content

Commit

Permalink
fix: ensure unique controller names to fix name conflicts in multigro…
Browse files Browse the repository at this point in the history
…up setup
  • Loading branch information
camilamacedo86 committed Sep 12, 2024
1 parent d26664f commit b7f6f68
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,5 +574,6 @@ func (r *CronJobReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&batchv1.CronJob{}).
Owns(&kbatch.Job{}).
Named("cronjob-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func (r *MemcachedReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&cachev1alpha1.Memcached{}).
Owns(&appsv1.Deployment{}).
Named("memcached-controller").
Complete(r)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,5 +574,6 @@ func (r *CronJobReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&batchv1.CronJob{}).
Owns(&kbatch.Job{}).
Named("cronjob-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ func (r *{{ .Resource.Kind }}Reconciler) SetupWithManager(mgr ctrl.Manager) erro
// Uncomment the following line adding a pointer to an instance of the controlled resource as an argument
// For().
{{- end }}
{{- if and (.MultiGroup) (not (isEmptyStr .Resource.Group)) }}
Named("{{ lower .Resource.Group }}-{{ lower .Resource.Kind }}-controller").
{{- else }}
Named("{{ lower .Resource.Kind }}-controller").
{{- end }}
// Watch the Deployment managed by the {{ .Resource.Kind }}Reconciler. If any changes occur to the Deployment
// owned and managed by this controller, it will trigger reconciliation, ensuring that the cluster
// state aligns with the desired state. See that the ownerRef was set when the Deployment was created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func (r *{{ .Resource.Kind }}Reconciler) SetupWithManager(mgr ctrl.Manager) erro
// Uncomment the following line adding a pointer to an instance of the controlled resource as an argument
// For().
{{- end }}
{{- if and (.MultiGroup) (not (isEmptyStr .Resource.Group)) }}
Named("{{ lower .Resource.Group }}-{{ lower .Resource.Kind }}-controller").
{{- else }}
Named("{{ lower .Resource.Kind }}-controller").
{{- end }}
Complete(r)
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ func (r *DeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Request)
func (r *DeploymentReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&appsv1.Deployment{}).
Named("apps-deployment-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *CaptainReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&crewv1.Captain{}).
Named("crew-captain-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ func (r *BusyboxReconciler) SetupWithManager(mgr ctrl.Manager) error {
// Watch the Busybox CR(s) and trigger reconciliation whenever it
// is created, updated, or deleted
For(&examplecomv1alpha1.Busybox{}).
Named("example.com-busybox-controller").
// Watch the Deployment managed by the BusyboxReconciler. If any changes occur to the Deployment
// owned and managed by this controller, it will trigger reconciliation, ensuring that the cluster
// state aligns with the desired state. See that the ownerRef was set when the Deployment was created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ func (r *MemcachedReconciler) SetupWithManager(mgr ctrl.Manager) error {
// Watch the Memcached CR(s) and trigger reconciliation whenever it
// is created, updated, or deleted
For(&examplecomv1alpha1.Memcached{}).
Named("example.com-memcached-controller").
// Watch the Deployment managed by the MemcachedReconciler. If any changes occur to the Deployment
// owned and managed by this controller, it will trigger reconciliation, ensuring that the cluster
// state aligns with the desired state. See that the ownerRef was set when the Deployment was created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *BarReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
func (r *BarReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&fizv1.Bar{}).
Named("fiz-bar-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *HealthCheckPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Re
func (r *HealthCheckPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&foopolicyv1.HealthCheckPolicy{}).
Named("foo.policy-healthcheckpolicy-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *BarReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
func (r *BarReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&foov1.Bar{}).
Named("foo-bar-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *KrakenReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
func (r *KrakenReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&seacreaturesv1beta1.Kraken{}).
Named("sea-creatures-kraken-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *LeviathanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
func (r *LeviathanReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&seacreaturesv1beta2.Leviathan{}).
Named("sea-creatures-leviathan-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *CruiserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
func (r *CruiserReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&shipv2alpha1.Cruiser{}).
Named("ship-cruiser-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *DestroyerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
func (r *DestroyerReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&shipv1.Destroyer{}).
Named("ship-destroyer-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *FrigateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
func (r *FrigateReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&shipv1beta1.Frigate{}).
Named("ship-frigate-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ func (r *BusyboxReconciler) SetupWithManager(mgr ctrl.Manager) error {
// Watch the Busybox CR(s) and trigger reconciliation whenever it
// is created, updated, or deleted
For(&examplecomv1alpha1.Busybox{}).
Named("busybox-controller").
// Watch the Deployment managed by the BusyboxReconciler. If any changes occur to the Deployment
// owned and managed by this controller, it will trigger reconciliation, ensuring that the cluster
// state aligns with the desired state. See that the ownerRef was set when the Deployment was created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ func (r *MemcachedReconciler) SetupWithManager(mgr ctrl.Manager) error {
// Watch the Memcached CR(s) and trigger reconciliation whenever it
// is created, updated, or deleted
For(&examplecomv1alpha1.Memcached{}).
Named("memcached-controller").
// Watch the Deployment managed by the MemcachedReconciler. If any changes occur to the Deployment
// owned and managed by this controller, it will trigger reconciliation, ensuring that the cluster
// state aligns with the desired state. See that the ownerRef was set when the Deployment was created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *AdmiralReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&crewv1.Admiral{}).
Named("admiral-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *CaptainReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&crewv1.Captain{}).
Named("captain-controller").
Complete(r)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ func (r *FirstMateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&crewv1.FirstMate{}).
Named("firstmate-controller").
Complete(r)
}

0 comments on commit b7f6f68

Please sign in to comment.