-
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
Fixed the lease endpoint reconciler creation of kubernetes endpoint and lease file ttl. #53803 #53809
Fixed the lease endpoint reconciler creation of kubernetes endpoint and lease file ttl. #53803 #53809
Conversation
@rrati: Adding do-not-merge/release-note-label-needed because the release note process has not been followed. One of the following labels is required "release-note", "release-note-action-required", or "release-note-none". Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
pkg/master/reconcilers/lease.go
Outdated
@@ -82,7 +82,7 @@ func (s *storageLeases) UpdateLease(ip string) error { | |||
}, | |||
} | |||
|
|||
leaseTime := uint64(s.leaseTime) | |||
leaseTime := uint64(s.leaseTime / time.Second) |
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.
Worth commenting that leaseTime has to be in seconds and hence the division?
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.
Yep, will add a comment
pkg/master/master.go
Outdated
@@ -94,7 +94,7 @@ const ( | |||
// DefaultEndpointReconcilerTTL is the default TTL timeout for the storage layer | |||
DefaultEndpointReconcilerTTL = 15 * time.Second | |||
// DefaultStorageEndpoint is the default storage endpoint for the lease controller | |||
DefaultStorageEndpoint = "kube-apiserver-endpoint" | |||
DefaultStorageEndpoint = "services/endpoints" |
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 shouldn't need this at all. this is getting passed like this:
ResourcePrefix: c.ExtraConfig.StorageFactory.ResourcePrefix(kapi.Resource(DefaultStorageEndpoint)),
that should be
ResourcePrefix: c.ExtraConfig.StorageFactory.ResourcePrefix(kapi.Resource("endpoints")),
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.
Partial diff here
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.
ah, the api.Resource("endpoints") is even better
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.
I think we can get it from StorageFactory.ResourcePrefix(api.Resource("endpoints"))
pkg/master/master.go
Outdated
@@ -94,7 +94,7 @@ const ( | |||
// DefaultEndpointReconcilerTTL is the default TTL timeout for the storage layer | |||
DefaultEndpointReconcilerTTL = 15 * time.Second | |||
// DefaultStorageEndpoint is the default storage endpoint for the lease controller |
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.
This comment doesn't really make sense insofar as what it's really used for, and we should probably change the name of the constant too.
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.
Agreed. What about EndpointPrefix?
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, I think we can get rid of this const alltogether
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.
exactly
As best I can tell, the lease endpoint reconciler is only on master and not in 1.8, therefore: /release-note-none |
@kubernetes/sig-api-machinery-pr-reviews |
Yes, merged after 1.8 was cut |
e160bef
to
700f41d
Compare
/assign @cheftako |
…nd lease file ttl
pkg/master/master.go
Outdated
@@ -206,18 +204,19 @@ func (c *Config) createLeaseReconciler() reconcilers.EndpointReconciler { | |||
if err != nil { | |||
glog.Fatalf("Error creating storage factory: %v", err) | |||
} | |||
endpointConfig, err := c.ExtraConfig.StorageFactory.NewConfig(kapi.Resource(DefaultStorageEndpoint)) | |||
endpointPrefix := c.ExtraConfig.StorageFactory.ResourcePrefix(api.Resource("endpoints")) | |||
endpointConfig, err := c.ExtraConfig.StorageFactory.NewConfig(kapi.Resource(endpointPrefix)) |
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.
this looks right:
endpointPrefix := c.ExtraConfig.StorageFactory.ResourcePrefix(api.Resource("endpoints"))
this looks wrong:
c.ExtraConfig.StorageFactory.NewConfig(kapi.Resource(endpointPrefix))
why are you passing the prefix into kapi.Resource(endpointPrefix)
? I expected:
c.ExtraConfig.StorageFactory.NewConfig(kapi.Resource("endpoints"))
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.
StorageFactory.ResourcePrefix actually returns a string. I'm passing to kapi.Resource to create a schema.GroupResource which is what NewConfig needs.
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 output of c.ExtraConfig.StorageFactory.ResourcePrefix
is an etcd prefix, the location in etcd where we want to store that resource.
taking that value and making a schema.GroupResource
out of it doesn't make any sense. this should be
endpointConfig, err := c.ExtraConfig.StorageFactory.NewConfig(kapi.Resource("endpoints"))
pkg/master/master.go
Outdated
if err != nil { | ||
glog.Fatalf("Error getting storage config: %v", err) | ||
} | ||
endpointsStorage := endpointsstorage.NewREST(generic.RESTOptions{ | ||
StorageConfig: endpointConfig, | ||
Decorator: generic.UndecoratedStorage, | ||
DeleteCollectionWorkers: 0, | ||
ResourcePrefix: c.ExtraConfig.StorageFactory.ResourcePrefix(kapi.Resource(DefaultStorageEndpoint)), | ||
ResourcePrefix: c.ExtraConfig.StorageFactory.ResourcePrefix(kapi.Resource(endpointPrefix)), |
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.
should be ResourcePrefix: endpointPrefix
, right?
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.
Same comment as above
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.
same response as above :)
pkg/master/master.go
Outdated
}) | ||
endpointRegistry := endpoint.NewRegistry(endpointsStorage) | ||
masterLeases := reconcilers.NewLeases(leaseStorage, "/masterleases/", ttl) | ||
masterLeases := reconcilers.NewLeases(leaseStorage, "/masterleases", ttl) |
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.
normalize inside NewLeases
to ensure we work with or without leading/trailing slashes?
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.
also, does List
depend on a trailing slash? does removing this mean we could see things at /masterleases1
?
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.
Internally the prefix is appended with a / and a key for getting a specific key or just uses the prefix when listing, so shouldn't have an issue with /masterleases1. The adding of a / is currently hard-coded so "masterleases/" would result in "masterleases//" on lookup. Using path.join is the better way to handle the filename.
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.
or just the prefix, so shouldn't have an issue with /masterleases1
my question was whether List("/masterleases")
would return /masterleases1
if it existed
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.
Updated the internals to use path.join when hunting for a key
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.
my question was whether List("/masterleases") would return /masterleases1 if it existed
I believe it would. The list function is just using a prefix. In my experience List("masterleases") would return /masterleses1 and/or /masterleases/1
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.
so this needs to change back to "/masterleases/"
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.
You're right. I'll fix
2f4c12e
to
bc80909
Compare
bc80909
to
a52bcd4
Compare
@ncdc Yes, I've tested on a 3 node apiserver setup and verified the lease files are created, expire, and that the endpoint is created in the proper location and attached to the kubernetes service |
LGTM. Will defer to @liggitt to tag |
/lgtm |
/assign @derekwaynecarr |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: derekwaynecarr, liggitt, rrati Associated issue: 53803 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
a52bcd4
to
099404a
Compare
/test pull-kubernetes-unit |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Fixed the prefix used to create the kubernetes endpoint and the ttl value used for lease files.
Fixes: #53803