mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #4151 from lengrongfu/fix/scheudle-validate
fix scheduler validate
This commit is contained in:
@@ -383,8 +383,10 @@ func scheduler(config *configs.Config) error {
|
||||
if s.Policy == "" {
|
||||
return errors.New("scheduler policy is required")
|
||||
}
|
||||
if s.Nice < -20 || s.Nice > 19 {
|
||||
return fmt.Errorf("invalid scheduler.nice: %d", s.Nice)
|
||||
if s.Policy == specs.SchedOther || s.Policy == specs.SchedBatch {
|
||||
if s.Nice < -20 || s.Nice > 19 {
|
||||
return fmt.Errorf("invalid scheduler.nice: %d when scheduler.policy is %s", s.Nice, string(s.Policy))
|
||||
}
|
||||
}
|
||||
if s.Priority != 0 && (s.Policy != specs.SchedFIFO && s.Policy != specs.SchedRR) {
|
||||
return errors.New("scheduler.priority can only be specified for SchedFIFO or SchedRR policy")
|
||||
|
||||
@@ -814,6 +814,9 @@ func TestValidateScheduler(t *testing.T) {
|
||||
{isErr: false, policy: "SCHED_DEADLINE", runtime: 200},
|
||||
{isErr: false, policy: "SCHED_DEADLINE", deadline: 300},
|
||||
{isErr: false, policy: "SCHED_DEADLINE", period: 400},
|
||||
{isErr: true, policy: "SCHED_OTHER", niceValue: 20},
|
||||
{isErr: true, policy: "SCHED_OTHER", niceValue: -21},
|
||||
{isErr: false, policy: "SCHED_FIFO", priority: 100, niceValue: 100},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user