From aadd837450da2ebccefb3d607feeeaaf390140d6 Mon Sep 17 00:00:00 2001 From: Scott Hebert Date: Tue, 26 Mar 2024 11:54:57 -0400 Subject: [PATCH] feat(KFLUXBUGS-1162): support override of election leaderId (#54) - allows us to have multiple controllers pointing to different Konflux instances. - update test command Signed-off-by: Scott Hebert --- Makefile | 2 +- main.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ccc958e..5bd2db2 100644 --- a/Makefile +++ b/Makefile @@ -202,7 +202,7 @@ $(CONTROLLER_GEN): $(LOCALBIN) .PHONY: envtest envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) - test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240317073005-bd9ea79e8d18 .PHONY: bundle bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files. diff --git a/main.go b/main.go index b677f61..11e9643 100644 --- a/main.go +++ b/main.go @@ -63,6 +63,7 @@ func init() { func main() { var metricsAddr string var enableLeaderElection bool + var enableLeaderElectionId string var probeAddr string var remoteClusterConfigFile string flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") @@ -70,6 +71,9 @@ func main() { flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") + flag.StringVar(&enableLeaderElectionId, "leader-election-id", + "b548bb9d.redhat.com", + "Enable overriding leader election ID for controller manager. ") flag.StringVar(&remoteClusterConfigFile, "remote-cluster-config-file", "", "The remote client will load its initial configuration from this file. "+ "Omit this flag to use the default configuration values. "+ @@ -89,7 +93,7 @@ func main() { Port: 9443, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, - LeaderElectionID: "b548bb9d.redhat.com", + LeaderElectionID: enableLeaderElectionId, NewCache: cache.BuilderWithOptions(cache.Options{ SelectorsByObject: cache.SelectorsByObject{ &tektonv1beta1.PipelineRun{}: {