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

Ansible/Helm new layouts should work with controller-runtime leader election #3356

Closed
camilamacedo86 opened this issue Jul 8, 2020 · 1 comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. kubebuilder-integration Relates to rewriting the SDK in Kubebuilder plugin form language/ansible Issue is related to an Ansible operator project language/helm Issue is related to a Helm operator project
Milestone

Comments

@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Jul 8, 2020

Feature Request

The new helm layout is working with the current/legacy image of the operator-sdk helm. This image is not using the controller-runtime implementation for the leader election.

We need to:

  • Add the both flags to the run
  • Change the main implementation to use the leader election as it is in the GO type. See:
        
	pflag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
		"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
	pflag.StringVar(&leaderElectionID, "leader-election-id", "",
		"Name of the configmap that is used for holding the leader lock.")
	pflag.StringVar(&leaderElectionNamespace, "leader-election-namespace", "",
		"Namespace in which to create the leader election configmap for holding the leader lock (required if running locally).")  



        // Deprecated: OPERATOR_NAME environment variable is an artifact of the legacy operator-sdk project scaffolding.
	//   Flag `--leader-election-id` should be used instead.
	if operatorName, found := os.LookupEnv("OPERATOR_NAME"); found {
		setupLog.Info("environment variable OPERATOR_NAME has been deprecated, use --leader-election-id instead.")
		if pflag.Lookup("leader-election-id").Changed {
			setupLog.Info("ignoring OPERATOR_NAME environment variable since --leader-election-id is set")
		} else {
			leaderElectionID = operatorName
		}
	}

       options := ctrl.Options{
		MetricsBindAddress:      metricsAddr,
		LeaderElection:          enableLeaderElection,
		LeaderElectionID:        leaderElectionID,
		LeaderElectionNamespace: leaderElectionNamespace,
		NewClient:               manager.NewDelegatingClientFunc(),
	}
@camilamacedo86 camilamacedo86 added language/ansible Issue is related to an Ansible operator project language/helm Issue is related to a Helm operator project kind/feature Categorizes issue or PR as related to a new feature. kubebuilder-integration Relates to rewriting the SDK in Kubebuilder plugin form labels Jul 8, 2020
@camilamacedo86 camilamacedo86 added this to the v1.0.0 milestone Jul 8, 2020
@estroz
Copy link
Member

estroz commented Jul 24, 2020

Closed by #3446 and #3457

@estroz estroz closed this as completed Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. kubebuilder-integration Relates to rewriting the SDK in Kubebuilder plugin form language/ansible Issue is related to an Ansible operator project language/helm Issue is related to a Helm operator project
Projects
None yet
Development

No branches or pull requests

2 participants