app/vminsert: allow parsing tenant id from (#4144)

VictoriaMetrics_ProjectID and VictoriaMetrics_AccountID labels.
It should help to migrate for new labels vm_account_id vm_project_id without service downtime
This commit is contained in:
Nikolay 2023-05-16 17:16:37 +02:00 committed by GitHub
parent 9461d3fdfa
commit 5514b5d552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -204,13 +204,19 @@ func (ctx *InsertCtx) GetLocalAuthToken(at *auth.Token) *auth.Token {
projectID := uint32(0) projectID := uint32(0)
tmpLabels := ctx.Labels[:0] tmpLabels := ctx.Labels[:0]
for _, label := range ctx.Labels { for _, label := range ctx.Labels {
if string(label.Name) == "vm_account_id" { switch string(label.Name) {
case "vm_account_id":
accountID = parseUint32(label.Value) accountID = parseUint32(label.Value)
continue continue
} case "vm_project_id":
if string(label.Name) == "vm_project_id" {
projectID = parseUint32(label.Value) projectID = parseUint32(label.Value)
continue continue
// do not remove labels from labelSet for backward-compatibility
// previous realisation kept it
case "VictoriaMetrics_AccountID":
accountID = parseUint32(label.Value)
case "VictoriaMetrics_ProjectID":
projectID = parseUint32(label.Value)
} }
tmpLabels = append(tmpLabels, label) tmpLabels = append(tmpLabels, label)
} }