mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
sysbatch: fix panic from reschedule block (#26534)
* fix panic from nil ReschedulePolicy
commit 279775082c (pr #26279)
intended to return an error for sysbatch jobs with a reschedule block,
but in bypassing populating the `ReschedulePolicy`'s pointer fields,
a nil pointer panic occurred before the job could get rejected
with the intended error.
in particular, in `command/agent/job_endpoint.go`, `func ApiTgToStructsTG`,
```
if taskGroup.ReschedulePolicy != nil {
tg.ReschedulePolicy = &structs.ReschedulePolicy{
Attempts: *taskGroup.ReschedulePolicy.Attempts,
Interval: *taskGroup.ReschedulePolicy.Interval,
```
`*taskGroup.ReschedulePolicy.Interval` was a nil pointer.
* fix e2e test jobs
This commit is contained in:
@@ -202,7 +202,7 @@ func (r *ReschedulePolicy) Merge(rp *ReschedulePolicy) {
|
||||
}
|
||||
|
||||
func (r *ReschedulePolicy) Canonicalize(jobType string) {
|
||||
if r == nil || jobType == JobTypeSystem || jobType == JobTypeSysbatch {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
dp := NewDefaultReschedulePolicy(jobType)
|
||||
@@ -289,6 +289,8 @@ func NewDefaultReschedulePolicy(jobType string) *ReschedulePolicy {
|
||||
// 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
|
||||
// the canonicalization runs without panicking.
|
||||
// This also applies to batch/sysbatch jobs, which do not reschedule;
|
||||
// we still want to return a safe object.
|
||||
dp = &ReschedulePolicy{
|
||||
Attempts: pointerOf(0),
|
||||
Interval: pointerOf(time.Duration(0)),
|
||||
|
||||
Reference in New Issue
Block a user