Using default priority weight if not specified (#7954)

## What changed?
- Using default priority weight if not specified

## Why?
- In case new priority levels got introduced and break existing things

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
This commit is contained in:
Yichao Yang
2025-06-24 18:24:48 -07:00
committed by GitHub
parent aef2846046
commit 783def0876
2 changed files with 12 additions and 1 deletions

View File

@@ -7,6 +7,8 @@ import (
)
var (
DefaultPriorityWeight = 1
DefaultActiveTaskPriorityWeight = map[tasks.Priority]int{
tasks.PriorityHigh: 10,
tasks.PriorityLow: 9,

View File

@@ -106,10 +106,19 @@ func NewScheduler(
)
}
return configs.ConvertDynamicConfigValueToWeights(
weight, ok := configs.ConvertDynamicConfigValueToWeights(
namespaceWeights(namespaceName.String()),
logger,
)[key.Priority]
if !ok || weight <= 0 {
logger.Warn("Task priority weight not specified or is invalid, using default weight",
tag.TaskPriority(key.Priority.String()),
tag.NewInt("priority-weight", weight),
tag.NewInt("default-weight", configs.DefaultPriorityWeight),
)
weight = configs.DefaultPriorityWeight
}
return weight
}
channelWeightUpdateCh := make(chan struct{}, 1)
fifoSchedulerOptions := &tasks.FIFOSchedulerOptions{