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

✨ pkg/indexers: add helers for cache server fallback #2944

Conversation

stevekuznetsov
Copy link
Contributor

Every single consumer of these functions operating over replicated data needs to use the same exact pattern to access their data. There's no need to make them all duplicate the logic.

/cc @nrb @sttts
/assign @p0lyn0mial

Every single consumer of these functions operating over replicated data
needs to use the same exact pattern to access their data. There's no
need to make them all duplicate the logic.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@openshift-ci openshift-ci bot requested review from nrb and sttts April 4, 2023 16:51
@openshift-ci openshift-ci bot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Apr 4, 2023
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 4, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 4, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ncdc

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 4, 2023
@stevekuznetsov
Copy link
Contributor Author

Test failed on ... DNS?

@openshift-merge-robot openshift-merge-robot merged commit ee2ba92 into kcp-dev:main Apr 4, 2023
// ByPathAndNameWithFallback returns the instance of T from the indexer with the matching path and name. Path may be a canonical path
// or a cluster name. Note: this depends on the presence of the optional "kcp.io/path" annotation. If no instance is found, globalIndexer
// is searched as well. Any errors short-circuit this logic.
func ByPathAndNameWithFallback[T runtime.Object](groupResource schema.GroupResource, indexer, globalIndexer cache.Indexer, path logicalcluster.Path, name string) (ret T, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need both ByIndexWithFallback and ByPathAndNameWithFallback methods?
It seems that both methods eventually make use of indexer.ByIndex :)

The difference seems to be that ByIndex returns an array of object whereas ByPathAndName returns a single object.

Do we need this distinction or could we unify into one method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@p0lyn0mial please feel free to propose a simpler factoring! One was not obvious to me since the error checking is different.

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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants