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

🐛 InformerCache: Do not require leader lease #678

Merged

Conversation

alvaroaleman
Copy link
Member

This PR makes the informerCache implement the LeaderElectionRunnable interface to signal that it doesn't need leader election. This is done so other runnables that also do not need leader election can use the cache-backed reader.

Fixes #677

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 11, 2019
@@ -140,6 +140,12 @@ func (ip *informerCache) GetInformer(obj runtime.Object) (Informer, error) {
return i.Informer, err
}

// NeedLeaderElection implements the LeaderElectionRunnable interface
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately we can not verify the interface implementation via a var _ manager.LeaderElectionRunnable = &informerCache{} as that would result in an import cycle

Expect(err).ToNot(HaveOccurred())

c, err := cache.New(cfg, cache.Options{Mapper: mapper})
Expect(err).ToNot(HaveOccurred())
Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find a matcher for "type X implements interface Y", the closed to that I found is BeAssignableToTypeOf but that errors out if one of the two is nil.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is clear enough. If you're really worried, you can always add an explanation after the "be true" part as a format string, but I think this is readable enough for now.

@alvaroaleman
Copy link
Member Author

/assign @DirectXMan12

Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Expect(err).ToNot(HaveOccurred())

c, err := cache.New(cfg, cache.Options{Mapper: mapper})
Expect(err).ToNot(HaveOccurred())
Copy link
Contributor

Choose a reason for hiding this comment

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

this is clear enough. If you're really worried, you can always add an explanation after the "be true" part as a format string, but I think this is readable enough for now.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, DirectXMan12

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 15, 2019
@k8s-ci-robot k8s-ci-robot merged commit 6d6e9c1 into kubernetes-sigs:master Nov 15, 2019
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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache-Backed reader only works when the leader lease was acquired
3 participants