Skip to content

Commit 8bcc2bd

Browse files
committed
fix: handle renewJob error return values and log them
1 parent 8998c09 commit 8bcc2bd

1 file changed

Lines changed: 29 additions & 21 deletions

File tree

actionsrunner/runner.go

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -528,27 +528,7 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro
528528
con := *vssConnection
529529
go func() {
530530
for {
531-
var renewErr error
532-
if runServiceURL != "" {
533-
jobVssConnection, _, _ := jobreq.GetConnection("SystemVssConnection")
534-
jobVssConnection.Trace = con.Trace
535-
renewjobURL, _ := url.Parse(runServiceURL)
536-
renewjobURL.Path = path.Join(renewjobURL.Path, "renewjob")
537-
jobVssConnection.TenantURL = runServiceURL
538-
payload := &runservice.RenewJobRequest{
539-
PlanID: jobreq.Plan.PlanID,
540-
JobID: jobreq.JobID,
541-
}
542-
resp := &runservice.RenewJobResponse{}
543-
renewErr = jobVssConnection.RequestWithContext2(jobctx, "POST", renewjobURL.String(), "", payload, &resp)
544-
} else {
545-
renewErr = con.RequestWithContext(jobctx, "fc825784-c92a-4299-9221-998a02d1b54f", "5.1-preview", "PATCH", map[string]string{
546-
"poolId": fmt.Sprint(instance.PoolID),
547-
"requestId": fmt.Sprint(jobreq.RequestID),
548-
}, map[string]string{
549-
"lockToken": "00000000-0000-0000-0000-000000000000",
550-
}, &protocol.RenewAgent{RequestID: jobreq.RequestID}, nil)
551-
}
531+
renewErr := renewJob(jobctx, runServiceURL, jobreq, con, instance)
552532
if renewErr != nil {
553533
if errors.Is(renewErr, context.Canceled) {
554534
return
@@ -634,3 +614,31 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro
634614
}
635615
}()
636616
}
617+
618+
func renewJob(jobctx context.Context, runServiceURL string, jobreq *protocol.AgentJobRequestMessage, con protocol.VssConnection, instance *runnerconfiguration.RunnerInstance) error {
619+
if runServiceURL != "" {
620+
jobVssConnection, _, conErr := jobreq.GetConnection("SystemVssConnection")
621+
if conErr != nil {
622+
return conErr
623+
}
624+
jobVssConnection.Trace = con.Trace
625+
renewjobURL, urlErr := url.Parse(runServiceURL)
626+
if urlErr != nil {
627+
return urlErr
628+
}
629+
renewjobURL.Path = path.Join(renewjobURL.Path, "renewjob")
630+
jobVssConnection.TenantURL = runServiceURL
631+
payload := &runservice.RenewJobRequest{
632+
PlanID: jobreq.Plan.PlanID,
633+
JobID: jobreq.JobID,
634+
}
635+
resp := &runservice.RenewJobResponse{}
636+
return jobVssConnection.RequestWithContext2(jobctx, "POST", renewjobURL.String(), "", payload, &resp)
637+
}
638+
return con.RequestWithContext(jobctx, "fc825784-c92a-4299-9221-998a02d1b54f", "5.1-preview", "PATCH", map[string]string{
639+
"poolId": fmt.Sprint(instance.PoolID),
640+
"requestId": fmt.Sprint(jobreq.RequestID),
641+
}, map[string]string{
642+
"lockToken": "00000000-0000-0000-0000-000000000000",
643+
}, &protocol.RenewAgent{RequestID: jobreq.RequestID}, nil)
644+
}

0 commit comments

Comments
 (0)