Skip to content

Commit

Permalink
Add role states in walle_status_description in cms
Browse files Browse the repository at this point in the history
765fc5287a82f0295eff3f39559f13f0b187f4e4
  • Loading branch information
aausmanov committed Aug 20, 2024
1 parent b422c9b commit ec7a24c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/cms/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package cms

import (
"context"
"strings"

"go.ytsaurus.tech/library/go/ptr"
"go.ytsaurus.tech/yt/admin/cms/internal/models"
"go.ytsaurus.tech/yt/go/ypath"
"go.ytsaurus.tech/yt/go/yt"
"go.ytsaurus.tech/yt/go/ytsys"
)
Expand Down Expand Up @@ -137,3 +139,11 @@ func markNodeDecommissioned(
}
return dc.MarkNodeDecommissioned(ctx, node.Addr, decommisionMsg)
}

func getPodIDFromYPath(path ypath.Path) string {
pathSplit := strings.Split(path.String(), "/")
addr := pathSplit[len(pathSplit)-1]
shortAddr := strings.Split(addr, ".")[0]

return shortAddr
}
18 changes: 18 additions & 0 deletions internal/cms/task_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cms

import (
"context"
"fmt"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -1084,6 +1085,11 @@ func (p *TaskProcessor) processTask(ctx context.Context, t *models.Task) {
p.processHost(taskCtx, t.HostStates[h])
}

if desc := p.generateWalleDescription(t); t.WalleStatusDescription != desc {
t.WalleStatusDescription = desc
p.tryUpdateTaskInStorage(ctx, t)
}

// Update task state in storage.
if t.AllHostsFinished() {
t.SetFinished()
Expand Down Expand Up @@ -1352,3 +1358,15 @@ func (p *TaskProcessor) hasTaskUpgrade(t *models.Task) bool {
func IsNOCTask(t *models.Task) bool {
return t.IsGroupTask && t.Action == walle.ActionTemporaryUnreachable
}

func (p *TaskProcessor) generateWalleDescription(t *models.Task) string {
var desc []string

for _, h := range t.HostStates {
for path, r := range h.Roles {
desc = append(desc, fmt.Sprintf("%s: %s", getPodIDFromYPath(path), r.GetState()))
}
}

return strings.Join(desc, " | ")
}

0 comments on commit ec7a24c

Please sign in to comment.