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

cache-server: provides client-related functionality for dealing with a shard on the HTTP level #1853

Merged

Conversation

p0lyn0mial
Copy link
Contributor

Summary

WithDefaultShardRoundTripper for setting a default shard in the context.
WithShardRoundTripper for changing the URL path to contain a shard name defined in the context.

WithShardInContext and ShardFromContext for writting/reading a shard name to/from the context.

A shard package for holding a shard name in the memory.

Related issue(s)

Fixes #

@openshift-ci openshift-ci bot requested review from stevekuznetsov and sttts August 30, 2022 13:22
@p0lyn0mial
Copy link
Contributor Author

/assign @stevekuznetsov @sttts

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

One question, otherwise LGTM

@p0lyn0mial p0lyn0mial force-pushed the cache-server-client-rt branch from 9e12c04 to 04676f9 Compare August 31, 2022 13:01
@p0lyn0mial
Copy link
Contributor Author

@stevekuznetsov I slightly changed the PR, PTAL

@p0lyn0mial p0lyn0mial force-pushed the cache-server-client-rt branch from 04676f9 to 5921e93 Compare August 31, 2022 13:03
// ShardFromContext returns the value of the shard key on the ctx,
// or an empty Name if there is no shard key.
func ShardFromContext(ctx context.Context) shard.Name {
val, ok := ctx.Value(shardContextKey).(shard.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can be a follow-up: can just return ctx.Value(shardContextKey).(shard.Name) since

a) the shardContextKey is private to this package, so the only case where !ok is if someone were to write code in this package to add something invalid
b) the zero-value is already shard.New("")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I just don't like when the code panics but sure I can change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

Choose a reason for hiding this comment

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

Sorry, one last question - feel free to cancel hold

/lgtm
/approve
/hold

return originalPath, nil
}
// if the originalPath already has a shard set just overwrite it to the given one
if strings.Contains(originalPath, "/shards") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this specifically not doing a prefix check for some reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as of today, we could actually check for a prefix, maybe in the future, it will have to be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@openshift-ci openshift-ci bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 31, 2022
… HTTP level

WithDefaultShardRoundTripper for setting a default shard in the context.
WithShardRoundTripper for changing the URL path to contain a shard name defined in the context.

WithShardInContext and ShardFromContext for writting/reading a shard name to/from the context.

A shard package for holding a shard name in the memory.
@p0lyn0mial p0lyn0mial force-pushed the cache-server-client-rt branch from 5921e93 to 43e9e48 Compare August 31, 2022 15:34
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2022
@p0lyn0mial
Copy link
Contributor Author

@stevekuznetsov updated the PR, PTAL

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 31, 2022
@stevekuznetsov
Copy link
Contributor

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 31, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: stevekuznetsov

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-merge-robot openshift-merge-robot merged commit 86c8e40 into kcp-dev:main Aug 31, 2022
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. 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