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

Replicate can specify blocks to copy #3388

Merged
merged 6 commits into from
Dec 15, 2020

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Oct 30, 2020

Signed-off-by: Ben Ye [email protected]

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Fixes #2713

Added a repeated flag --id to specify the blocks to replicate.

Verification

@yeya24 yeya24 force-pushed the replicate-block-id branch from 5e3289c to 76c27f5 Compare November 9, 2020 03:11
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Nice, job! Some suggestions 🤗

@@ -446,6 +446,8 @@ func registerBucketReplicate(app extkingpin.AppClause, objStoreConfig *extflag.P
Default("0000-01-01T00:00:00Z"))
maxTime := model.TimeOrDuration(cmd.Flag("max-time", "End of time range limit to replicate. Thanos Replicate will replicate only metrics, which happened earlier than this value. Option can be a constant time in RFC3339 format or time duration relative to current time, such as -1d or 2h45m. Valid duration units are ms, s, m, h, d, w, y.").
Default("9999-12-31T23:59:59Z"))
ids := cmd.Flag("id", "Block to be replicated to the destination bucket. If this is specified, then only "+
"IDs will be used to match blocks and other matchers will be ignored. It only runs once. Repeated field").Strings()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"IDs will be used to match blocks and other matchers will be ignored. It only runs once. Repeated field").Strings()
"IDs will be used to match blocks and other matchers will be ignored. When specified, this command will be run only once after successful replication. Repeated field").Strings()

@@ -83,6 +83,7 @@ func RunReplicate(
toObjStoreConfig *extflag.PathOrContent,
singleRun bool,
minTime, maxTime *thanosmodel.TimeOrDurationValue,
blockIDs []string,
Copy link
Member

Choose a reason for hiding this comment

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

why not pasing ulid.ULID?

if _, ok := bf.blockIDs[id]; ok {
return true
}
level.Debug(bf.logger).Log("msg", "filtering block", "reason", "block ID doesn't match", "block_uuid", id)
Copy link
Member

Choose a reason for hiding this comment

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

This will spam a lot. Maybe we can just not do log it?

@@ -49,11 +51,16 @@ func NewBlockFilter(
for _, compactionLevel := range compactionLevels {
allowedCompactions[compactionLevel] = struct{}{}
}
blockSet := make(map[string]struct{})
Copy link
Member

Choose a reason for hiding this comment

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

The blockID list will be super short. Can we just loop over it instead of using map? Might be simpler (:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds better!

@yeya24 yeya24 force-pushed the replicate-block-id branch from 76c27f5 to 4a5af18 Compare November 12, 2020 16:45
@yeya24
Copy link
Contributor Author

yeya24 commented Nov 12, 2020

@bwplotka Updated, please take a look again!

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM, just two nits (:

for _, id := range *ids {
if bid, err := ulid.Parse(id); err != nil {
return errors.Wrap(err, "invalid ULID found in --id flag")
} else {
Copy link
Member

Choose a reason for hiding this comment

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

no need for else ;p

"testing"
)

func TestIntersection(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, will remove this.

@yeya24
Copy link
Contributor Author

yeya24 commented Nov 12, 2020

Updated again.

@yeya24 yeya24 force-pushed the replicate-block-id branch from 29a0f89 to 8899580 Compare November 12, 2020 17:24
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM 💪 rebase only.

@yeya24 yeya24 force-pushed the replicate-block-id branch from 8899580 to e8b3656 Compare November 21, 2020 23:25
@yeya24
Copy link
Contributor Author

yeya24 commented Nov 21, 2020

LGTM rebase only.

Rebased, PTAL

Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! Please rebase on master again and I think we can merge this.

@yeya24 yeya24 force-pushed the replicate-block-id branch from e8b3656 to b22170c Compare November 24, 2020 20:26
@yeya24
Copy link
Contributor Author

yeya24 commented Nov 24, 2020

Done. PTAL again.

Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
@yeya24 yeya24 force-pushed the replicate-block-id branch from b22170c to c2ae9a0 Compare December 14, 2020 02:42
@yeya24
Copy link
Contributor Author

yeya24 commented Dec 14, 2020

Just rebased this pr. PTAL again, thanks!

@yeya24
Copy link
Contributor Author

yeya24 commented Dec 15, 2020

I will merge this since there are already two approvals!

@yeya24 yeya24 merged commit 7c3c43c into thanos-io:master Dec 15, 2020
@yeya24 yeya24 deleted the replicate-block-id branch December 15, 2020 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Replicate can copy individual blocks
3 participants