Skip to content

Commit

Permalink
Return 404 on unknown tenant (#321)
Browse files Browse the repository at this point in the history
* If the tenant id is not found just return nil

Signed-off-by: Joe Elliott <number101010@gmail.com>

* changelog

Signed-off-by: Joe Elliott <number101010@gmail.com>
  • Loading branch information
joe-elliott committed Nov 4, 2020
1 parent 08a465b commit fd114a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,3 +6,4 @@
* [ENHANCEMENT] Add warnings for suspect configs. [#294](https://github.com/grafana/tempo/pull/294)
* [ENHANCEMENT] Add command line flags for s3 credentials. [#308](https://github.com/grafana/tempo/pull/308)
* [BUGFIX] Increase Prometheus `notfound` metric on tempo-vulture. [#301](https://github.com/grafana/tempo/pull/301)
* [BUGFIX] Return 404 if searching for a tenant id that does not exist in the backend. [#321](https://github.com/grafana/tempo/pull/321)
2 changes: 1 addition & 1 deletion tempodb/tempodb.go
Expand Up @@ -255,7 +255,7 @@ func (rw *readerWriter) Find(ctx context.Context, tenantID string, id encoding.I
rw.blockListsMtx.Unlock()

if !found {
return nil, metrics, fmt.Errorf("tenantID %s not found", tenantID)
return nil, metrics, nil
}

foundBytes, err := rw.pool.RunJobs(derivedCtx, copiedBlocklist, func(ctx context.Context, payload interface{}) ([]byte, error) {
Expand Down
24 changes: 24 additions & 0 deletions tempodb/tempodb_test.go
Expand Up @@ -97,6 +97,30 @@ func TestDB(t *testing.T) {
}
}

func TestNilOnUnknownTenantID(t *testing.T) {
tempDir, err := ioutil.TempDir("/tmp", "")
defer os.RemoveAll(tempDir)
assert.NoError(t, err, "unexpected error creating temp dir")

r, _, _, err := New(&Config{
Backend: "local",
Local: &local.Config{
Path: path.Join(tempDir, "traces"),
},
WAL: &wal.Config{
Filepath: path.Join(tempDir, "wal"),
IndexDownsample: 17,
BloomFP: .01,
},
BlocklistPoll: 0,
}, log.NewNopLogger())
assert.NoError(t, err)

buff, _, err := r.Find(context.Background(), "unknown", []byte{0x01})
assert.Nil(t, buff)
assert.Nil(t, err)
}

func TestRetention(t *testing.T) {
tempDir, err := ioutil.TempDir("/tmp", "")
defer os.RemoveAll(tempDir)
Expand Down

0 comments on commit fd114a2

Please sign in to comment.