Skip to content

Commit

Permalink
Introduce multitenant reserved label
Browse files Browse the repository at this point in the history
  • Loading branch information
vlvasilev committed Sep 27, 2021
1 parent 5a9b5bf commit 20ee7f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.38.0-dev
v0.37.1-dev
1 change: 1 addition & 0 deletions pkg/batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (b *Batch) Add(ls model.LabelSet, t time.Time, line string) {
b.Bytes += len(line)

// Append the entry to an already existing stream (if any)
// Not efficient string building.
labels := ls.String()
if stream, ok := b.Streams[labels]; ok {
stream.add(t, line)
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/multi_tenant_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const (
MultiTenantClientsSeparator = ";"
)

// NewMultiTenantClientWrapper returns Loki client which support more than one tenant id specified
// under `_gardener_multitenamt_id__` labale separated with semicolumn.
// NewMultiTenantClientWrapper returns Loki client which supports more than one tenant id specified
// under `_gardener_multitenamt_id__` label. The tenants are separated by semicolon.
func NewMultiTenantClientWrapper(clientToWrap types.LokiClient, copyLabelSet bool) types.LokiClient {
return &multiTenantClient{
lokiclient: clientToWrap,
Expand Down
6 changes: 6 additions & 0 deletions pkg/client/multi_tenant_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ var _ = Describe("Multi Tenant Client", func() {
s: "test1",
wantedTenants: []model.LabelValue{"operator", "user"},
}),
ginkotable.Entry("Handle record with __gardener_multitenant_id__ reserved label with one empty. Separator \" ; \" and leading and trailing spaces.", handleArgs{
ls: model.LabelSet{"hostname": "test", "__gardener_multitenant_id__": " operator ; ; user "},
t: time.Now(),
s: "test1",
wantedTenants: []model.LabelValue{"operator", "user"},
}),
ginkotable.Entry("Handle record with __gardener_multitenant_id__ and __tenant_id__ reserved labels.", handleArgs{
ls: model.LabelSet{"hostname": "test", "__tenant_id__": "pinokio", "__gardener_multitenant_id__": "operator; user"},
t: time.Now(),
Expand Down

0 comments on commit 20ee7f4

Please sign in to comment.