diff --git a/livelog.go b/livelog.go index e36fce74..0447f826 100644 --- a/livelog.go +++ b/livelog.go @@ -154,7 +154,8 @@ func (l *LiveLogTask) reinstateBackingLog() { } func (l *LiveLogTask) uploadLiveLog() error { - maxRunTimeDeadline := l.task.LocalClaimTime.Add(time.Duration(l.task.Payload.MaxRunTime) * time.Second) + // add an extra 15 minutes, to adequately cover client/server clock drift or task initialisation delays + maxRunTimeDeadline := time.Now().Add(time.Duration(l.task.Payload.MaxRunTime+900) * time.Second) // deduce stateless DNS name to use statelessHostname := hostname.New(config.PublicIP, config.Subdomain, maxRunTimeDeadline, config.LiveLogSecret) getURL, err := url.Parse(l.liveLog.GetURL) diff --git a/main.go b/main.go index 6521892f..8989f61f 100644 --- a/main.go +++ b/main.go @@ -1046,8 +1046,7 @@ func (task *TaskRun) resolve(e *ExecutionErrors) *CommandExecutionError { func (task *TaskRun) setMaxRunTimer() *time.Timer { return time.AfterFunc( - // Round(0) forces wall time calculation instead of monotonic time in case machine slept etc - task.maxRunTimeDeadline.Round(0).Sub(time.Now()), + time.Second*time.Duration(task.Payload.MaxRunTime), func() { // ignore any error the Abort function returns - we are in the // wrong go routine to properly handle it @@ -1141,8 +1140,6 @@ func (task *TaskRun) Run() (err *ExecutionErrors) { log.Printf("Running task https://tools.taskcluster.net/task-inspector/#%v/%v", task.TaskID, task.RunID) task.Commands = make([]*process.Command, len(task.Payload.Command)) - // need to include deadline in commands, so need to set it already here - task.maxRunTimeDeadline = time.Now().Add(time.Second * time.Duration(task.Payload.MaxRunTime)) // generate commands, in case features want to modify them for i := range task.Payload.Command { err := task.generateCommand(i) // platform specific diff --git a/model.go b/model.go index fe945479..558fd98d 100644 --- a/model.go +++ b/model.go @@ -25,13 +25,12 @@ type ( Status TaskStatus `json:"-"` Commands []*process.Command `json:"-"` // not exported - logMux sync.RWMutex - logWriter io.Writer - maxRunTimeDeadline time.Time - queueMux sync.RWMutex - Queue *tcqueue.Queue `json:"-"` - StatusManager *TaskStatusManager `json:"-"` - LocalClaimTime time.Time `json:"-"` + logMux sync.RWMutex + logWriter io.Writer + queueMux sync.RWMutex + Queue *tcqueue.Queue `json:"-"` + StatusManager *TaskStatusManager `json:"-"` + LocalClaimTime time.Time `json:"-"` // PlatformData contains platform-specific data related to the // execution environment, such as access tokens on Windows PlatformData *PlatformData `json:"-"`