Controller-runtime: "duplicate metrics collector registration attempted" spam at startup

Created on 11 Jun 2019  路  2Comments  路  Source: kubernetes-sigs/controller-runtime

When I start my manager, I get a lot of lines like this:

E0611 12:55:04.516997  251465 client_go_adapter.go:339] duplicate metrics collector registration attempted

I'm guessing this is because I'm registering several controllers for the same type and each one is trying to use the same metric name.

Most helpful comment

Just in case anyone else stumbles upon this Issue and needs a little more context - I was able to fix this using .Named() when calling SetupWithManager(). For example:

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
    return ctrl.NewControllerManagedBy(mgr).
        For(&mycontrollerv1alpha2.Environment{}).
        Named("storage").
        Complete(r)
}

All 2 comments

I'd recommend using the .Name() method on builder if you have multiple controllers for the same type to given them different names. If you still have issues after that, poke this issue and I'll reopen it.

Just in case anyone else stumbles upon this Issue and needs a little more context - I was able to fix this using .Named() when calling SetupWithManager(). For example:

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
    return ctrl.NewControllerManagedBy(mgr).
        For(&mycontrollerv1alpha2.Environment{}).
        Named("storage").
        Complete(r)
}
Was this page helpful?
0 / 5 - 0 ratings