Skip to content

Commit 2d4ebaa

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 2d4ebaa

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/onsi/ginkgo/v2 v2.20.1
77
github.com/onsi/gomega v1.34.1
88
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-825e3d94da81
9-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250419062702-0acec6a591c8
9+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35
1010
k8s.io/api v0.29.15
1111
k8s.io/apimachinery v0.29.15
1212
k8s.io/client-go v0.29.15

api/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6
7676
github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4=
7777
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-825e3d94da81 h1:TVvg7J2z4uQWR9ahxAkxT+RR6cSVZ9T667I8s+Afq1U=
7878
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-825e3d94da81/go.mod h1:+l+sclC6YCRcLcvS3UEGKBf8xya8aExMrmHeA9tMg+k=
79-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250419062702-0acec6a591c8 h1:lu9TcW75zo1dMyEIa7adDwzSIBBVpFwrPU9hx6n531c=
80-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250419062702-0acec6a591c8/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
79+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35 h1:dczrtvVjeDXUR3OhnUQRhVVnN14KX52qp0KXCulo8pA=
80+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35/go.mod h1:UwHXRIrMSPJD3lFqrA4oKmRXVLFQCRkLAj9x6KLEHiQ=
8181
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
8282
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
8383
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-825e3d94da81
1212
github.com/openstack-k8s-operators/ironic-operator/api v0.0.0-00010101000000-000000000000
1313
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8
14-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250419062702-0acec6a591c8
14+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35
1515
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20250419062702-0acec6a591c8
1616
github.com/openstack-k8s-operators/mariadb-operator/api v0.6.1-0.20250415060817-dc849adfa27e
1717
k8s.io/api v0.29.15

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-8
8282
github.com/openstack-k8s-operators/infra-operator/apis v0.6.1-0.20250422055748-825e3d94da81/go.mod h1:+l+sclC6YCRcLcvS3UEGKBf8xya8aExMrmHeA9tMg+k=
8383
github.com/openstack-k8s-operators/keystone-operator/api v0.6.1-0.20250420193521-f2b86a82d7e8 h1:goExj6wO3m63qMWsavIR+IbnmkJ/H/kN5ypLDAfys+c=
8484
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=
85+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35 h1:dczrtvVjeDXUR3OhnUQRhVVnN14KX52qp0KXCulo8pA=
86+
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20250505061650-7cb2f323fb35/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)