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

Receive: initialize default tenant on start in receiver #6728

Closed
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,21 @@ func runReceive(
return errors.Wrap(err, "parse relabel configuration")
}

dbs := receive.NewMultiTSDB(
dbs, err := receive.NewMultiTSDB(
conf.dataDir,
logger,
reg,
tsdbOpts,
lset,
conf.tenantLabelName,
conf.defaultTenantID,
bkt,
conf.allowOutOfOrderUpload,
hashFunc,
)
if err != nil {
return errors.Wrap(err, "creating multi tsdb")
}
writer := receive.NewWriter(log.With(logger, "component", "receive-writer"), dbs, &receive.WriterOptions{
Intern: conf.writerInterning,
TooFarInFutureTimeWindow: int64(time.Duration(*conf.tsdbTooFarInFutureTimeWindow)),
Expand Down
9 changes: 7 additions & 2 deletions pkg/receive/multitsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ func NewMultiTSDB(
tsdbOpts *tsdb.Options,
labels labels.Labels,
tenantLabelName string,
defaultTenantId string,
bucket objstore.Bucket,
allowOutOfOrderUpload bool,
hashFunc metadata.HashFunc,
) *MultiTSDB {
) (*MultiTSDB, error) {
if l == nil {
l = log.NewNopLogger()
}

return &MultiTSDB{
res := &MultiTSDB{
dataDir: dataDir,
logger: log.With(l, "component", "multi-tsdb"),
reg: reg,
Expand All @@ -93,6 +94,10 @@ func NewMultiTSDB(
allowOutOfOrderUpload: allowOutOfOrderUpload,
hashFunc: hashFunc,
}
// initialize default tenant for warmer startups
_, err := res.getOrLoadTenant(defaultTenantId, true)

return res, err
}

type localClient struct {
Expand Down
Loading