Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Calling reconciler.SetupWithManager with .For() multiple times loses previous apiTypes with controller-runtime < 0.7.0 or raises error with newer controller-runtime #13

@yaksharma

Description

@yaksharma

Expected Behaviour

Kratos controller-runtime consumer should watch both scalingv1alpha1.Kratos and corev1.ConfigMap resources for kratos spec.

Actual Behaviour

Kratos controller-runtime consumer calls [.For(scalingv1alpha1.Kratos).For(corev1.ConfigMap](https://github.com/adobe/kratos/blob/master/controllers/kratos_controller.go#L89-L90)), then scalingv1alpha1.Kratos is silently lost in favour of ConfigMap. with controller-runtime < 0.7.0 or raises an error for newer versions.

Reproduce Scenario (including but not limited to)

  • Please see (#1173)
  • An error is added for this behavior with (#1176)
  • As a workaround, to watch multiple apiTypes consumer can use .Watches() or . Owns() instead, alternatively limit the use of For to one apiType.

Steps to Reproduce

  • Run Kratos operator against latest kind cluster

Platform and Version

  • controller-runtime v0.9.2
  • kind version 0.11.1

Sample Code that illustrates the problem

https://github.com/adobe/kratos/blob/master/controllers/kratos_controller.go#L89-L90

func (r *KratosReconciler) SetupWithManager(mgr ctrl.Manager) error {
	return ctrl.NewControllerManagedBy(mgr).
		For(&scalingv1alpha1.Kratos{}).
		For(&corev1.ConfigMap{}).
		Complete(r)
}

Logs taken while reproducing problem

ERROR setup unable to setup controller with manager {"controller": "Kratos", "error": "For(...) should only be called once, could not assign multiple objects for reconciliation"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions