Skip to content

Commit

Permalink
Merge pull request #13652 from hashicorp/backport-min-fix-1.2.x
Browse files Browse the repository at this point in the history
client: cannot use generic Min func in backport
  • Loading branch information
shoenig authored Jul 8, 2022
2 parents 70587d6 + cf1f809 commit 17649ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 7 additions & 2 deletions client/allocrunner/taskrunner/driver_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/drivers"
)
Expand All @@ -18,12 +17,18 @@ func NewDriverHandle(
task *structs.Task,
maxKillTimeout time.Duration,
net *drivers.DriverNetwork) *DriverHandle {

timeout := task.KillTimeout
if maxKillTimeout < timeout {
timeout = maxKillTimeout
}

return &DriverHandle{
driver: driver,
net: net,
taskID: taskID,
killSignal: task.KillSignal,
killTimeout: helper.Min(task.KillTimeout, maxKillTimeout),
killTimeout: timeout,
}
}

Expand Down
10 changes: 7 additions & 3 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8222,9 +8222,13 @@ func (e *TaskEvent) SetValidationError(err error) *TaskEvent {
}

func (e *TaskEvent) SetKillTimeout(timeout, maxTimeout time.Duration) *TaskEvent {
actual := helper.Min(timeout, maxTimeout)
e.KillTimeout = actual
e.Details["kill_timeout"] = actual.String()
lower := timeout
if maxTimeout < lower {
lower = maxTimeout
}

e.KillTimeout = lower
e.Details["kill_timeout"] = lower.String()
return e
}

Expand Down

0 comments on commit 17649ee

Please sign in to comment.