-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add /ingester/shutdown_and_forget handler
This handler can be used to gracefully shut down a Loki instance and delete the file that persists the tokens of the ingester ring. In production environments you usually want to persist ring tokens so that during a restart of an ingester instance, or during rollout, the tokens from that instance are not re-distributed to other instances, but instead kept so that the same streams end up on the same instance once it is up and running again. For that, the tokens are written to a file that can be specified via the `-ingester.tokens-file-path` argument. In certain cases, however, you want to forget the tokens and re-distribute them when shutting down an ingester instance. This was already possible by calling `/ingester/flush_shutdown`, deleting the tokens file and terminating the instance. The new handler `/ingester/shutdown_and_forget` combines these manual steps into a single handler. Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
- Loading branch information
Showing
3 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package series | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/go-kit/log" | ||
"github.com/grafana/dskit/flagext" | ||
"github.com/prometheus/common/model" | ||
"github.com/stretchr/testify/require" | ||
"github.com/weaveworks/common/user" | ||
|
||
"github.com/grafana/loki/pkg/storage/chunk/cache" | ||
"github.com/grafana/loki/pkg/storage/config" | ||
"github.com/grafana/loki/pkg/storage/stores/series/index" | ||
"github.com/grafana/loki/pkg/validation" | ||
) | ||
|
||
type mockStore struct { | ||
index.Client | ||
queries []index.Query | ||
results index.ReadBatchResult | ||
} | ||
|
||
func (m *mockStore) QueryPages(ctx context.Context, queries []index.Query, callback index.QueryPagesCallback) error { | ||
for _, query := range queries { | ||
callback(query, m.results) | ||
} | ||
m.queries = append(m.queries, queries...) | ||
return nil | ||
} | ||
|
||
func defaultLimits() (*validation.Overrides, error) { | ||
var defaults validation.Limits | ||
flagext.DefaultValues(&defaults) | ||
defaults.CardinalityLimit = 5 | ||
return validation.NewOverrides(defaults, nil) | ||
} | ||
|
||
func BenchmarkIndexStore(b *testing.B) { | ||
store := &mockStore{ | ||
results: index.ReadBatch{ | ||
Entries: []index.CacheEntry{{ | ||
Column: []byte("foo"), | ||
Value: []byte("bar"), | ||
}}, | ||
}, | ||
} | ||
limits, err := defaultLimits() | ||
require.NoError(b, err) | ||
logger := log.NewNopLogger() | ||
cache := cache.NewFifoCache("test", cache.FifoCacheConfig{MaxSizeItems: 10, TTL: 10 * time.Second}, nil, logger) | ||
client := index.NewCachingIndexClient(store, cache, 100*time.Millisecond, limits, logger, false) | ||
|
||
schemaCfg := config.SchemaConfig{ | ||
Configs: []config.PeriodConfig{ | ||
{From: config.DayTime{Time: model.Now().Add(-24 * time.Hour)}, Schema: "v12", RowShards: 16}, | ||
}, | ||
} | ||
schema, err := index.CreateSchema(schemaCfg.Configs[0]) | ||
require.NoError(b, err) | ||
idxStore := NewIndexStore(schemaCfg, schema, client, nil, 10) | ||
|
||
userID := "fake" | ||
from := model.Now().Add(-1 * time.Hour) | ||
through := model.Now() | ||
ctx := user.InjectOrgID(context.Background(), userID) | ||
|
||
b.ResetTimer() | ||
b.ReportAllocs() | ||
for x := 0; x < b.N; x++ { | ||
res, err := idxStore.LabelValuesForMetricName(ctx, userID, from, through, "logs", "foo") | ||
b.Log(res, err) | ||
} | ||
} |