-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(thanos): add support for aliyun oss and baidu bos #14891
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package bos | ||
|
||
import ( | ||
"github.com/go-kit/log" | ||
"github.com/thanos-io/objstore" | ||
"github.com/thanos-io/objstore/providers/bos" | ||
) | ||
|
||
func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) { | ||
bosCfg := bos.Config{ | ||
Endpoint: cfg.Endpoint, | ||
Bucket: cfg.Bucket, | ||
SecretKey: cfg.SecretKey.String(), | ||
AccessKey: cfg.AccessKey, | ||
} | ||
return bos.NewBucketWithConfig(logger, bosCfg, name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package bos | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/grafana/dskit/flagext" | ||
) | ||
|
||
// Config holds the configuration for Baidu Cloud BOS client | ||
type Config struct { | ||
Bucket string `yaml:"bucket"` | ||
Endpoint string `yaml:"endpoint"` | ||
AccessKey string `yaml:"access_key"` | ||
SecretKey flagext.Secret `yaml:"secret_key"` | ||
} | ||
|
||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
cfg.RegisterFlagsWithPrefix("", f) | ||
} | ||
|
||
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | ||
f.StringVar(&cfg.Bucket, prefix+"bos.bucket", "", "Name of BOS bucket.") | ||
f.StringVar(&cfg.Endpoint, prefix+"bos.endpoint", "", "BOS endpoint to connect to.") | ||
f.StringVar(&cfg.AccessKey, prefix+"bos.access-key", "", "Baidu Cloud Engine (BCE) Access Key ID.") | ||
f.Var(&cfg.SecretKey, prefix+"bos.secret-key", "Baidu Cloud Engine (BCE) Secret Access Key.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package oss | ||
|
||
import ( | ||
"github.com/go-kit/log" | ||
"github.com/thanos-io/objstore" | ||
"github.com/thanos-io/objstore/providers/oss" | ||
) | ||
|
||
// NewBucketClient creates a new Alibaba Cloud OSS bucket client | ||
func NewBucketClient(cfg Config, component string, logger log.Logger) (objstore.Bucket, error) { | ||
ossCfg := oss.Config{ | ||
Endpoint: cfg.Endpoint, | ||
Bucket: cfg.Bucket, | ||
AccessKeyID: cfg.AccessKeyID, | ||
AccessKeySecret: cfg.AccessKeySecret.String(), | ||
} | ||
return oss.NewBucketWithConfig(logger, ossCfg, component, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package oss | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/grafana/dskit/flagext" | ||
) | ||
|
||
// Config holds the configuration for Alibaba Cloud OSS client | ||
type Config struct { | ||
Endpoint string `yaml:"endpoint"` | ||
Bucket string `yaml:"bucket"` | ||
AccessKeyID string `yaml:"access_key_id"` | ||
AccessKeySecret flagext.Secret `yaml:"access_key_secret"` | ||
} | ||
|
||
// RegisterFlags registers the flags for Alibaba Cloud OSS storage config | ||
func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | ||
cfg.RegisterFlagsWithPrefix("", f) | ||
} | ||
|
||
// RegisterFlagsWithPrefix registers the flags for Alibaba Cloud OSS storage config with prefix | ||
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) { | ||
f.StringVar(&cfg.Bucket, prefix+"oss.bucketname", "", "Name of OSS bucket.") | ||
f.StringVar(&cfg.Endpoint, prefix+"oss.endpoint", "", "Endpoint to connect to.") | ||
f.StringVar(&cfg.AccessKeyID, prefix+"oss.access-key-id", "", "alibabacloud Access Key ID") | ||
f.Var(&cfg.AccessKeySecret, prefix+"oss.access-key-secret", "alibabacloud Secret Access Key") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just noticed: with thanos-io/objstore#147 merged we can now define these for these two no? Also fine to do it on a follow up
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.
both bos and oss do not have a any way to configure retries, that's what i gathered from my last search :)