-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from eggfoobar/sno_leader_election_config
HA/SNO leader election config
- Loading branch information
Showing
84 changed files
with
4,558 additions
and
2,011 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package leaderelection | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/golang/glog" | ||
"k8s.io/client-go/tools/leaderelection" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" | ||
) | ||
|
||
const ( | ||
// Defaults follow conventions | ||
// https://github.com/openshift/enhancements/blob/master/CONVENTIONS.md#high-availability | ||
// Impl Calculations: https://github.com/openshift/library-go/commit/7e7d216ed91c3119800219c9194e5e57113d059a | ||
defaultLeaseDuration = 137 * time.Second | ||
defaultRenewDeadline = 107 * time.Second | ||
defaultRetryPeriod = 26 * time.Second | ||
) | ||
|
||
func GetLeaderElectionConfig(c client.Client, enabled bool) (defaultConfig leaderelection.LeaderElectionConfig) { | ||
defaultConfig = leaderelection.LeaderElectionConfig{ | ||
LeaseDuration: defaultLeaseDuration, | ||
RenewDeadline: defaultRenewDeadline, | ||
RetryPeriod: defaultRetryPeriod, | ||
} | ||
|
||
if enabled { | ||
isSingleNode, err := utils.IsSingleNodeCluster(c) | ||
if err != nil { | ||
glog.Warningf("unable to get cluster infrastructure status, using HA cluster values for leader election: %v", err) | ||
return | ||
} | ||
if isSingleNode { | ||
return leaderElectionSingleNodeConfig(defaultConfig) | ||
} | ||
} | ||
return | ||
} | ||
|
||
// Default leader election for Single Node environments | ||
// Impl Calculations: | ||
// https://github.com/openshift/library-go/commit/2612981f3019479805ac8448b997266fc07a236a#diff-61dd95c7fd45fa18038e825205fbfab8a803f1970068157608b6b1e9e6c27248R127 | ||
func leaderElectionSingleNodeConfig(config leaderelection.LeaderElectionConfig) leaderelection.LeaderElectionConfig { | ||
config.LeaseDuration = 270 * time.Second | ||
config.RenewDeadline = 240 * time.Second | ||
config.RetryPeriod = 60 * time.Second | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
....com/openshift/api/config/v1/0000_00_cluster-version-operator_01_clusteroperator.crd.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 4 additions & 1 deletion
5
...b.com/openshift/api/config/v1/0000_00_cluster-version-operator_01_clusterversion.crd.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
vendor/github.com/openshift/api/config/v1/0000_03_config-operator_01_operatorhub.crd.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.