Skip to content

Commit b39f827

Browse files
committed
Leader election lease tunables
Expose the leader election tunables for lease duration, renew deadline and retry period via environment variables. This is inspired by rabbitmq operator exposes the same. Jira: OSPRH-16335 Depends-On: openstack-k8s-operators/lib-common#627
1 parent 6e687de commit b39f827

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,5 @@ replace github.com/openshift/api => github.com/openshift/api v0.0.0-202408300231
9595

9696
// custom RabbitmqClusterSpecCore for OpenStackControlplane (v2.6.0_patches_tag)
9797
replace github.com/rabbitmq/cluster-operator/v2 => github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 //allow-merging
98+
99+
replace github.com/openstack-k8s-operators/lib-common/modules/common => github.com/hjensas/lib-common/modules/common v0.0.0-20250502185338-0f7f4138f43f

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
4949
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5050
github.com/gophercloud/gophercloud v1.14.1 h1:DTCNaTVGl8/cFu58O1JwWgis9gtISAFONqpMKNg/Vpw=
5151
github.com/gophercloud/gophercloud v1.14.1/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM=
52+
github.com/hjensas/lib-common/modules/common v0.0.0-20250502185338-0f7f4138f43f h1:X7Ez3hC056nMepO/4zqEwiSvY783tx0D6PYQYqlnFkw=
53+
github.com/hjensas/lib-common/modules/common v0.0.0-20250502185338-0f7f4138f43f/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
5254
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
5355
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
5456
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
@@ -82,8 +84,6 @@ github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-8
8284
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-825e3d94da81/go.mod h1:+l+sclC6YCRcLcvS3UEGKBf8xya8aExMrmHeA9tMg+k=
8385
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8 h1:goExj6wO3m63qMWsavIR+IbnmkJ/H/kN5ypLDAfys+c=
8486
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8/go.mod h1:XbNobjVL9/ZRniHFpC8aqZUI//PM/Y9dvnoXTJ8RmPM=
85-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250419062702-0acec6a591c8 h1:lu9TcW75zo1dMyEIa7adDwzSIBBVpFwrPU9hx6n531c=
86-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250419062702-0acec6a591c8/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
8787
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250419062702-0acec6a591c8 h1:40OvFG7lXPdnzy5eOLvOp6pX2sM51M5jhvWbNSmnvew=
8888
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20250419062702-0acec6a591c8/go.mod h1:fesgTbs2j30Fhw2hebXkPgbeAIqG0Yk2oaeOklAInZg=
8989
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20250419062702-0acec6a591c8 h1:oLY6iMNPe3/L5S8EvNcjvfWd1tbCNgfQ+iSnv3UCB0U=

main.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"crypto/tls"
2222
"flag"
23+
"fmt"
2324
"os"
2425
"strings"
2526

@@ -47,6 +48,8 @@ import (
4748
"github.com/openstack-k8s-operators/ironic-operator/controllers"
4849
keystonev1beta1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
4950
mariadbv1beta1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
51+
52+
"github.com/openstack-k8s-operators/lib-common/modules/common/operator"
5053
//+kubebuilder:scaffold:imports
5154
)
5255

@@ -97,7 +100,7 @@ func main() {
97100
c.NextProtos = []string{"http/1.1"}
98101
}
99102

100-
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
103+
options := ctrl.Options{
101104
Scheme: scheme,
102105
Metrics: metricsserver.Options{
103106
BindAddress: metricsAddr,
@@ -110,7 +113,15 @@ func main() {
110113
Port: 9443,
111114
TLSOpts: []func(config *tls.Config){disableHTTP2},
112115
}),
113-
})
116+
}
117+
118+
err := operator.SetManagerOptions(&options, setupLog)
119+
if err != nil {
120+
setupLog.Error(err, fmt.Sprintf("unable to set controller options"))
121+
os.Exit(1)
122+
}
123+
124+
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options)
114125
if err != nil {
115126
setupLog.Error(err, "unable to start manager")
116127
os.Exit(1)

0 commit comments

Comments
 (0)