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

Bug fix relating to Cluster Seed File #1625

Merged
merged 3 commits into from
Aug 8, 2022
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Jsonnet users will now need to specify a storage request and limit for the gener
* [BUGFIX] metrics-generator: do not remove x-scope-orgid header in single tenant modus [#1554](https://github.com/grafana/tempo/pull/1554) (@kvrhdn)
* [BUGFIX] Fixed issue where backend does not support `root.name` and `root.service.name` [#1589](https://github.com/grafana/tempo/pull/1589) (@kvrhdn)
* [BUGFIX] Fixed ingester to continue starting up after block replay error [#1603](https://github.com/grafana/tempo/issues/1603) (@mdisibio)
* [BUGFIX] Fix issue relating to usage stats and GCS returning empty strings as tenantID [#1625](https://github.com/grafana/tempo/pull/1625) (@ie-pham)

## v1.4.1 / 2022-05-05

Expand Down
6 changes: 2 additions & 4 deletions pkg/usagestats/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
)

const (
// File name for the cluster seed file.
ClusterSeedFileName = "tempo_cluster_seed.json"
// attemptNumber how many times we will try to read a corrupted cluster seed before deleting it.
attemptNumber = 4
// seedKey is the key for the cluster seed to use with the kv store.
Expand Down Expand Up @@ -200,7 +198,7 @@ func (rep *Reporter) fetchSeed(ctx context.Context, continueFn func(err error) b

// readSeedFile reads the cluster seed file from the object store.
func (rep *Reporter) readSeedFile(ctx context.Context) (*ClusterSeed, error) {
reader, _, err := rep.reader.Read(ctx, ClusterSeedFileName, backend.KeyPath{}, false)
reader, _, err := rep.reader.Read(ctx, backend.ClusterSeedFileName, backend.KeyPath{}, false)
if err != nil {
return nil, err
}
Expand All @@ -226,7 +224,7 @@ func (rep *Reporter) writeSeedFile(ctx context.Context, seed ClusterSeed) error
if err != nil {
return err
}
return rep.writer.Write(ctx, ClusterSeedFileName, []string{}, bytes.NewReader(data), -1, false)
return rep.writer.Write(ctx, backend.ClusterSeedFileName, []string{}, bytes.NewReader(data), -1, false)
}

// running inits the reporter seed and start sending report for every interval
Expand Down
3 changes: 2 additions & 1 deletion pkg/usagestats/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"

"github.com/grafana/tempo/tempodb/backend"
"github.com/grafana/tempo/tempodb/backend/local"
)

Expand Down Expand Up @@ -81,7 +82,7 @@ func Test_LeaderElectionWithBrokenSeedFile(t *testing.T) {
// Ensure that leader election succeeds even when the seed file has been
// corrupted. This means that we don't need to extend the interface of the
// backend in order to delete a corrupted seed file.
err = objectClient.Write(context.Background(), ClusterSeedFileName, []string{}, bytes.NewReader([]byte("{")), -1, false)
err = objectClient.Write(context.Background(), backend.ClusterSeedFileName, []string{}, bytes.NewReader([]byte("{")), -1, false)
require.NoError(t, err)

for i := 0; i < 3; i++ {
Expand Down
2 changes: 1 addition & 1 deletion tempodb/backend/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (rw *readerWriter) List(ctx context.Context, keypath backend.KeyPath) ([]st
Versions: false,
})

objects := make([]string, 0)
var objects []string
for {
attrs, err := iter.Next()
if err == iterator.Done {
Expand Down
14 changes: 13 additions & 1 deletion tempodb/backend/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const (
MetaName = "meta.json"
CompactedMetaName = "meta.compacted.json"
TenantIndexName = "index.json.gz"
// File name for the cluster seed file.
ClusterSeedFileName = "tempo_cluster_seed.json"
)

// KeyPath is an ordered set of strings that govern where data is read/written from the backend
Expand Down Expand Up @@ -129,7 +131,17 @@ func (r *reader) ReadRange(ctx context.Context, name string, blockID uuid.UUID,
}

func (r *reader) Tenants(ctx context.Context) ([]string, error) {
return r.r.List(ctx, nil)
list, err := r.r.List(ctx, nil)

// this filter is added to fix a GCS usage stats issue that would result in ""
var filteredList []string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zalegrala @ie-pham

minor but we should have preallocated this slice to match the tenants length.

a test on this behavior also would have been nice.

for _, tenant := range list {
if tenant != "" && tenant != ClusterSeedFileName {
filteredList = append(filteredList, tenant)
}
}

return filteredList, err
}

func (r *reader) Blocks(ctx context.Context, tenantID string) ([]uuid.UUID, error) {
Expand Down