Skip to content

Commit

Permalink
Merge pull request #4162 from camilamacedo86/fix-multigroup
Browse files Browse the repository at this point in the history
🐛 fix: ensure unique controller names to fix name conflicts in multigroup setup
  • Loading branch information
k8s-ci-robot authored Sep 13, 2024
2 parents ff8d772 + 79a06e5 commit 29a22d1
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").
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").
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").
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 }}").
{{- else }}
Named("{{ lower .Resource.Kind }}").
{{- 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 }}").
{{- else }}
Named("{{ lower .Resource.Kind }}").
{{- 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").
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").
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").
// 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").
// 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").
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").
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").
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").
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").
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").
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").
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").
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").
// 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").
// 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").
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").
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").
Complete(r)
}

0 comments on commit 29a22d1

Please sign in to comment.