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

nilref panic when configuring leader election #1828

Closed
tomasaschan opened this issue Mar 4, 2022 · 0 comments · Fixed by #1889
Closed

nilref panic when configuring leader election #1828

tomasaschan opened this issue Mar 4, 2022 · 0 comments · Fixed by #1889

Comments

@tomasaschan
Copy link
Member

tomasaschan commented Mar 4, 2022

The Kubebuilder Book includes a tutorial on setting up a manager to use a custom config file, e.g. volume-mounted from a config map. As part of this tutorial, it is suggested to run

options := ctrl.Options{Scheme: scheme}
options, err := options.AndFrom(ctrl.ConfigFile().AtPath(configPath).OfKind(&MyCustomConfigType{}))
// ...

where MyCustomConfigType is defined something like this:

import (
    metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    cfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
)

type MyCustomConfigType struct {
    metav1.TypeMeta `json:",inline"`

    cfg.ControllerManagerConfigurationSpec `json:",inline"`
    
    // add custom config props here
}

If the config file does not provide any configuration for leader election (which should be OK, since the element is optional in the config type), you'll get a nilref panic in setLeaderElectionConfig, since obj.LeaderElection == nil.

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