Skip to content

Commit 2d526b2

Browse files
committed
Enable custom election id for status sync.
1 parent 85369f8 commit 2d526b2

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

core/pkg/ingress/controller/controller.go

+2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ type Configuration struct {
134134
Backend ingress.Controller
135135

136136
UpdateStatus bool
137+
ElectionID string
137138
}
138139

139140
// newIngressController creates an Ingress controller
@@ -303,6 +304,7 @@ func newIngressController(config *Configuration) *GenericController {
303304
Client: config.Client,
304305
PublishService: ic.cfg.PublishService,
305306
IngressLister: ic.ingLister,
307+
ElectionID: config.ElectionID,
306308
})
307309
} else {
308310
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")

core/pkg/ingress/controller/launch.go

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ func NewIngressController(backend ingress.Controller) *GenericController {
8282

8383
updateStatus = flags.Bool("update-status", true, `Indicates if the
8484
ingress controller should update the Ingress status IP/hostname. Default is true`)
85+
86+
electionID = flags.String("election-id", "ingress-controller-leader", `Election id to use for status update.`)
8587
)
8688

8789
backend.OverrideFlags(flags)
@@ -137,6 +139,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
137139

138140
config := &Configuration{
139141
UpdateStatus: *updateStatus,
142+
ElectionID: *electionID,
140143
Client: kubeClient,
141144
ResyncPeriod: *resyncPeriod,
142145
DefaultService: *defaultSvc,

core/pkg/ingress/status/status.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Config struct {
5252
Client clientset.Interface
5353
PublishService string
5454
IngressLister cache_store.StoreToIngressLister
55+
ElectionID string
5556
}
5657

5758
// statusSync keeps the status IP in each Ingress rule updated executing a periodic check
@@ -171,7 +172,7 @@ func NewStatusSyncer(config Config) Sync {
171172
}
172173
st.syncQueue = task.NewCustomTaskQueue(st.sync, st.keyfunc)
173174

174-
le, err := NewElection("ingress-controller-leader",
175+
le, err := NewElection(config.ElectionID,
175176
pod.Name, pod.Namespace, 30*time.Second,
176177
st.callback, config.Client)
177178
if err != nil {

0 commit comments

Comments
 (0)