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

fix dir setup based on which mode it is running #2559

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions pkg/storage/stores/shipper/shipper_index_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,12 @@ type Shipper struct {

// NewShipper creates a shipper for syncing local objects with a store
func NewShipper(cfg Config, storageClient chunk.ObjectClient, registerer prometheus.Registerer) (chunk.IndexClient, error) {
err := chunk_util.EnsureDirectory(cfg.CacheLocation)
if err != nil {
return nil, err
}

shipper := Shipper{
cfg: cfg,
metrics: newMetrics(registerer),
}

err = shipper.init(storageClient, registerer)
err := shipper.init(storageClient, registerer)
if err != nil {
return nil, err
}
Expand All @@ -102,19 +97,27 @@ func NewShipper(cfg Config, storageClient chunk.ObjectClient, registerer prometh
}

func (s *Shipper) init(storageClient chunk.ObjectClient, registerer prometheus.Registerer) error {
uploader, err := s.getUploaderName()
if err != nil {
return err
// When we run with target querier we don't have ActiveIndexDirectory set so using CacheLocation instead.
// Also it doesn't matter which directory we use since BoltDBIndexClient doesn't do anything with it but it is good to have a valid path.
boltdbIndexClientDir := s.cfg.ActiveIndexDirectory
if boltdbIndexClientDir == "" {
boltdbIndexClientDir = s.cfg.CacheLocation
}

s.boltDBIndexClient, err = local.NewBoltDBIndexClient(local.BoltDBConfig{Directory: s.cfg.ActiveIndexDirectory})
var err error
s.boltDBIndexClient, err = local.NewBoltDBIndexClient(local.BoltDBConfig{Directory: boltdbIndexClientDir})
if err != nil {
return err
}

prefixedObjectClient := util.NewPrefixedObjectClient(storageClient, StorageKeyPrefix)

if s.cfg.Mode != ModeReadOnly {
uploader, err := s.getUploaderName()
if err != nil {
return err
}

cfg := uploads.Config{
Uploader: uploader,
IndexDir: s.cfg.ActiveIndexDirectory,
Expand Down