Use full election leader ID

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-03-11 12:57:28 -03:00
parent 7c717cabcf
commit 20a89480f0
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
2 changed files with 12 additions and 14 deletions

View file

@ -18,7 +18,6 @@ package controller
import (
"context"
"fmt"
"os"
"time"
@ -31,8 +30,6 @@ import (
"k8s.io/client-go/tools/leaderelection"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/client-go/tools/record"
"k8s.io/ingress-nginx/internal/ingress/annotations/class"
)
type leaderElectionConfig struct {
@ -48,13 +45,6 @@ type leaderElectionConfig struct {
}
func setupLeaderElection(config *leaderElectionConfig) {
// we need to use the defined ingress class to allow multiple leaders
// in order to update information about ingress status
electionID := fmt.Sprintf("%v-%v", config.ElectionID, class.DefaultClass)
if class.IngressClass != "" {
electionID = fmt.Sprintf("%v-%v", config.ElectionID, class.IngressClass)
}
var elector *leaderelection.LeaderElector
// start a new context
@ -106,7 +96,7 @@ func setupLeaderElection(config *leaderElectionConfig) {
})
lock := resourcelock.ConfigMapLock{
ConfigMapMeta: metav1.ObjectMeta{Namespace: config.PodNamespace, Name: electionID},
ConfigMapMeta: metav1.ObjectMeta{Namespace: config.PodNamespace, Name: config.ElectionID},
Client: config.Client.CoreV1(),
LockConfig: resourcelock.ResourceLockConfig{
Identity: config.PodName,