mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
sysbatch: correctly validate that reschedule policy is not allowed (#26279)
System and sysbatch jobs don't support the reschedule block, because we'd always replace allocations back onto the same node. The job validation for system jobs asserts that the user hasn't set a `reschedule` block so that users aren't submitting jobs expecting it to be supported. But this validation was missing for sysbatch jobs. Validate that sysbatch jobs don't have a reschedule block.
This commit is contained in:
3
.changelog/26279.txt
Normal file
3
.changelog/26279.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:breaking-change
|
||||
sysbatch: Submitting a sysbatch job with a `reschedule` block will now return an error instead of being silently ignored
|
||||
```
|
||||
18
api/tasks.go
18
api/tasks.go
@@ -202,6 +202,9 @@ func (r *ReschedulePolicy) Merge(rp *ReschedulePolicy) {
|
||||
}
|
||||
|
||||
func (r *ReschedulePolicy) Canonicalize(jobType string) {
|
||||
if r == nil || jobType == JobTypeSystem || jobType == JobTypeSysbatch {
|
||||
return
|
||||
}
|
||||
dp := NewDefaultReschedulePolicy(jobType)
|
||||
if r.Interval == nil {
|
||||
r.Interval = dp.Interval
|
||||
@@ -282,16 +285,6 @@ func NewDefaultReschedulePolicy(jobType string) *ReschedulePolicy {
|
||||
Unlimited: pointerOf(false),
|
||||
}
|
||||
|
||||
case "system":
|
||||
dp = &ReschedulePolicy{
|
||||
Attempts: pointerOf(0),
|
||||
Interval: pointerOf(time.Duration(0)),
|
||||
Delay: pointerOf(time.Duration(0)),
|
||||
DelayFunction: pointerOf(""),
|
||||
MaxDelay: pointerOf(time.Duration(0)),
|
||||
Unlimited: pointerOf(false),
|
||||
}
|
||||
|
||||
default:
|
||||
// GH-7203: it is possible an unknown job type is passed to this
|
||||
// function and we need to ensure a non-nil object is returned so that
|
||||
@@ -583,13 +576,10 @@ func (g *TaskGroup) Canonicalize(job *Job) {
|
||||
jobReschedule := job.Reschedule.Copy()
|
||||
g.ReschedulePolicy = jobReschedule
|
||||
}
|
||||
// Only use default reschedule policy for non system jobs
|
||||
if g.ReschedulePolicy == nil && *job.Type != "system" {
|
||||
if g.ReschedulePolicy == nil && *job.Type != JobTypeSysbatch && *job.Type != JobTypeSystem {
|
||||
g.ReschedulePolicy = NewDefaultReschedulePolicy(*job.Type)
|
||||
}
|
||||
if g.ReschedulePolicy != nil {
|
||||
g.ReschedulePolicy.Canonicalize(*job.Type)
|
||||
}
|
||||
|
||||
// Merge the migrate strategy from the job
|
||||
if jm, tm := job.Migrate != nil, g.Migrate != nil; jm && tm {
|
||||
|
||||
@@ -7112,9 +7112,9 @@ func (tg *TaskGroup) Validate(j *Job) error {
|
||||
}
|
||||
}
|
||||
|
||||
if j.Type == JobTypeSystem {
|
||||
if j.Type == JobTypeSystem || j.Type == JobTypeSysBatch {
|
||||
if tg.ReschedulePolicy != nil {
|
||||
mErr = multierror.Append(mErr, fmt.Errorf("System jobs should not have a reschedule policy"))
|
||||
mErr = multierror.Append(mErr, fmt.Errorf("System or sysbatch jobs should not have a reschedule policy"))
|
||||
}
|
||||
} else {
|
||||
if tg.ReschedulePolicy != nil {
|
||||
|
||||
@@ -1512,7 +1512,7 @@ func TestTaskGroup_Validate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expErr: []string{
|
||||
"System jobs should not have a reschedule policy",
|
||||
"System or sysbatch jobs should not have a reschedule policy",
|
||||
},
|
||||
jobType: JobTypeSystem,
|
||||
},
|
||||
|
||||
@@ -12,6 +12,14 @@ upgrade. However, specific versions of Nomad may have more details provided for
|
||||
their upgrades as a result of new features or changed behavior. This page is
|
||||
used to document those details separately from the standard upgrade flow.
|
||||
|
||||
## Nomad 1.11.0
|
||||
|
||||
#### Sysbatch jobs will no longer accept `reschedule` blocks
|
||||
|
||||
In Nomad 1.11.0, submitting a sysbatch job with a `reschedule` block returns
|
||||
an error instead of being silently ignored, as it was in previous versions. The
|
||||
same behavior applies to system jobs.
|
||||
|
||||
## Nomad 1.10.2
|
||||
|
||||
#### Clients respect `telemetry.publish_allocation_metrics`
|
||||
|
||||
Reference in New Issue
Block a user