-
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.
feat: toplogy aware leader election config
leader election config will query the cluster for the topology and if we are in an SNO toplogy we use one set of configs otherwise we use conventional defaults for HA cluster config. Signed-off-by: ehila <[email protected]> upkeep: ran go mod tidy/vendor/verify Signed-off-by: ehila <[email protected]> upkeep: spelling fix Signed-off-by: ehila <[email protected]> feat: moved sno logic to utils moved sno logic to use the cluster.go file added check for k8s or openshift environment upkeep re-organize imports Signed-off-by: ehila <[email protected]> feat: added rbac for operator Signed-off-by: ehila <[email protected]> refactor: updated to use client-go leader election updated to use client-go leader election struct instead of openshift/api updated wording to remove SNO acronym Signed-off-by: ehila <[email protected]>
- Loading branch information
Showing
25 changed files
with
318 additions
and
379 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.