-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Added thanos bucket replicate
#2113
Changes from all commits
a63a73a
d8d7d96
2b5f8e5
ec15750
7fb9f6a
418fb42
dfeef29
e65c5af
d7ea55a
772a358
cd8a067
4bda22a
ffece8a
dcf97d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |||||||
"fmt" | ||||||||
"os" | ||||||||
"sort" | ||||||||
"strconv" | ||||||||
"strings" | ||||||||
"text/template" | ||||||||
"time" | ||||||||
|
@@ -26,13 +27,15 @@ import ( | |||||||
"github.com/thanos-io/thanos/pkg/block" | ||||||||
"github.com/thanos-io/thanos/pkg/block/metadata" | ||||||||
"github.com/thanos-io/thanos/pkg/compact" | ||||||||
"github.com/thanos-io/thanos/pkg/compact/downsample" | ||||||||
"github.com/thanos-io/thanos/pkg/component" | ||||||||
"github.com/thanos-io/thanos/pkg/extflag" | ||||||||
"github.com/thanos-io/thanos/pkg/extprom" | ||||||||
extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" | ||||||||
"github.com/thanos-io/thanos/pkg/objstore" | ||||||||
"github.com/thanos-io/thanos/pkg/objstore/client" | ||||||||
"github.com/thanos-io/thanos/pkg/prober" | ||||||||
"github.com/thanos-io/thanos/pkg/replicate" | ||||||||
"github.com/thanos-io/thanos/pkg/runutil" | ||||||||
httpserver "github.com/thanos-io/thanos/pkg/server/http" | ||||||||
"github.com/thanos-io/thanos/pkg/ui" | ||||||||
|
@@ -69,6 +72,7 @@ func registerBucket(m map[string]setupFunc, app *kingpin.Application, name strin | |||||||
registerBucketLs(m, cmd, name, objStoreConfig) | ||||||||
registerBucketInspect(m, cmd, name, objStoreConfig) | ||||||||
registerBucketWeb(m, cmd, name, objStoreConfig) | ||||||||
registerBucketReplicate(m, cmd, name, objStoreConfig) | ||||||||
} | ||||||||
|
||||||||
func registerBucketVerify(m map[string]setupFunc, root *kingpin.CmdClause, name string, objStoreConfig *extflag.PathOrContent) { | ||||||||
|
@@ -377,6 +381,49 @@ func registerBucketWeb(m map[string]setupFunc, root *kingpin.CmdClause, name str | |||||||
} | ||||||||
} | ||||||||
|
||||||||
// Provide a list of resolution, can not use Enum directly, since string does not implement int64 function. | ||||||||
func listResLevel() []string { | ||||||||
return []string{ | ||||||||
strconv.FormatInt(downsample.ResLevel0, 10), | ||||||||
strconv.FormatInt(downsample.ResLevel1, 10), | ||||||||
strconv.FormatInt(downsample.ResLevel2, 10)} | ||||||||
} | ||||||||
|
||||||||
func registerBucketReplicate(m map[string]setupFunc, root *kingpin.CmdClause, name string, objStoreConfig *extflag.PathOrContent) { | ||||||||
cmd := root.Command("replicate", fmt.Sprintf("Replicate data from one object storage to another. NOTE: Currently it works only with Thanos blocks (%v has to have Thanos metadata).", block.MetaFilename)) | ||||||||
httpBindAddr, httpGracePeriod := regHTTPFlags(cmd) | ||||||||
toObjStoreConfig := regCommonObjStoreFlags(cmd, "-to", false, "The object storage which replicate data to.") | ||||||||
// TODO(bwplotka): Allow to replicate many resolution levels. | ||||||||
resolution := cmd.Flag("resolution", "Only blocks with this resolution will be replicated.").Default(strconv.FormatInt(downsample.ResLevel0, 10)).HintAction(listResLevel).Int64() | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, I think we might need actually Also
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact it does. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How? I proposed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that you mean add more level support for both resolution and compaction, so i added two TODOs here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kinpin supports |
||||||||
// TODO(bwplotka): Allow to replicate many compaction levels. | ||||||||
compaction := cmd.Flag("compaction", "Only blocks with this compaction level will be replicated.").Default("1").Int() | ||||||||
daixiang0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
matcherStrs := cmd.Flag("matcher", "Only blocks whose external labels exactly match this matcher will be replicated.").PlaceHolder("key=\"value\"").Strings() | ||||||||
singleRun := cmd.Flag("single-run", "Run replication only one time, then exit.").Default("false").Bool() | ||||||||
|
||||||||
m[name+" replicate"] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ <-chan struct{}, _ bool) error { | ||||||||
matchers, err := replicate.ParseFlagMatchers(*matcherStrs) | ||||||||
if err != nil { | ||||||||
return errors.Wrap(err, "parse block label matchers") | ||||||||
} | ||||||||
|
||||||||
return replicate.RunReplicate( | ||||||||
g, | ||||||||
logger, | ||||||||
reg, | ||||||||
tracer, | ||||||||
*httpBindAddr, | ||||||||
time.Duration(*httpGracePeriod), | ||||||||
matchers, | ||||||||
compact.ResolutionLevel(*resolution), | ||||||||
*compaction, | ||||||||
objStoreConfig, | ||||||||
toObjStoreConfig, | ||||||||
*singleRun, | ||||||||
) | ||||||||
} | ||||||||
|
||||||||
} | ||||||||
|
||||||||
// refresh metadata from remote storage periodically and update UI. | ||||||||
func refresh(ctx context.Context, logger log.Logger, bucketUI *ui.Bucket, duration time.Duration, timeout time.Duration, name string, reg *prometheus.Registry, objStoreConfig *extflag.PathOrContent) error { | ||||||||
confContentYaml, err := objStoreConfig.Content() | ||||||||
|
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.
It got into wrong release section, so we need to be careful when merging release-0.11 to master @metalmatze