-
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
Refactor bucket configuration flags for Object Store #500
Refactor bucket configuration flags for Object Store #500
Conversation
@Bplotka Sorry for later. I'm so busy with my work this two weeks. But it is prepare to review now. |
docs/components/bucket.md
Outdated
no trace will be sent periodically, unless forced | ||
by baggage item. See `pkg/tracing/tracing.go` for | ||
details. | ||
--provider.type=<provider> |
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.
All these parameters are S3 specific. :( I think best approach would be to specify provider config in external JSON file where you can specify type and all additional provider options, like Premium/Standard storage, access policies etc.. Each provider can have arbitrary options to pass there.
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.
Agree... We need some way to not exponentially increase number of flags, but also keep documentation clear, how to configure obj stores. I am generally against moving to a config file, instead of flags. This is basically harder to operate. There is no clear winner here..
Some quick idea:
- Put to flags only things that are common and add
objstore.extra
for file content and allow different providers parse it dynamically to internal structs?
Anything smarter? @brancz you are after inspiring Gophercon, maybe you have some idea (:
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 have mixed feelings for anything that goes into the provider direction but still baked into the binary. It's going to be a pain no matter how we spin it and there's always going to be that next provider that someone desperately needs. I think similar to peer discovery we should find an interface that someone can implement and create a shim between Thanos and the storage provider they want to use. Maybe we could extend the store component to expose an additional "upload" service so all object storage functionality is central to that component and people can then just implement their own store binaries, as the code is really not complex, and we could even expose everything except the actual bucket implementation as a library.
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 agree. I feel like we need another proposal for this as we need to consider various issues like performance and operating of yet another sidecar/service.
The problem is that this is quite critical part, but some gRPC S3 like API could make sense. It is not time critical though, as we have some safety buffer. I think I like this idea more & more.
But clearly this change will not happen from day to day. I feel like we need something simple for time being...
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.
Added #505
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.
Some initial review. Overall - very good direction. We need exactly that! Thanks for this!
And good timing, I was just about to implement this (:
pkg/objstore/config.go
Outdated
func NewBucketConfig(cmd *kingpin.CmdClause) *BucketConfig { | ||
var bucketConfig BucketConfig | ||
|
||
cmd.Flag("provider.type", "Specify the provider for object store. If empty or unsupport provider, Thanos won't read and store any block to the object store. Now supported GCS / S3."). |
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.
s/unsupport/unsupported
pkg/objstore/config.go
Outdated
var bucketConfig BucketConfig | ||
|
||
cmd.Flag("provider.type", "Specify the provider for object store. If empty or unsupport provider, Thanos won't read and store any block to the object store. Now supported GCS / S3."). | ||
PlaceHolder("<provider>").StringVar(&bucketConfig.Provider) |
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.
Can we use EnumVar
type here (instead of String var)?
pkg/objstore/config.go
Outdated
} | ||
|
||
// NewBucketConfig return the configuration of object store | ||
// TODO(jojohappy) should it support multiple bucket? |
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.
Good question. I think yes. We need some way of being able to use NewBucketConfig
more than once, with some certain prefix maybe for both flag names and envvars names?
One use case is in bucket verify
subcommand, where you can specify backup bucket. (: Not sure if we need this now though. Let's leave TODO and add that in next PRs
pkg/objstore/config.go
Outdated
Unsupported objProvider = "UNSUPPORTED" | ||
) | ||
|
||
var ErrNotFound = errors.New("no valid provider configuration supplied") |
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.
All of this should move to client
package. It is confusing that ErrNotFound
indicates not found provided and not, "not found bucket" or "not found object"
pkg/objstore/config.go
Outdated
) | ||
|
||
var ErrNotFound = errors.New("no valid provider configuration supplied") | ||
var ErrMissingGCSBucket = errors.New("missing Google Cloud Storage bucket name for stored blocks") |
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.
objstore
is meant to be generic, no provider details should be here
pkg/objstore/config.go
Outdated
// BucketConfig encapsulates the necessary config values to instantiate an object store client. | ||
// Use Provider to represent the Object Stores | ||
type BucketConfig struct { | ||
Provider string |
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.
objProvider
instead of string?
pkg/objstore/config.go
Outdated
cmd.Flag("provider.access-key", "Access key for an object store API. Support S3-Compatible API"). | ||
PlaceHolder("<key>").Envar("PROVIDER_ACCESS_KEY").StringVar(&bucketConfig.AccessKey) | ||
|
||
// TODO(jojohappy): should it be encrypted? |
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 don't think so. How this improve things, if you would need encryption password/key passed somehow anyway?
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.
No, users should provide the original password or key, but the BucketConfig
will encrypt that and return it decrypted. Because the s3.Config
did not export the secretKey
, I didn't know why did that. In the new BucketConfig
, I still doesn't export this field, so I think should it be encrypted?
Not sure for that, if it is not necessary, I will remove that.
pkg/objstore/config.go
Outdated
func NewBucketConfig(cmd *kingpin.CmdClause) *BucketConfig { | ||
var bucketConfig BucketConfig | ||
|
||
cmd.Flag("provider.type", "Specify the provider for object store. If empty or unsupport provider, Thanos won't read and store any block to the object store. Now supported GCS / S3."). |
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 am also not sure about provider
name. Provider does not suggest for what things provider we mean. Maybe objstore
instead?
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.
yea, it will make sense.
docs/components/bucket.md
Outdated
no trace will be sent periodically, unless forced | ||
by baggage item. See `pkg/tracing/tracing.go` for | ||
details. | ||
--provider.type=<provider> |
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.
Agree... We need some way to not exponentially increase number of flags, but also keep documentation clear, how to configure obj stores. I am generally against moving to a config file, instead of flags. This is basically harder to operate. There is no clear winner here..
Some quick idea:
- Put to flags only things that are common and add
objstore.extra
for file content and allow different providers parse it dynamically to internal structs?
Anything smarter? @brancz you are after inspiring Gophercon, maybe you have some idea (:
pkg/objstore/config.go
Outdated
} | ||
|
||
// NewBackupBucketConfig return the configuration of backup object store | ||
func NewBackupBucketConfig(cmd *kingpin.CmdClause) *BucketConfig { |
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.
yea, maybe we want just NewBucketConfig(cmd, suffix)
^^
Please rebase this for green CI (Landed fix #504) (: |
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.
Thanks for addressing all comments! Some extra one, but overall good direction.
There is blocker comment we need to make some decision on before merging, which is this discussion: #500 (comment)
In current state it still requires custom flags that does not make any sense for different providers. I feel like creating 2 flags:
objstore.type
objstore.config
and config being some custom yaml, marhsalled differently for each provider makes the most sense now.
cmd/thanos/store.go
Outdated
@@ -31,7 +31,7 @@ func registerStore(m map[string]setupFunc, app *kingpin.Application, name string | |||
dataDir := cmd.Flag("tsdb.path", "Data directory of TSDB."). | |||
Default("./data").String() | |||
|
|||
bucketConf := objstore.NewBucketConfig(cmd) | |||
bucketConf := objstore.NewBucketConfig(cmd, "") |
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.
you could potentiall add NewBucketConfigWithPrefix
method to avoid this (:
pkg/objstore/config.go
Outdated
@@ -34,104 +43,52 @@ type BucketConfig struct { | |||
} | |||
|
|||
// NewBucketConfig return the configuration of object store | |||
// TODO(jojohappy) should it support multiple bucket? | |||
func NewBucketConfig(cmd *kingpin.CmdClause) *BucketConfig { | |||
func NewBucketConfig(cmd *kingpin.CmdClause, suffix string) *BucketConfig { |
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.
Why this has to be here and not in client
package?
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.
(and all changes in this file)
Added #505 that relates to this, but in mean time we should have something working now - @jojohappy feel free to ping me on slack, I explain more. |
5b6673b
to
8764690
Compare
b25496d
to
8057c44
Compare
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. This will help a lot I think. But this is major change so I will share it widely for review, OK?
I am mostly ok, just some suggestions.
cmd/thanos/bucket.go
Outdated
PlaceHolder("<bucket>").String() | ||
|
||
s3Config := s3.RegisterS3Params(cmd) | ||
bucketConf := cmd.Flag("objstore.config", "The yaml format configuration of bucket for stored blocks."). |
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.
Can we improve this description by saying The object store configuration in yaml format.
cmd/thanos/bucket.go
Outdated
|
||
s3Config := s3.RegisterS3Params(cmd) | ||
bucketConf := cmd.Flag("objstore.config", "The yaml format configuration of bucket for stored blocks."). | ||
PlaceHolder("<bucket.config>").String() |
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 is .Required()
here I believe.
pkg/objstore/client/factory.go
Outdated
|
||
type BucketConfig struct { | ||
Type objProvider `yaml:"type"` | ||
Content interface{} `yaml:"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.
Maybe just config
instead of 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.
+1
pkg/objstore/client/factory.go
Outdated
if config == "" { | ||
return nil, ErrNotFound | ||
} | ||
err = yaml.Unmarshal([]byte(config), &bucketConf) |
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.
we can use if err := ... ; err != nil {
idiom here (:
pkg/objstore/s3/s3.go
Outdated
Bucket string `yaml:"bucket"` | ||
Endpoint string `yaml:"endpoint"` | ||
AccessKey string `yaml:"access-key"` | ||
SecretKey string `yaml:"secret-key"` |
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.
And now is that real question.. should it be available here or just through envvar (: I remember people saying it is not good idea to specify them via config file or flags
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.
OK, I will rollback it to just use envvar (:
Can you @jojohappy rebase? |
As a next step we can do in next PR: Some |
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.
Overall, looks good, need some minor tweaks.
cmd/thanos/downsample.go
Outdated
|
||
s3Config := s3.RegisterS3Params(cmd) | ||
bucketConf := cmd.Flag("objstore.config", "The yaml format configuration of bucket for stored blocks."). | ||
PlaceHolder("<bucket.config>").String() |
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.
.Required() I guess
cmd/thanos/store.go
Outdated
@@ -24,17 +23,15 @@ import ( | |||
|
|||
// registerStore registers a store command. | |||
func registerStore(m map[string]setupFunc, app *kingpin.Application, name string) { | |||
cmd := app.Command(name, "store node giving access to blocks in a GCS bucket") | |||
cmd := app.Command(name, "store node giving access to blocks in a supported bucket provider") |
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 would print out provider signature here.
docs/components/bucket.md
Outdated
How often we send traces (1/<sample-factor>). If 0 no | ||
trace will be sent periodically, unless forced by | ||
baggage item. See `pkg/tracing/tracing.go` for details. | ||
--objstore.config=<bucket.config> |
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's not clear from the description that it should be yaml file
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.
e.. It is not a yaml file, just content of configuration in yaml format. But we should update the example.
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.
Sorry for the noise. I know your opinion.
pkg/objstore/client/factory.go
Outdated
|
||
type BucketConfig struct { | ||
Type objProvider `yaml:"type"` | ||
Content interface{} `yaml:"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.
+1
|
8057c44
to
7d5dffa
Compare
@Bplotka @vglafirov Fixed review and CHANGELOG. Meanwhile update the documents. |
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, awesome work. Just super tiny nits, except maybe error handling in client.Bucket. Let's fix those and we are good to go 💪 Thanks!
cmd/thanos/bucket.go
Outdated
|
||
s3Config := s3.RegisterS3Params(cmd) | ||
bucketConf := cmd.Flag("objstore.config", "The object store configuration in yaml format."). | ||
PlaceHolder("<bucket.config.yaml>").Required().String() | ||
|
||
// Verify command. | ||
verify := cmd.Command("verify", "verify all blocks in the bucket against specified issues") | ||
verifyRepair := verify.Flag("repair", "attempt to repair blocks for which issues were detected"). | ||
Short('r').Default("false").Bool() | ||
// NOTE(bplotka): Currently we support backup buckets only in the same project. |
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.
Not relevant anymore, we can kill this
pkg/objstore/client/factory.go
Outdated
case S3: | ||
bucket, err = s3.NewBucket(logger, config, reg, component) | ||
default: | ||
return nil, ErrNotFound |
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 should return different error than not found. It's not known type we should error on.
pkg/objstore/gcs/gcs.go
Outdated
@@ -32,29 +37,56 @@ const ( | |||
// DirDelim is the delimiter used to model a directory structure in an object store bucket. | |||
const DirDelim = "/" | |||
|
|||
// gcsConfig stores the configuration for gcs bucket |
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.
missing trailing period
pkg/objstore/gcs/gcs.go
Outdated
func NewBucket(name string, cl *storage.Client, reg prometheus.Registerer) *Bucket { | ||
func NewBucket(logger log.Logger, ctx context.Context, conf []byte, reg prometheus.Registerer, component string) (*Bucket, error) { | ||
var gc gcsConfig | ||
err := yaml.Unmarshal(conf, &gc) |
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.
we can if err := (..); err != nil { .. }
idiom
pkg/objstore/s3/s3.go
Outdated
return nil, err | ||
} | ||
config.secretKey = os.Getenv("S3_SECRET_KEY") | ||
err = Validate(config) |
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.
if err := (...); err != nil {}
idiom (:
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.
and above
pkg/objstore/s3/s3.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
config.secretKey = os.Getenv("S3_SECRET_KEY") |
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.
👍
pkg/objstore/s3/s3.go
Outdated
@@ -185,6 +147,31 @@ func NewBucket(logger log.Logger, conf *Config, reg prometheus.Registerer, compo | |||
return bkt, nil | |||
} | |||
|
|||
// GetBucket return the bucket name for s3 |
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.
returns
instead of return
and missing trailing period (:
CHANGELOG.md
Outdated
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |||
- Add Thanos compact --retention.default flag, for configuring storage bucket retention period. | |||
- Removes support for multiple units in duration. For example: 1m0s won't work, while 1m will work. | |||
- Adds support for y,w,d time units | |||
- Use the configuration of bucket in yaml format. |
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.
Can we move to something like:
Removes support of those flags
--gcs-bucket=<bucket>
--s3.bucket=<bucket>
--s3.endpoint=<api-url>
--s3.access-key=<key>
--s3.insecure
--s3.signature-version2
--s3.encrypt-sse
--gcs-backup-bucket=<bucket>
--s3-backup-bucket=<bucket>
instead added --objstore.config
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 would remove this special case, otherwise rebase + LGTM
pkg/objstore/client/factory.go
Outdated
bucket, err = gcs.NewBucket(logger, context.Background(), config, reg, component) | ||
case S3: | ||
bucket, err = s3.NewBucket(logger, config, reg, component) | ||
case "": |
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.
This one is not required. It's clearly an error if someone puts config with type: ""
(:
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.
Done
pkg/objstore/client/factory_test.go
Outdated
testutil.Assert(t, err != ErrNotFound, "it should not error with not found") | ||
} | ||
|
||
func TestBlankBucketConfig(t *testing.T) { |
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.
not required case
4b001d5
to
aa29f10
Compare
@vglafirov you requested some changes. Is it ok now? I would like to merge this to unblock you and @jojohappy COS client |
Isn't it better to pass link to yaml file to the |
@Bplotka I tend to agree with @xjewer I think passing a path to the yaml file will be much cleaner than actually passing the yaml in a string. |
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.
Mainly nits ... can we wrap errors that we are returning to give more context and updating a few function signatures.
cmd/thanos/compact.go
Outdated
|
||
s3config := s3.RegisterS3Params(cmd) | ||
bucketConf := cmd.Flag("objstore.config", "The object store configuration in yaml format."). | ||
PlaceHolder("<bucket.config.yaml>").String() |
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.
should this not be required for compact? We will not be able to do anything without a bucket.
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.
yea, It should be required.
pkg/objstore/client/factory.go
Outdated
return objstore.BucketWithMetrics(s3Config.Bucket, b, reg), nil | ||
config, err := yaml.Marshal(bucketConf.Config) | ||
if err != nil { | ||
return nil, err |
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.
can we wrap this error 👍
cmd/thanos/store.go
Outdated
@@ -83,7 +78,7 @@ func runStore( | |||
verbose bool, | |||
) error { | |||
{ | |||
bkt, err := client.NewBucket(logger, &gcsBucket, *s3Config, reg, component) | |||
bkt, err := client.NewBucket(logger, bucketConf, reg, component) | |||
if err != nil { | |||
return err |
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.
mind wrapping this whilst were here
pkg/objstore/gcs/gcs.go
Outdated
|
||
closer io.Closer | ||
} | ||
|
||
// NewBucket returns a new Bucket against the given bucket handle. | ||
func NewBucket(name string, cl *storage.Client, reg prometheus.Registerer) *Bucket { | ||
func NewBucket(logger log.Logger, ctx context.Context, conf []byte, reg prometheus.Registerer, component string) (*Bucket, error) { |
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 think its convention to have ctx
as the first variable in the method. See conclusion here https://blog.golang.org/context
pkg/objstore/gcs/gcs.go
Outdated
bkt *storage.BucketHandle | ||
opsTotal *prometheus.CounterVec | ||
bucket string |
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.
name
?
pkg/objstore/objstore.go
Outdated
@@ -26,6 +26,9 @@ type Bucket interface { | |||
|
|||
// Delete removes the object with the given name. | |||
Delete(ctx context.Context, name string) error | |||
|
|||
// GetBucket returns the bucket name for the provider. | |||
GetBucket() string |
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.
Can we update this function name ... Name()
? We tend not to have Getters in Go and although its returning string
on first glance I would assume it returns the bucket.
c0ae0e6
to
a1ec2b3
Compare
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
cce5eba
to
4d665f1
Compare
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.
Some comment after changing to file loading.
cmd/thanos/bucket.go
Outdated
PlaceHolder("<bucket>").String() | ||
verifyBackupS3Bucket := cmd.Flag("s3-backup-bucket", "S3 bucket name to backup blocks on repair operations."). | ||
PlaceHolder("<bucket>").String() | ||
backupBucketConfFile := verify.Flag("objstore-backup.config", "The backup object store configuration in yaml format."). |
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.
config-file for consistency (:
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's my fault. Will be updated
pkg/objstore/client/factory.go
Outdated
func loadFile(confFile string) (*BucketConfig, error) { | ||
content, err := ioutil.ReadFile(confFile) | ||
if err != nil { | ||
return nil, err |
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.
wrap with confFile
maybe?
pkg/objstore/client/factory.go
Outdated
} | ||
|
||
bucketConf := &BucketConfig{} | ||
if err := yaml.UnmarshalStrict(content, bucketConf); err != nil { |
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.
Why Strict
?
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.
According to the gopkg.in/yaml.v2
documents, using UnmarshalStrict
can throw the error in the data that mapping keys that are duplicates or other unknown errors. The opinion comes from this issue.
pkg/objstore/client/factory.go
Outdated
|
||
bucketConf := &BucketConfig{} | ||
if err := yaml.UnmarshalStrict(content, bucketConf); err != nil { | ||
return nil, fmt.Errorf("parsing YAML file %s: %v", confFile, err) |
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.
we use errors.Wrapf(err, msg, ...)
from github/pkg/errors
package.
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[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.
🎉 Thanks for you work @jojohappy
Let's merge it!
Signed-off-by: jojohappy <[email protected]>
Just noticed, interesting moment, we deleted support env S3_SECRET_KEY, so what's the way to keep it in secrets in k8s and use configmap for the rest? @jojohappy |
the only way to use it in k8s seams to put the whole bucket.yaml config file into the secret https://kubernetes.io/docs/concepts/configuration/secret/#use-case-dotfiles-in-secret-volume |
Very good point! And it's major one, let's figure it out. For me we should
get S3_SECRET_KEY back working again.
śr., 26 wrz 2018 o 17:16 użytkownik xjewer <[email protected]>
napisał:
… the only way to use it in k8s seams to put the whole bucket.yaml config
file into the secret
https://kubernetes.io/docs/concepts/configuration/secret/#use-case-dotfiles-in-secret-volume
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#500 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGoNu3Ht2-vsVEm8X9zkKWlQj_glgRdNks5ue6higaJpZM4WU8Cz>
.
|
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
Signed-off-by: jojohappy <[email protected]>
* Feature: support tencent cloud object storage Signed-off-by: jojohappy <[email protected]> * To set Content-Length for *os.File Signed-off-by: jojohappy <[email protected]> * Fixed circleci test Signed-off-by: jojohappy <[email protected]> * Rebase master to migrate PR #500 Signed-off-by: jojohappy <[email protected]> * Fixed code style Signed-off-by: jojohappy <[email protected]> * Update inconsistent constant variable Signed-off-by: jojohappy <[email protected]> * Update storage document Signed-off-by: jojohappy <[email protected]> * Fixed snake_case & some nits Signed-off-by: jojohappy <[email protected]> * Remove unnecessary store metrics Signed-off-by: jojohappy <[email protected]> * Remove evaluating type of block object in production code Signed-off-by: jojohappy <[email protected]> * Remove bucket metrics Signed-off-by: jojohappy <[email protected]> * Address review comments Signed-off-by: jojohappy <[email protected]> * To wrap reader closer as a nop to avoid to close it after uploading in COS client Signed-off-by: jojohappy <[email protected]> * Rebase & Add client struct config to bucketcfggen Signed-off-by: jojohappy <[email protected]> * Update storage docs using bucketcfggen Signed-off-by: jojohappy <[email protected]> * Address review comments Signed-off-by: jojohappy <[email protected]> * Address review comments Signed-off-by: jojohappy <[email protected]> * Update version of COS provider && Remove getting the length of reader Signed-off-by: jojohappy <[email protected]> * Missing the comment of object storage testing env THANOS_SKIP_SWIFT_TESTS Signed-off-by: jojohappy <[email protected]> * Address review comments Signed-off-by: jojohappy <[email protected]> * Typo error && Remove unused function argument Signed-off-by: jojohappy <[email protected]>
Changes
This PR try to make some unified bucket flags for all provider. User should set the
--provider.type
to represent which provider they use. And all flags will be reused for all provider now. This aim is to reduce the number of flags when new provider appended if it can reuse the flags have been exists.Verification
User can run the
thanos bucket ls
to verify this PR