-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
move apiserver Configuration to k8s.io/apiserver/pkg/apis/config #66059
Conversation
d22fc3a
to
49de79e
Compare
/retest |
/hold |
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.
Thanks for this PR!
@rosti FYI
Please add OWNERS file as in the KEP. Fix verify. Add comment to DebuggingConfiguration. Lowercase the EnableContentionProfiling comment. Maybe add validation now or in a later PR. Move/duplicate the "endpoints" string to this package.
Feel free to add these packages that need it to .golint_failures btw |
@kubernetes/sig-api-machinery-pr-reviews |
// leaderElect enables a leader election client to gain leadership | ||
// before executing the main loop. Enable this when running replicated | ||
// components for high availability. | ||
LeaderElect *bool `json:"leaderElect"` |
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.
IMO, we should add probuf
for all var
, syncing with others api struct
, so that prase easy . such as https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/apis/example/v1/types.go#L60. Even that may be unnecessary now. @luxas @sttts WDYT
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.
do we support protobuf for configs? Do we want to?
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.
Actually, no need for now, Json
enough.
5b7f20b
to
aabee11
Compare
|
||
// +k8s:deepcopy-gen=package | ||
// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/config | ||
// +k8s:openapi-gen=true |
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.
do we want this in openapi?
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.
It seems we don't want it, I remove it
) | ||
|
||
var ( | ||
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. |
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.
remove TODO
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.
Done, Thanks for your review
/hold cancel |
@@ -0,0 +1,7 @@ | |||
approvers: |
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.
the OWNERS file from k8s.io/apiserver
would probably be a more appropriate starting point for the reviewers list (and the api approvers owners file for approvals, since config is considered API... see https://docs.google.com/document/d/1OkSQngGem7xaENqaO8jzHLDSSIGh2obPUaJGAFDwTUE/edit#)
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.
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.
+1 for @liggitt's suggestion.
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.
Done
) | ||
|
||
// LeaderElectionConfiguration defines the configuration of leader election | ||
// clients for components that can run with leader election enabled. |
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.
does this belong in apiserver? lots of things that aren't apiservers use leader election. I expected it in apimachinery
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.
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.
We were undecided about this one. It seems to be higher level than apimachinery, but also has no tight connections to apiserver. I don't feel strongly with either direction. As the types are kube independent, we can technically also move it to apimachinery. I would like to see some generic ResourceLock
syntax which does not reference kube.
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.
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.
does this belong in apiserver? lots of things that aren't apiservers use leader election. I expected it in apimachinery
I don't see this as related to our type system in the same way as TypeMeta
, ObjectMeta
, Time
, or List
. I don't even see it as quite as fundamental as ListOptions
. Something common for many bits of config, sure. Something common for all types/schemes, not really.
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.
If I understand correctly, components can migrate to using the Lease API (it was designed to represent the same information as LeaderElectionRecord), but they still have to get related configuration from somewhere (i.e. LeaderElectionConfiguration).
So this is a question of where to put a common config struct type?
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.
is this resolved?
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.
Yes, I think the consensus is to put it here, in k8s.io/apiserver vs putting it in k8s.io/apimachinery which should hold even more generic types.
RetryPeriod metav1.Duration | ||
// resourceLock indicates the resource object type that will be used to lock | ||
// during leader election cycles. | ||
ResourceLock string |
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.
what are the value of this? resource plus apigroup plus version?
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.
The default is string "endpoints": https://github.com/kubernetes/kubernetes/pull/66059/files#diff-315017a8fe6dd5515919e19a0fffcc20R43
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.
There are two lock types endpoints
and configmaps
: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/leaderelection/resourcelock/interface.go
/cc @roycaihw |
/assign @jbeda |
Can we at least create the clean-up PR now already to see possible issues early? Don't like to duplicate code and post-poin the cleanups. /hold |
Can we please get a top-level approval of this to get the ball rolling so we can then cleanup the types (PR #66722) ASAP, and unblock the components' types moving (e.g. #66916). We can always change the structure later if we feel we need to, before going beta with this, but if this is gonna be stuck forever we have no chance improving anything. |
/approve Just to get this moving. |
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.
/lgtm
Thanks @hanxiaoshuai and @jbeda!
Let's get the ball rolling here and follow-up on minor nits and changes as we go.
) | ||
|
||
// LeaderElectionConfiguration defines the configuration of leader election | ||
// clients for components that can run with leader election enabled. |
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.
Yes, I think the consensus is to put it here, in k8s.io/apiserver vs putting it in k8s.io/apimachinery which should hold even more generic types.
|
||
// +k8s:deepcopy-gen=package | ||
// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/config | ||
// +k8s:defaulter-gen=TypeMeta |
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.
As said in the other PR, we're not sure if we actually need this, but we're leaving it as-is for now
obj.ResourceLock = EndpointsResourceLock | ||
} | ||
if obj.LeaderElect == nil { | ||
obj.LeaderElect = &booltrue |
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.
nit: in the future you can use k8s.io/utils/pointer.BoolPtr(true)
kruntime "k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
func addDefaultingFuncs(scheme *kruntime.Scheme) error { |
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.
TODO: we haven't fully decided if we're gonna register the defaults like this in the scheme, but having this as it is the default way of doing things right now. We can always change stuff later.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hanxiaoshuai, jbeda, luxas 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 |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue (batch tested with PRs 66058, 66059). If you want to cherry-pick this change to another branch, please follow the instructions here. |
Automatic merge from submit-queue (batch tested with PRs 67071, 66906, 66722, 67276, 67039). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Remove references to the structs that have moved to their own packages **What this PR does / why we need it**: Follows-up #66058 and #66059 to remove the structs that now aren't needed in `pkg/apis/componentconfig` **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref kubernetes/community#2354 **Special notes for your reviewer**: This PR depends on: - [x] #67090 - [x] #67149 - [x] #67159 - [x] #67207 **Only review commit 'Remove references to the structs that have moved to their own packages' please** **Release note**: ```release-note NONE ``` /kind cleanup /assign @sttts @thockin @jbeda @liggitt
What this PR does / why we need it:
ref #2354
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
After the related componentconfig to be moved to staging, LeaderElectionConfiguration and DebuggingConfiguration should be clean up in pkg/apis/componentconfig
Release note: