Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yaksharma opened this issue Jul 30, 2021 · 0 comments

Comments

@yaksharma
Copy link
Contributor

yaksharma commented Jul 30, 2021

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"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant