Skip to content

Commit

Permalink
WIP: Allow filesytem for storage-gateway (#2555)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonswine authored Nov 8, 2023
1 parent 01fe815 commit 4486d81
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/pyroscope/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ Usage of ./pyroscope:
-storage.azure.user-assigned-id string
User assigned identity. If empty, then System assigned identity is used.
-storage.backend string
Backend storage to use. Supported backends are: s3, gcs, azure, swift, filesystem, cos. (default "filesystem")
Backend storage to use. Supported backends are: s3, gcs, azure, swift, filesystem, cos.
-storage.cos.app-id string
COS app id
-storage.cos.bucket string
Expand Down Expand Up @@ -842,7 +842,7 @@ Usage of ./pyroscope:
-storage.cos.tls-handshake-timeout duration
Maximum time to wait for a TLS handshake. 0 means no limit. (default 10s)
-storage.filesystem.dir string
Local filesystem storage directory.
Local filesystem storage directory. (default "./data-shared")
-storage.gcs.bucket-name string
GCS bucket name
-storage.gcs.service-account string
Expand Down
4 changes: 2 additions & 2 deletions cmd/pyroscope/help.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Usage of ./pyroscope:
-storage.azure.endpoint-suffix string
Azure storage endpoint suffix without schema. The account name will be prefixed to this value to create the FQDN. If set to empty string, default endpoint suffix is used.
-storage.backend string
Backend storage to use. Supported backends are: s3, gcs, azure, swift, filesystem, cos. (default "filesystem")
Backend storage to use. Supported backends are: s3, gcs, azure, swift, filesystem, cos.
-storage.cos.app-id string
COS app id
-storage.cos.bucket string
Expand All @@ -270,7 +270,7 @@ Usage of ./pyroscope:
-storage.cos.secret-key string
COS secret key
-storage.filesystem.dir string
Local filesystem storage directory.
Local filesystem storage directory. (default "./data-shared")
-storage.gcs.bucket-name string
GCS bucket name
-storage.gcs.service-account string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ storage:
# Backend storage to use. Supported backends are: s3, gcs, azure, swift,
# filesystem, cos.
# CLI flag: -storage.backend
[backend: <string> | default = "filesystem"]
[backend: <string> | default = ""]

# The s3_backend block configures the connection to Amazon S3 object storage
# backend.
Expand Down Expand Up @@ -2105,7 +2105,7 @@ The `filesystem_storage_backend` block configures the usage of local file system
```yaml
# Local filesystem storage directory.
# CLI flag: -storage.filesystem.dir
[dir: <string> | default = ""]
[dir: <string> | default = "./data-shared"]
```

```
2 changes: 1 addition & 1 deletion pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func New(phlarectx context.Context, cfg Config, dbConfig phlaredb.Config, storag
localBucketCfg phlareobjclient.Config
err error
)
localBucketCfg.Backend = "filesystem"
localBucketCfg.Backend = phlareobjclient.Filesystem
localBucketCfg.Filesystem.Directory = dbConfig.DataPath
i.localBucket, err = phlareobjclient.NewBucket(phlarectx, localBucketCfg, "local")
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions pkg/objstore/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
)

const (
// None is the null value for the storage backends.
None = ""

// S3 is the value for the S3 storage backend.
S3 = "s3"

Expand Down Expand Up @@ -78,7 +81,7 @@ func (cfg *StorageBackendConfig) RegisterFlagsWithPrefixAndDefaultDirectory(pref
cfg.Swift.RegisterFlagsWithPrefix(prefix, f)
cfg.Filesystem.RegisterFlagsWithPrefixAndDefaultDirectory(prefix, dir, f)
cfg.COS.RegisterFlagsWithPrefix(prefix, f)
f.StringVar(&cfg.Backend, prefix+"backend", Filesystem, fmt.Sprintf("Backend storage to use. Supported backends are: %s.", strings.Join(cfg.supportedBackends(), ", ")))
f.StringVar(&cfg.Backend, prefix+"backend", None, fmt.Sprintf("Backend storage to use. Supported backends are: %s.", strings.Join(cfg.supportedBackends(), ", ")))
}

func (cfg *StorageBackendConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet, logger log.Logger) {
Expand Down Expand Up @@ -122,7 +125,7 @@ func (cfg *Config) RegisterFlagsWithPrefixAndDefaultDirectory(prefix, dir string
}

func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet, logger log.Logger) {
cfg.RegisterFlagsWithPrefixAndDefaultDirectory(prefix, "", f, logger)
cfg.RegisterFlagsWithPrefixAndDefaultDirectory(prefix, "./data-shared", f, logger)
}

func (cfg *Config) Validate() error {
Expand Down
5 changes: 4 additions & 1 deletion pkg/phlare/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,10 @@ func (f *Phlare) initRing() (_ services.Service, err error) {

func (f *Phlare) initStorage() (_ services.Service, err error) {
objectStoreTypeStats.Set(f.Cfg.Storage.Bucket.Backend)
if cfg := f.Cfg.Storage.Bucket; cfg.Backend != "filesystem" {
if cfg := f.Cfg.Storage.Bucket; cfg.Backend != objstoreclient.None {
if cfg.Backend != objstoreclient.Filesystem {
level.Warn(f.logger).Log("msg", "when running with storage.backend 'filesystem' it is important that all replicas/components share the same filesystem")
}
b, err := objstoreclient.NewBucket(
f.context(),
cfg,
Expand Down
2 changes: 1 addition & 1 deletion pkg/phlaredb/profile_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func testContext(t testing.TB) testCtx {
dataPath := t.TempDir()
ctx = contextWithDataDir(ctx, dataPath)
bucketCfg := phlareobjclient.Config{}
bucketCfg.Backend = "filesystem"
bucketCfg.Backend = phlareobjclient.Filesystem
bucketCfg.Filesystem.Directory = dataPath
bucketClient, err := phlareobjclient.NewBucket(ctx, bucketCfg, "testing")
require.NoError(t, err)
Expand Down

0 comments on commit 4486d81

Please sign in to comment.