Skip to content

Commit

Permalink
Setting LeaderElectionReleaseOnCancel to the Manager in scaffolded ma…
Browse files Browse the repository at this point in the history
…in.go
  • Loading branch information
NikhilSharmaWe committed Apr 4, 2022
1 parent b23e467 commit 915c186
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
3 changes: 3 additions & 0 deletions pkg/plugins/golang/v3/scaffolds/internal/templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,16 @@ func main() {
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
{{ if not .ComponentConfig }}
// Setting LeaderElectionReleaseOnCancel to true prevents main.go
// scripts to close when Manager is done and improves the performance of re-election.
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}",
LeaderElectionReleaseOnCancel: true,
})
{{- else }}
var err error
Expand Down
15 changes: 9 additions & 6 deletions testdata/project-v3-addon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

// Setting LeaderElectionReleaseOnCancel to true prevents main.go
// scripts to close when Manager is done and improves the performance of re-election.
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "52ea9610.testproject.org",
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "52ea9610.testproject.org",
LeaderElectionReleaseOnCancel: true,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
15 changes: 9 additions & 6 deletions testdata/project-v3-multigroup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

// Setting LeaderElectionReleaseOnCancel to true prevents main.go
// scripts to close when Manager is done and improves the performance of re-election.
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "14be1926.testproject.org",
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "14be1926.testproject.org",
LeaderElectionReleaseOnCancel: true,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
15 changes: 9 additions & 6 deletions testdata/project-v3-v1beta1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

// Setting LeaderElectionReleaseOnCancel to true prevents main.go
// scripts to close when Manager is done and improves the performance of re-election.
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "2eab85d8.testproject.org",
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "2eab85d8.testproject.org",
LeaderElectionReleaseOnCancel: true,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
15 changes: 9 additions & 6 deletions testdata/project-v3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

// Setting LeaderElectionReleaseOnCancel to true prevents main.go
// scripts to close when Manager is done and improves the performance of re-election.
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "dd1da13f.testproject.org",
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "dd1da13f.testproject.org",
LeaderElectionReleaseOnCancel: true,
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down

0 comments on commit 915c186

Please sign in to comment.