New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend ResourceLock interface to include leader election config #77204
Extend ResourceLock interface to include leader election config #77204
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: vikaschoudhary16 If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
c2a9d37
to
ebd8471
Compare
ebd8471
to
764b484
Compare
/cc @cheftako |
@@ -85,6 +95,9 @@ type Interface interface { | |||
// Identity will return the locks Identity | |||
Identity() string | |||
|
|||
// LeaderElectionConfig will return leader election's lease duration, lease renew and retry configurations | |||
LeaderElectionConfig() (*int, *int, *int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odd to hide implementation behind an interface and then intentionally leaking this information. Who is a consumer of this? Isn't the consumer also the same who creates the object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can those values be nil?
@@ -89,6 +89,11 @@ func (ll *LeaseLock) Identity() string { | |||
return ll.LockConfig.Identity | |||
} | |||
|
|||
// returns the leader election config of the lock | |||
func (ll *LeaseLock) LeaderElectionConfig() (*int, *int, *int) { | |||
return &ll.LockConfig.LeaseDurationSeconds, &ll.LockConfig.RenewDeadlineSeconds, &ll.LockConfig.RetryPeriodSeconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, now I get this. I don't like it at all to open up internals like that. Who locks those values?
If we want a way to change those values, add a setter method.
/hold The approach does not look right. Leaking pointers to unprotected internal state is dangerous. |
@sttts Thanks for the comments.
Yeah, looks like it can handle entirely in consumer (i.e controller-runtime), without requiring changes in this part, so closing it. |
What type of PR is this?
What this PR does / why we need it:
This PR is required for making leader election configuration for Lease duration, renew duration and retry duration to be configurable options. Currently these are hard-coded.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Related PR# kubernetes-sigs/controller-runtime#412
Does this PR introduce a user-facing change?: