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/validate compactor config #2824

Merged
merged 3 commits into from
Nov 5, 2020
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
4 changes: 2 additions & 2 deletions pkg/logql/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package logql
import (
"fmt"

"github.com/grafana/loki/pkg/logql/log"

"github.com/prometheus/prometheus/pkg/labels"

"github.com/grafana/loki/pkg/logql/log"
)

// ParseError is what is returned when we failed to parse.
Expand Down
1 change: 1 addition & 0 deletions pkg/storage/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ func TestStore_MultipleBoltDBShippersInConfig(t *testing.T) {
cortex_util.Logger,
)
require.NoError(t, err)

store, err = NewStore(config, schemaConfig, chunkStore, nil)
require.NoError(t, err)

Expand Down
12 changes: 12 additions & 0 deletions pkg/storage/stores/shipper/compactor/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package compactor

import (
"context"
"errors"
"flag"
"path/filepath"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -34,6 +36,12 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
f.DurationVar(&cfg.CompactionInterval, "boltdb.shipper.compactor.compaction-interval", 2*time.Hour, "Interval at which to re-run the compaction operation.")
}

func (cfg *Config) IsDefaults() bool {
cpy := &Config{}
cpy.RegisterFlags(flag.NewFlagSet("defaults", flag.ContinueOnError))
return reflect.DeepEqual(cfg, cpy)
}

type Compactor struct {
services.Service

Expand All @@ -44,6 +52,10 @@ type Compactor struct {
}

func NewCompactor(cfg Config, storageConfig storage.Config, r prometheus.Registerer) (*Compactor, error) {
if cfg.IsDefaults() {
return nil, errors.New("Must specify compactor config")
}

objectClient, err := storage.NewObjectClient(cfg.SharedStoreType, storageConfig)
if err != nil {
return nil, err
Expand Down
28 changes: 28 additions & 0 deletions pkg/storage/stores/shipper/compactor/compactor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package compactor

import (
"fmt"
"testing"
"time"

"github.com/stretchr/testify/require"
)

func TestIsDefaults(t *testing.T) {
for i, tc := range []struct {
in *Config
out bool
}{
{&Config{
WorkingDirectory: "/tmp",
}, false},
{&Config{}, false},
{&Config{
CompactionInterval: 2 * time.Hour,
}, true},
} {
t.Run(fmt.Sprint(i), func(t *testing.T) {
require.Equal(t, tc.out, tc.in.IsDefaults())
})
}
}
2 changes: 1 addition & 1 deletion pkg/storage/stores/shipper/util/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func DoParallelQueries(ctx context.Context, tableQuerier TableQuerier, queries [
}

// IndexDeduper should always be used on table level not the whole query level because it just looks at range values which can be repeated across tables
//Cortex anyways dedupes entries across tables
// Cortex anyways dedupes entries across tables
type IndexDeduper struct {
callback chunk_util.Callback
seenRangeValues map[string]map[string]struct{}
Expand Down