Skip to content

Commit

Permalink
[yt/admin/cms] Do not mark tasks urgent for non-noc scenarios.
Browse files Browse the repository at this point in the history
60838d5903bc1877c3341ee2fb7f841631b80629
  • Loading branch information
verytable committed Sep 10, 2024
1 parent 1425718 commit 06f53b3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/models/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ func (t *Task) GetClusterInfo(c Cluster) ClusterInfo {
}

func (t *Task) IsUrgent() bool {
if !t.ScenarioInfo.IsNOCScenario() {
return false
}

if !t.ScenarioInfo.HasMaintenanceStartTime() {
return true
}
Expand Down
16 changes: 16 additions & 0 deletions internal/walle/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ type ScenarioType string
const (
ScenarioTypeITDCMaintenance ScenarioType = "itdc-maintenance"
ScenarioTypeNOCHard ScenarioType = "noc-hard"
ScenarioTypeNOCSoft ScenarioType = "noc-soft"
ScenarioTypeNewNOCSoft ScenarioType = "new-noc-soft"
ScenarioTypeHardwareUpgrade ScenarioType = "hardware-upgrade"
ScenarioTypeHostTransfer ScenarioType = "hosts-transfer"
)

type ScenarioInfo struct {
Expand All @@ -99,6 +103,18 @@ func (i *ScenarioInfo) MaintenanceEnd() time.Time {
return time.Unix(int64(i.MaintenanceEndTime), 0)
}

func (i *ScenarioInfo) IsNOCScenario() bool {
if i == nil {
return false
}
switch i.Type {
case ScenarioTypeNOCHard, ScenarioTypeNOCSoft, ScenarioTypeNewNOCSoft:
return true
default:
return false
}
}

// MaintenanceKind type holds all available maintenance kind values.
type MaintenanceKind = HostAction

Expand Down
41 changes: 41 additions & 0 deletions internal/walle/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,44 @@ func TestAddTasksRequest_yson(t *testing.T) {
})
}
}

func TestScenarioInfo_IsNOCScenario(t *testing.T) {
for _, tc := range []struct {
typ ScenarioType
expected bool
}{
{
typ: ScenarioTypeHardwareUpgrade,
expected: false,
},
{
typ: ScenarioTypeHostTransfer,
expected: false,
},
{
typ: ScenarioTypeITDCMaintenance,
expected: false,
},
{
typ: ScenarioTypeNOCHard,
expected: true,
},
{
typ: ScenarioTypeNOCSoft,
expected: true,
},
{
typ: ScenarioTypeNewNOCSoft,
expected: true,
},
{
typ: ScenarioType("unknown"),
expected: false,
},
} {
t.Run(string(tc.typ), func(t *testing.T) {
i := &ScenarioInfo{Type: tc.typ}
require.Equal(t, tc.expected, i.IsNOCScenario())
})
}
}

0 comments on commit 06f53b3

Please sign in to comment.