diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/controller_manager_config.go b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/controller_manager_config.go index fa977d90ecb..c0eed72cc33 100644 --- a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/controller_manager_config.go +++ b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/controller_manager_config.go @@ -55,4 +55,14 @@ webhook: leaderElection: leaderElect: true resourceName: {{ hashFNV .Repo }}.{{ .Domain }} +# leaderElectionReleaseOnCancel defines if the leader should step down volume +# when the Manager ends. This requires the binary to immediately end when the +# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly +# speeds up voluntary leader transitions as the new leader don't have to wait +# LeaseDuration time first. +# In the default scaffold provided, the program ends immediately after +# the manager stops, so would be fine to enable this option. However, +# if you are doing or is intended to do any operation such as perform cleanups +# after the manager stops then its usage might be unsafe. +# leaderElectionReleaseOnCancel: true ` diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go index 34d80b4f098..e450584fbba 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/main.go @@ -245,6 +245,17 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, }) {{- else }} var err error diff --git a/testdata/project-v3-addon/config/manager/controller_manager_config.yaml b/testdata/project-v3-addon/config/manager/controller_manager_config.yaml index 4dea2227086..5e029850a21 100644 --- a/testdata/project-v3-addon/config/manager/controller_manager_config.yaml +++ b/testdata/project-v3-addon/config/manager/controller_manager_config.yaml @@ -9,3 +9,13 @@ webhook: leaderElection: leaderElect: true resourceName: 52ea9610.testproject.org +# leaderElectionReleaseOnCancel defines if the leader should step down volume +# when the Manager ends. This requires the binary to immediately end when the +# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly +# speeds up voluntary leader transitions as the new leader don't have to wait +# LeaseDuration time first. +# In the default scaffold provided, the program ends immediately after +# the manager stops, so would be fine to enable this option. However, +# if you are doing or is intended to do any operation such as perform cleanups +# after the manager stops then its usage might be unsafe. +# leaderElectionReleaseOnCancel: true diff --git a/testdata/project-v3-addon/main.go b/testdata/project-v3-addon/main.go index dc898dab8f1..63a310f7e25 100644 --- a/testdata/project-v3-addon/main.go +++ b/testdata/project-v3-addon/main.go @@ -72,6 +72,17 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "52ea9610.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, }) if err != nil { setupLog.Error(err, "unable to start manager") diff --git a/testdata/project-v3-config/config/manager/controller_manager_config.yaml b/testdata/project-v3-config/config/manager/controller_manager_config.yaml index ca63e8ee4ab..7d6222f9398 100644 --- a/testdata/project-v3-config/config/manager/controller_manager_config.yaml +++ b/testdata/project-v3-config/config/manager/controller_manager_config.yaml @@ -9,3 +9,13 @@ webhook: leaderElection: leaderElect: true resourceName: 6858fb70.testproject.org +# leaderElectionReleaseOnCancel defines if the leader should step down volume +# when the Manager ends. This requires the binary to immediately end when the +# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly +# speeds up voluntary leader transitions as the new leader don't have to wait +# LeaseDuration time first. +# In the default scaffold provided, the program ends immediately after +# the manager stops, so would be fine to enable this option. However, +# if you are doing or is intended to do any operation such as perform cleanups +# after the manager stops then its usage might be unsafe. +# leaderElectionReleaseOnCancel: true diff --git a/testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml b/testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml index 85ba6785e4f..933cb932708 100644 --- a/testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml +++ b/testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml @@ -9,3 +9,13 @@ webhook: leaderElection: leaderElect: true resourceName: 14be1926.testproject.org +# leaderElectionReleaseOnCancel defines if the leader should step down volume +# when the Manager ends. This requires the binary to immediately end when the +# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly +# speeds up voluntary leader transitions as the new leader don't have to wait +# LeaseDuration time first. +# In the default scaffold provided, the program ends immediately after +# the manager stops, so would be fine to enable this option. However, +# if you are doing or is intended to do any operation such as perform cleanups +# after the manager stops then its usage might be unsafe. +# leaderElectionReleaseOnCancel: true diff --git a/testdata/project-v3-multigroup/main.go b/testdata/project-v3-multigroup/main.go index aa566237105..55e34cb64f2 100644 --- a/testdata/project-v3-multigroup/main.go +++ b/testdata/project-v3-multigroup/main.go @@ -97,6 +97,17 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "14be1926.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, }) if err != nil { setupLog.Error(err, "unable to start manager") diff --git a/testdata/project-v3-v1beta1/config/manager/controller_manager_config.yaml b/testdata/project-v3-v1beta1/config/manager/controller_manager_config.yaml index d90e0e0c3f6..77d68fa1ad5 100644 --- a/testdata/project-v3-v1beta1/config/manager/controller_manager_config.yaml +++ b/testdata/project-v3-v1beta1/config/manager/controller_manager_config.yaml @@ -9,3 +9,13 @@ webhook: leaderElection: leaderElect: true resourceName: 2eab85d8.testproject.org +# leaderElectionReleaseOnCancel defines if the leader should step down volume +# when the Manager ends. This requires the binary to immediately end when the +# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly +# speeds up voluntary leader transitions as the new leader don't have to wait +# LeaseDuration time first. +# In the default scaffold provided, the program ends immediately after +# the manager stops, so would be fine to enable this option. However, +# if you are doing or is intended to do any operation such as perform cleanups +# after the manager stops then its usage might be unsafe. +# leaderElectionReleaseOnCancel: true diff --git a/testdata/project-v3-v1beta1/main.go b/testdata/project-v3-v1beta1/main.go index 44ed897a511..5024e123b1b 100644 --- a/testdata/project-v3-v1beta1/main.go +++ b/testdata/project-v3-v1beta1/main.go @@ -72,6 +72,17 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "2eab85d8.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, }) if err != nil { setupLog.Error(err, "unable to start manager") diff --git a/testdata/project-v3/config/manager/controller_manager_config.yaml b/testdata/project-v3/config/manager/controller_manager_config.yaml index 989bcc9b3bd..9638df66df8 100644 --- a/testdata/project-v3/config/manager/controller_manager_config.yaml +++ b/testdata/project-v3/config/manager/controller_manager_config.yaml @@ -9,3 +9,13 @@ webhook: leaderElection: leaderElect: true resourceName: dd1da13f.testproject.org +# leaderElectionReleaseOnCancel defines if the leader should step down volume +# when the Manager ends. This requires the binary to immediately end when the +# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly +# speeds up voluntary leader transitions as the new leader don't have to wait +# LeaseDuration time first. +# In the default scaffold provided, the program ends immediately after +# the manager stops, so would be fine to enable this option. However, +# if you are doing or is intended to do any operation such as perform cleanups +# after the manager stops then its usage might be unsafe. +# leaderElectionReleaseOnCancel: true diff --git a/testdata/project-v3/main.go b/testdata/project-v3/main.go index c8f85f0b275..81da09f3887 100644 --- a/testdata/project-v3/main.go +++ b/testdata/project-v3/main.go @@ -72,6 +72,17 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "dd1da13f.testproject.org", + // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily + // when the Manager ends. This requires the binary to immediately end when the + // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly + // speeds up voluntary leader transitions as the new leader don't have to wait + // LeaseDuration time first. + // + // In the default scaffold provided, the program ends immediately after + // the manager stops, so would be fine to enable this option. However, + // if you are doing or is intended to do any operation such as perform cleanups + // after the manager stops then its usage might be unsafe. + // LeaderElectionReleaseOnCancel: true, }) if err != nil { setupLog.Error(err, "unable to start manager")