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

labelbp: Renamed Label->Zlabel, and FullCopyLabel -> Label. #3330

Merged
merged 1 commit into from
Oct 16, 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
36 changes: 18 additions & 18 deletions pkg/api/query/v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ func TestRulesHandler(t *testing.T) {
EvaluationDurationSeconds: 12,
Health: "x",
Query: "sum(up)",
Labels: storepb.LabelSet{Labels: []storepb.Label{{Name: "some", Value: "label"}}},
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label"}}},
LastError: "err1",
}),
rulespb.NewRecordingRule(&rulespb.RecordingRule{
Expand All @@ -1330,7 +1330,7 @@ func TestRulesHandler(t *testing.T) {
EvaluationDurationSeconds: 12,
Health: "x",
Query: "sum(up1)",
Labels: storepb.LabelSet{Labels: []storepb.Label{{Name: "some", Value: "label2"}}},
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label2"}}},
}),
rulespb.NewAlertingRule(&rulespb.Alert{
Name: "3",
Expand All @@ -1339,21 +1339,21 @@ func TestRulesHandler(t *testing.T) {
Health: "x",
Query: "sum(up2) == 2",
DurationSeconds: 101,
Labels: storepb.LabelSet{Labels: []storepb.Label{{Name: "some", Value: "label3"}}},
Annotations: storepb.LabelSet{Labels: []storepb.Label{{Name: "ann", Value: "a1"}}},
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label3"}}},
Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "ann", Value: "a1"}}},
Alerts: []*rulespb.AlertInstance{
{
Labels: storepb.LabelSet{Labels: []storepb.Label{{Name: "inside", Value: "1"}}},
Annotations: storepb.LabelSet{Labels: []storepb.Label{{Name: "insideann", Value: "2"}}},
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "inside", Value: "1"}}},
Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "insideann", Value: "2"}}},
State: rulespb.AlertState_FIRING,
ActiveAt: &twoHAgo,
Value: "1",
// This is unlikely if groups is warn, but test nevertheless.
PartialResponseStrategy: storepb.PartialResponseStrategy_ABORT,
},
{
Labels: storepb.LabelSet{Labels: []storepb.Label{{Name: "inside", Value: "3"}}},
Annotations: storepb.LabelSet{Labels: []storepb.Label{{Name: "insideann", Value: "4"}}},
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "inside", Value: "3"}}},
Annotations: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "insideann", Value: "4"}}},
State: rulespb.AlertState_PENDING,
ActiveAt: nil,
Value: "2",
Expand All @@ -1370,7 +1370,7 @@ func TestRulesHandler(t *testing.T) {
Health: "x",
DurationSeconds: 102,
Query: "sum(up3) == 3",
Labels: storepb.LabelSet{Labels: []storepb.Label{{Name: "some", Value: "label4"}}},
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{{Name: "some", Value: "label4"}}},
State: rulespb.AlertState_INACTIVE,
}),
}
Expand Down Expand Up @@ -1431,7 +1431,7 @@ func TestRulesHandler(t *testing.T) {
testpromcompatibility.RecordingRule{
Name: all[0].GetRecording().Name,
Query: all[0].GetRecording().Query,
Labels: labelpb.LabelsToPromLabels(all[0].GetRecording().Labels.Labels),
Labels: labelpb.ZLabelsToPromLabels(all[0].GetRecording().Labels.Labels),
Health: rules.RuleHealth(all[0].GetRecording().Health),
LastError: all[0].GetRecording().LastError,
LastEvaluation: all[0].GetRecording().LastEvaluation,
Expand All @@ -1441,7 +1441,7 @@ func TestRulesHandler(t *testing.T) {
testpromcompatibility.RecordingRule{
Name: all[1].GetRecording().Name,
Query: all[1].GetRecording().Query,
Labels: labelpb.LabelsToPromLabels(all[1].GetRecording().Labels.Labels),
Labels: labelpb.ZLabelsToPromLabels(all[1].GetRecording().Labels.Labels),
Health: rules.RuleHealth(all[1].GetRecording().Health),
LastError: all[1].GetRecording().LastError,
LastEvaluation: all[1].GetRecording().LastEvaluation,
Expand All @@ -1452,25 +1452,25 @@ func TestRulesHandler(t *testing.T) {
State: strings.ToLower(all[2].GetAlert().State.String()),
Name: all[2].GetAlert().Name,
Query: all[2].GetAlert().Query,
Labels: labelpb.LabelsToPromLabels(all[2].GetAlert().Labels.Labels),
Labels: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Labels.Labels),
Health: rules.RuleHealth(all[2].GetAlert().Health),
LastError: all[2].GetAlert().LastError,
LastEvaluation: all[2].GetAlert().LastEvaluation,
EvaluationTime: all[2].GetAlert().EvaluationDurationSeconds,
Duration: all[2].GetAlert().DurationSeconds,
Annotations: labelpb.LabelsToPromLabels(all[2].GetAlert().Annotations.Labels),
Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Annotations.Labels),
Alerts: []*testpromcompatibility.Alert{
{
Labels: labelpb.LabelsToPromLabels(all[2].GetAlert().Alerts[0].Labels.Labels),
Annotations: labelpb.LabelsToPromLabels(all[2].GetAlert().Alerts[0].Annotations.Labels),
Labels: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[0].Labels.Labels),
Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[0].Annotations.Labels),
State: strings.ToLower(all[2].GetAlert().Alerts[0].State.String()),
ActiveAt: all[2].GetAlert().Alerts[0].ActiveAt,
Value: all[2].GetAlert().Alerts[0].Value,
PartialResponseStrategy: all[2].GetAlert().Alerts[0].PartialResponseStrategy.String(),
},
{
Labels: labelpb.LabelsToPromLabels(all[2].GetAlert().Alerts[1].Labels.Labels),
Annotations: labelpb.LabelsToPromLabels(all[2].GetAlert().Alerts[1].Annotations.Labels),
Labels: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[1].Labels.Labels),
Annotations: labelpb.ZLabelsToPromLabels(all[2].GetAlert().Alerts[1].Annotations.Labels),
State: strings.ToLower(all[2].GetAlert().Alerts[1].State.String()),
ActiveAt: all[2].GetAlert().Alerts[1].ActiveAt,
Value: all[2].GetAlert().Alerts[1].Value,
Expand All @@ -1483,7 +1483,7 @@ func TestRulesHandler(t *testing.T) {
State: strings.ToLower(all[3].GetAlert().State.String()),
Name: all[3].GetAlert().Name,
Query: all[3].GetAlert().Query,
Labels: labelpb.LabelsToPromLabels(all[3].GetAlert().Labels.Labels),
Labels: labelpb.ZLabelsToPromLabels(all[3].GetAlert().Labels.Labels),
Health: rules.RuleHealth(all[2].GetAlert().Health),
LastError: all[3].GetAlert().LastError,
LastEvaluation: all[3].GetAlert().LastEvaluation,
Expand Down
8 changes: 4 additions & 4 deletions pkg/query/internal/test-storeset-pre-v0.8.0/storeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ func (s *grpcStoreSpec) Metadata(ctx context.Context, client storepb.StoreClient
return nil, 0, 0, errors.Wrapf(err, "fetching store info from %s", s.addr)
}
if len(resp.LabelSets) == 0 && len(resp.Labels) > 0 {
resp.LabelSets = []storepb.LabelSet{{Labels: resp.Labels}}
resp.LabelSets = []labelpb.ZLabelSet{{Labels: resp.Labels}}
}

return labelpb.LabelSetsToPromLabelSets(resp.LabelSets...), resp.MinTime, resp.MaxTime, nil
return labelpb.ZLabelSetsToPromLabelSets(resp.LabelSets...), resp.MinTime, resp.MaxTime, nil
}

// StoreSet maintains a set of active stores. It is backed up by Store Specifications that are dynamically fetched on
Expand Down Expand Up @@ -328,10 +328,10 @@ func (s *StoreSet) getHealthyStores(ctx context.Context) map[string]*storeRef {
return
}
if len(resp.LabelSets) == 0 && len(resp.Labels) > 0 {
resp.LabelSets = []storepb.LabelSet{{Labels: resp.Labels}}
resp.LabelSets = []labelpb.ZLabelSet{{Labels: resp.Labels}}
}
store.storeType = component.FromProto(resp.StoreType)
store.Update(labelpb.LabelSetsToPromLabelSets(resp.LabelSets...), resp.MinTime, resp.MaxTime)
store.Update(labelpb.ZLabelSetsToPromLabelSets(resp.LabelSets...), resp.MinTime, resp.MaxTime)
}

mtx.Lock()
Expand Down
25 changes: 13 additions & 12 deletions pkg/query/internal/test-storeset-pre-v0.8.0/storeset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/prometheus/prometheus/pkg/labels"
"github.com/thanos-io/thanos/pkg/component"
"github.com/thanos-io/thanos/pkg/store"
"github.com/thanos-io/thanos/pkg/store/labelpb"
"github.com/thanos-io/thanos/pkg/store/storepb"
"github.com/thanos-io/thanos/pkg/testutil"

Expand Down Expand Up @@ -56,7 +57,7 @@ func (s *testStore) LabelValues(ctx context.Context, r *storepb.LabelValuesReque
}

type testStoreMeta struct {
extlsetFn func(addr string) []storepb.LabelSet
extlsetFn func(addr string) []labelpb.ZLabelSet
storeType component.StoreAPI
}

Expand Down Expand Up @@ -131,10 +132,10 @@ func TestPre0_8_0_StoreSet_AgainstNewStoreGW(t *testing.T) {
st, err := startTestStores([]testStoreMeta{
{
storeType: component.Sidecar,
extlsetFn: func(addr string) []storepb.LabelSet {
return []storepb.LabelSet{
extlsetFn: func(addr string) []labelpb.ZLabelSet {
return []labelpb.ZLabelSet{
{
Labels: []storepb.Label{
Labels: []labelpb.ZLabel{
{Name: "l1", Value: "v2"},
{Name: "l2", Value: "v3"},
},
Expand All @@ -144,34 +145,34 @@ func TestPre0_8_0_StoreSet_AgainstNewStoreGW(t *testing.T) {
},
{
storeType: component.Store,
extlsetFn: func(addr string) []storepb.LabelSet {
return []storepb.LabelSet{
extlsetFn: func(addr string) []labelpb.ZLabelSet {
return []labelpb.ZLabelSet{
{
Labels: []storepb.Label{
Labels: []labelpb.ZLabel{
// This is the labelset exposed by store when having only one sidecar's data.
{Name: "l1", Value: "v2"},
{Name: "l2", Value: "v3"},
},
},
{
Labels: []storepb.Label{{Name: store.CompatibilityTypeLabelName, Value: "store"}},
Labels: []labelpb.ZLabel{{Name: store.CompatibilityTypeLabelName, Value: "store"}},
},
}
},
},
// We expect this to be duplicated.
{
storeType: component.Store,
extlsetFn: func(addr string) []storepb.LabelSet {
return []storepb.LabelSet{
extlsetFn: func(addr string) []labelpb.ZLabelSet {
return []labelpb.ZLabelSet{
{
Labels: []storepb.Label{
Labels: []labelpb.ZLabel{
{Name: "l1", Value: "v2"},
{Name: "l2", Value: "v3"},
},
},
{
Labels: []storepb.Label{{Name: store.CompatibilityTypeLabelName, Value: "store"}},
Labels: []labelpb.ZLabel{{Name: store.CompatibilityTypeLabelName, Value: "store"}},
},
}
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/query/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func sortDedupLabels(set []storepb.Series, replicaLabels map[string]struct{}) {
// With the re-ordered label sets, re-sorting all series aligns the same series
// from different replicas sequentially.
sort.Slice(set, func(i, j int) bool {
return labels.Compare(labelpb.LabelsToPromLabels(set[i].Labels), labelpb.LabelsToPromLabels(set[j].Labels)) < 0
return labels.Compare(labelpb.ZLabelsToPromLabels(set[i].Labels), labelpb.ZLabelsToPromLabels(set[j].Labels)) < 0
})
}

Expand Down
39 changes: 20 additions & 19 deletions pkg/query/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/thanos-io/thanos/pkg/component"
"github.com/thanos-io/thanos/pkg/store"
"github.com/thanos-io/thanos/pkg/store/labelpb"
"github.com/thanos-io/thanos/pkg/store/storepb"
"github.com/thanos-io/thanos/pkg/testutil"
)
Expand Down Expand Up @@ -988,34 +989,34 @@ func TestSortReplicaLabel(t *testing.T) {
// 0 Single deduplication label.
{
input: []storepb.Series{
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "c", Value: "3"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "c", Value: "4"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-2"}, {Name: "c", Value: "3"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "c", Value: "3"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "c", Value: "4"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-2"}, {Name: "c", Value: "3"}}},
},
exp: []storepb.Series{
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-1"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-2"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}, {Name: "b", Value: "replica-1"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "4"}, {Name: "b", Value: "replica-1"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-1"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-2"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}, {Name: "b", Value: "replica-1"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "4"}, {Name: "b", Value: "replica-1"}}},
},
dedupLabels: map[string]struct{}{"b": {}},
},
// 1 Multi deduplication labels.
{
input: []storepb.Series{
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}, {Name: "c", Value: "3"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}, {Name: "c", Value: "4"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-2"}, {Name: "b1", Value: "replica-2"}, {Name: "c", Value: "3"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-2"}, {Name: "c", Value: "3"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}, {Name: "c", Value: "3"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}, {Name: "c", Value: "4"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-2"}, {Name: "b1", Value: "replica-2"}, {Name: "c", Value: "3"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "b", Value: "replica-2"}, {Name: "c", Value: "3"}}},
},
exp: []storepb.Series{
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-2"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-2"}, {Name: "b1", Value: "replica-2"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}}},
{Labels: []storepb.Label{{Name: "a", Value: "1"}, {Name: "c", Value: "4"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-2"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "b", Value: "replica-2"}, {Name: "b1", Value: "replica-2"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "3"}, {Name: "d", Value: "4"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}}},
{Labels: []labelpb.ZLabel{{Name: "a", Value: "1"}, {Name: "c", Value: "4"}, {Name: "b", Value: "replica-1"}, {Name: "b1", Value: "replica-1"}}},
},
dedupLabels: map[string]struct{}{"b": {}, "b1": {}},
},
Expand Down Expand Up @@ -1489,7 +1490,7 @@ func storeSeriesResponse(t testing.TB, lset labels.Labels, smplChunks ...[]sampl
var s storepb.Series

for _, l := range lset {
s.Labels = append(s.Labels, storepb.Label{Name: l.Name, Value: l.Value})
s.Labels = append(s.Labels, labelpb.ZLabel{Name: l.Name, Value: l.Value})
}

for _, smpls := range smplChunks {
Expand Down
2 changes: 1 addition & 1 deletion pkg/query/storeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *grpcStoreSpec) Metadata(ctx context.Context, client storepb.StoreClient
return nil, 0, 0, nil, errors.Wrapf(err, "fetching store info from %s", s.addr)
}
if len(resp.LabelSets) == 0 && len(resp.Labels) > 0 {
resp.LabelSets = []storepb.LabelSet{{Labels: resp.Labels}}
resp.LabelSets = []labelpb.ZLabelSet{{Labels: resp.Labels}}
}

labelSets = make([]labels.Labels, 0, len(resp.LabelSets))
Expand Down
Loading