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:
20
api/tasks.go
20
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)
|
||||
}
|
||||
g.ReschedulePolicy.Canonicalize(*job.Type)
|
||||
|
||||
// Merge the migrate strategy from the job
|
||||
if jm, tm := job.Migrate != nil, g.Migrate != nil; jm && tm {
|
||||
|
||||
Reference in New Issue
Block a user