Skip to content

Commit 49538e9

Browse files
committed
update quicktemplate, parse disable_compression, add sorting
1 parent cf64a5e commit 49538e9

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

app/vlselect/internalselect/internalselect.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"math"
88
"net/http"
9+
"sort"
910
"strconv"
1011
"sync"
1112
"time"
@@ -262,17 +263,33 @@ func processTenantIDsRequest(ctx context.Context, w http.ResponseWriter, r *http
262263
end = math.MaxInt64
263264
}
264265

266+
var disableCompression bool
267+
s := r.FormValue("disable_compression")
268+
if s != "" {
269+
disableCompression, err = strconv.ParseBool(s)
270+
if err != nil {
271+
return fmt.Errorf("cannot parse disable_compression=%q: %w", s, err)
272+
}
273+
}
274+
265275
tenantIDs, err := vlstorage.GetTenantIDs(ctx, start, end)
266276
if err != nil {
267277
return fmt.Errorf("cannot obtain tenant IDs: %w", err)
268278
}
269279

280+
sort.Slice(tenantIDs, func(i, j int) bool {
281+
if tenantIDs[i].AccountID != tenantIDs[j].AccountID {
282+
return tenantIDs[i].AccountID < tenantIDs[j].AccountID
283+
}
284+
return tenantIDs[i].ProjectID < tenantIDs[j].ProjectID
285+
})
286+
270287
tids, err := json.Marshal(tenantIDs)
271288
if err != nil {
272289
return fmt.Errorf("cannot marshal tenant IDs: %w", err)
273290
}
274291

275-
return writeTenantIDs(w, tids, false)
292+
return writeTenantIDs(w, tids, disableCompression)
276293
}
277294

278295
type commonParams struct {

app/vlselect/logsql/tenants_response.qtpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TenantsResponse generates response for /admin/tenants .
1010
"status":"success",
1111
"data":[
1212
{% for i, tenant := range tenants %}
13-
{%d int(tenant.AccountID) %}:{%d int(tenant.ProjectID) %}
13+
"{%d int(tenant.AccountID) %}:{%d int(tenant.ProjectID) %}"
1414
{% if i+1 < len(tenants) %},{% endif %}
1515
{% endfor %}
1616
]

app/vlselect/logsql/tenants_response.qtpl.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/vlstorage/netselect/netselect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,13 @@ func (s *Storage) getTenantIDs(ctx context.Context, start, end int64) ([]logstor
450450

451451
unique := make(map[logstorage.TenantID]struct{}, len(results))
452452
for i := range results {
453-
var tenats []logstorage.TenantID
454-
if err := json.Unmarshal(results[i], &tenats); err != nil {
453+
var tenants []logstorage.TenantID
454+
if err := json.Unmarshal(results[i], &tenants); err != nil {
455455
return nil, fmt.Errorf("cannot unmarshal tenantIDs from storage node %d: %w", i, err)
456456
}
457457
// Deduplicate tenantIDs
458-
for _, tenat := range tenats {
459-
unique[tenat] = struct{}{}
458+
for _, tenant := range tenants {
459+
unique[tenant] = struct{}{}
460460
}
461461
}
462462

lib/logstorage/indexdb_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func TestStorageSearchStreamIDs(t *testing.T) {
254254
closeTestStorage(s)
255255
}
256256

257-
func TestGetTenantsIds(t *testing.T) {
257+
func TestGetTenantsIDs(t *testing.T) {
258258
t.Parallel()
259259

260260
path := t.Name()

0 commit comments

Comments
 (0)