Skip to content

Commit

Permalink
fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
yanirq committed Feb 10, 2022
1 parent 86248b9 commit a93d87b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifests/40-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ rules:
- apiGroups: ["machineconfiguration.openshift.io"]
resources: ["machineconfigpools"]
verbs: ["get","list","watch"]
# Needed by new leases mechanism.
# Needed by the leases mechanism.
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["create","get","update","patch"]
Expand Down
16 changes: 9 additions & 7 deletions pkg/util/leaderelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ func GetLeaderElectionConfig(restcfg *rest.Config, enabled bool) configv1.Leader
"", "",
)

if enabled {
if infra, err := clusterstatus.GetClusterInfraStatus(context.TODO(), restcfg); err == nil && infra != nil {
if infra.ControlPlaneTopology == configv1.SingleReplicaTopologyMode {
return leaderelection.LeaderElectionSNOConfig(defaultLeaderElection)
}
} else {
klog.Warningf("unable to get cluster infrastructure status, using HA cluster values for leader election: %v", err)
if !enabled {
return defaultLeaderElection
}

if infra, err := clusterstatus.GetClusterInfraStatus(context.TODO(), restcfg); err == nil && infra != nil {
if infra.ControlPlaneTopology == configv1.SingleReplicaTopologyMode {
return leaderelection.LeaderElectionSNOConfig(defaultLeaderElection)
}
} else {
klog.Warningf("unable to get cluster infrastructure status, using HA cluster values for leader election: %v", err)
}

return defaultLeaderElection
Expand Down

0 comments on commit a93d87b

Please sign in to comment.