-
Notifications
You must be signed in to change notification settings - Fork 544
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
copyblocks: support copying between tenants #10110
Conversation
Co-authored-by: Taylor C <[email protected]>
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.
Left a couple of nits, but the changes overall look good 🔥
@@ -297,7 +329,7 @@ func copyBlocks(ctx context.Context, cfg config, logger log.Logger, m *metrics) | |||
m.blocksCopied.Inc() | |||
level.Info(logger).Log("msg", "block copied successfully") | |||
|
|||
err = uploadCopiedMarkerFile(ctx, sourceBucket, tenantID, blockID, destBucket.Name()) | |||
err = uploadCopiedMarkerFile(ctx, sourceBucket, sourceTenantID, blockID, destBucket.Name()) |
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.
(nit) Maybe we can add a note about the behaviour around markers, just it was clear from the code
err = uploadCopiedMarkerFile(ctx, sourceBucket, sourceTenantID, blockID, destBucket.Name()) | |
// Note that markers copying ignores the tenants mapping. This may not work if copying blocks to multiple destination tenants. | |
err = uploadCopiedMarkerFile(ctx, sourceBucket, sourceTenantID, blockID, destBucket.Name()) |
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 reworded it a bit and added the comment:
// Note that only the blockID and destination bucket are considered in the copy marker.
// If multiple tenants in the same destination bucket are copied to from the same source tenant the markers will currently clash.
tools/copyblocks/main.go
Outdated
@@ -59,6 +62,7 @@ func (c *config) registerFlags(f *flag.FlagSet) { | |||
f.DurationVar(&c.copyPeriod, "copy-period", 0, "How often to repeat the copy. If set to 0, copy is done once, and the program stops. Otherwise, the program keeps running and copying blocks until it is terminated.") | |||
f.Var(&c.enabledUsers, "enabled-users", "If not empty, only blocks for these users are copied.") | |||
f.Var(&c.disabledUsers, "disabled-users", "If not empty, blocks for these users are not copied.") | |||
f.Var(&c.crossTenantMapping, "cross-tenant-mapping", "A comma-separated list of (source tenant):(destination tenant). If a source tenant is not mapped then its destination tenant is assumed to be identical.") |
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.
cross-tenant-mapping
(nit) Maybe it's better to stick to "users" on the inputs level? The command has --enabled-users
and --disabled-users
flags. So it feels confusing if one doesn't know that those are the same. Can we name the flag --user-mapping
?
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.
Nice catch, thanks. I changed it to --user-mapping
and updated the documentation to reflect that.
* copyblocks: support copying between tenants * Update tools/copyblocks/README.md * Update tools/copyblocks/README.md Co-authored-by: Taylor C <[email protected]> * Address feedback --------- Co-authored-by: Taylor C <[email protected]> (cherry picked from commit be2f23b) Co-authored-by: Andy Asp <[email protected]>
What this PR does
Adds the option
user-mapping
tocopyblocks
to allow copying between tenants. Previously it was always assumed that blocks would be copied to a different bucket under the same tenant.For example, passing
--user-mapping="foo:bar"
would map the blocks from tenantfoo
to the destination tenantbar
.Something I did not touch in this PR was the copy marker naming. It is of the form
markers/blockID-copied-target-bucket
. Now that different tenants can be copied to the marker can clash if you copy data from one tenant to multiple tenants in the same destination bucket. That seemed like a weird use case so I deferred to YAGNI.Which issue(s) this PR fixes or relates to
N/A
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.