Skip to content
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

Merged
merged 1 commit into from
Oct 19, 2017

Conversation

rrati
Copy link

@rrati rrati commented Oct 12, 2017

Fixed the prefix used to create the kubernetes endpoint and the ttl value used for lease files.

Fixes: #53803

@k8s-ci-robot
Copy link
Contributor

@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".
Please see: https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 12, 2017
@rrati
Copy link
Author

rrati commented Oct 12, 2017

@ncdc @rphillips

@@ -82,7 +82,7 @@ func (s *storageLeases) UpdateLease(ip string) error {
},
}

leaseTime := uint64(s.leaseTime)
leaseTime := uint64(s.leaseTime / time.Second)
Copy link
Member

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?

Copy link
Author

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

@@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deads2k @sttts @liggitt is there any better way to get at this value?

Copy link
Member

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")),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial diff here

Copy link
Member

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

Copy link
Author

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"))

@@ -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
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. What about EndpointPrefix?

Copy link
Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

@ncdc
Copy link
Member

ncdc commented Oct 12, 2017

As best I can tell, the lease endpoint reconciler is only on master and not in 1.8, therefore:

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 12, 2017
@ncdc
Copy link
Member

ncdc commented Oct 12, 2017

@kubernetes/sig-api-machinery-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Oct 12, 2017
@liggitt
Copy link
Member

liggitt commented Oct 12, 2017

As best I can tell, the lease endpoint reconciler is only on master and not in 1.8, therefore:

Yes, merged after 1.8 was cut

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 12, 2017
@mml
Copy link
Contributor

mml commented Oct 12, 2017

/assign @cheftako

@ncdc
Copy link
Member

ncdc commented Oct 16, 2017

@rrati I assume you've tested this locally and it's all good?

@liggitt any other comments?

@@ -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))
Copy link
Member

@liggitt liggitt Oct 16, 2017

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"))

Copy link
Author

@rrati rrati Oct 16, 2017

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.

Copy link
Member

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"))

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)),
Copy link
Member

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?

Copy link
Author

@rrati rrati Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same response as above :)

})
endpointRegistry := endpoint.NewRegistry(endpointsStorage)
masterLeases := reconcilers.NewLeases(leaseStorage, "/masterleases/", ttl)
masterLeases := reconcilers.NewLeases(leaseStorage, "/masterleases", ttl)
Copy link
Member

@liggitt liggitt Oct 16, 2017

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?

Copy link
Member

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?

Copy link
Author

@rrati rrati Oct 16, 2017

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.

Copy link
Member

@liggitt liggitt Oct 16, 2017

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

Copy link
Author

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

Copy link
Author

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

Copy link
Member

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/"

Copy link
Author

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

@rrati rrati force-pushed the lease-reconciler-fixes branch 2 times, most recently from 2f4c12e to bc80909 Compare October 16, 2017 20:08
@yujuhong yujuhong removed their assignment Oct 16, 2017
@rrati
Copy link
Author

rrati commented Oct 17, 2017

@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

@ncdc
Copy link
Member

ncdc commented Oct 17, 2017

LGTM. Will defer to @liggitt to tag

@liggitt
Copy link
Member

liggitt commented Oct 17, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 17, 2017
@rrati
Copy link
Author

rrati commented Oct 17, 2017

/assign @derekwaynecarr

@derekwaynecarr
Copy link
Member

/approve

@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 19, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 19, 2017
@rrati
Copy link
Author

rrati commented Oct 19, 2017

/test pull-kubernetes-unit

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit c7a1a06 into kubernetes:master Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lease reconciler creates incorrect kubernetes endpoint and lease files
10 participants