From 8bcc2bd37f15b96a9bd224ba4ab767946da35e0a Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Thu, 28 Aug 2025 20:37:38 +0200 Subject: [PATCH 1/4] fix: handle renewJob error return values and log them --- actionsrunner/runner.go | 50 ++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/actionsrunner/runner.go b/actionsrunner/runner.go index d6960dd..e60e8da 100644 --- a/actionsrunner/runner.go +++ b/actionsrunner/runner.go @@ -528,27 +528,7 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro con := *vssConnection go func() { for { - var renewErr error - if runServiceURL != "" { - jobVssConnection, _, _ := jobreq.GetConnection("SystemVssConnection") - jobVssConnection.Trace = con.Trace - renewjobURL, _ := url.Parse(runServiceURL) - renewjobURL.Path = path.Join(renewjobURL.Path, "renewjob") - jobVssConnection.TenantURL = runServiceURL - payload := &runservice.RenewJobRequest{ - PlanID: jobreq.Plan.PlanID, - JobID: jobreq.JobID, - } - resp := &runservice.RenewJobResponse{} - renewErr = jobVssConnection.RequestWithContext2(jobctx, "POST", renewjobURL.String(), "", payload, &resp) - } else { - renewErr = con.RequestWithContext(jobctx, "fc825784-c92a-4299-9221-998a02d1b54f", "5.1-preview", "PATCH", map[string]string{ - "poolId": fmt.Sprint(instance.PoolID), - "requestId": fmt.Sprint(jobreq.RequestID), - }, map[string]string{ - "lockToken": "00000000-0000-0000-0000-000000000000", - }, &protocol.RenewAgent{RequestID: jobreq.RequestID}, nil) - } + renewErr := renewJob(jobctx, runServiceURL, jobreq, con, instance) if renewErr != nil { if errors.Is(renewErr, context.Canceled) { return @@ -634,3 +614,31 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro } }() } + +func renewJob(jobctx context.Context, runServiceURL string, jobreq *protocol.AgentJobRequestMessage, con protocol.VssConnection, instance *runnerconfiguration.RunnerInstance) error { + if runServiceURL != "" { + jobVssConnection, _, conErr := jobreq.GetConnection("SystemVssConnection") + if conErr != nil { + return conErr + } + jobVssConnection.Trace = con.Trace + renewjobURL, urlErr := url.Parse(runServiceURL) + if urlErr != nil { + return urlErr + } + renewjobURL.Path = path.Join(renewjobURL.Path, "renewjob") + jobVssConnection.TenantURL = runServiceURL + payload := &runservice.RenewJobRequest{ + PlanID: jobreq.Plan.PlanID, + JobID: jobreq.JobID, + } + resp := &runservice.RenewJobResponse{} + return jobVssConnection.RequestWithContext2(jobctx, "POST", renewjobURL.String(), "", payload, &resp) + } + return con.RequestWithContext(jobctx, "fc825784-c92a-4299-9221-998a02d1b54f", "5.1-preview", "PATCH", map[string]string{ + "poolId": fmt.Sprint(instance.PoolID), + "requestId": fmt.Sprint(jobreq.RequestID), + }, map[string]string{ + "lockToken": "00000000-0000-0000-0000-000000000000", + }, &protocol.RenewAgent{RequestID: jobreq.RequestID}, nil) +} From 28db95976e2ffcc8694cce713e2a7b04840b0d6b Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Thu, 28 Aug 2025 20:55:56 +0200 Subject: [PATCH 2/4] . --- actionsrunner/runner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionsrunner/runner.go b/actionsrunner/runner.go index e60e8da..2dba2ee 100644 --- a/actionsrunner/runner.go +++ b/actionsrunner/runner.go @@ -528,7 +528,7 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro con := *vssConnection go func() { for { - renewErr := renewJob(jobctx, runServiceURL, jobreq, con, instance) + renewErr := renewJob(jobctx, runServiceURL, jobreq, &con, instance) if renewErr != nil { if errors.Is(renewErr, context.Canceled) { return @@ -615,7 +615,7 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro }() } -func renewJob(jobctx context.Context, runServiceURL string, jobreq *protocol.AgentJobRequestMessage, con protocol.VssConnection, instance *runnerconfiguration.RunnerInstance) error { +func renewJob(jobctx context.Context, runServiceURL string, jobreq *protocol.AgentJobRequestMessage, con *protocol.VssConnection, instance *runnerconfiguration.RunnerInstance) error { if runServiceURL != "" { jobVssConnection, _, conErr := jobreq.GetConnection("SystemVssConnection") if conErr != nil { From ab7aa34140aeb2ae887e34431e79959d88a0f897 Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Thu, 28 Aug 2025 20:58:56 +0200 Subject: [PATCH 3/4] . --- actionsrunner/runner.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actionsrunner/runner.go b/actionsrunner/runner.go index 2dba2ee..2e38580 100644 --- a/actionsrunner/runner.go +++ b/actionsrunner/runner.go @@ -615,7 +615,8 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro }() } -func renewJob(jobctx context.Context, runServiceURL string, jobreq *protocol.AgentJobRequestMessage, con *protocol.VssConnection, instance *runnerconfiguration.RunnerInstance) error { +func renewJob(jobctx context.Context, runServiceURL string, jobreq *protocol.AgentJobRequestMessage, + con *protocol.VssConnection, instance *runnerconfiguration.RunnerInstance) error { if runServiceURL != "" { jobVssConnection, _, conErr := jobreq.GetConnection("SystemVssConnection") if conErr != nil { From 261efcfb9b70806b0fb1f4bc52c4e73f07bd04d8 Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Thu, 28 Aug 2025 21:02:36 +0200 Subject: [PATCH 4/4] . --- actionsrunner/runner.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actionsrunner/runner.go b/actionsrunner/runner.go index 2e38580..3d02d9e 100644 --- a/actionsrunner/runner.go +++ b/actionsrunner/runner.go @@ -616,7 +616,8 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro } func renewJob(jobctx context.Context, runServiceURL string, jobreq *protocol.AgentJobRequestMessage, - con *protocol.VssConnection, instance *runnerconfiguration.RunnerInstance) error { + con *protocol.VssConnection, instance *runnerconfiguration.RunnerInstance, +) error { if runServiceURL != "" { jobVssConnection, _, conErr := jobreq.GetConnection("SystemVssConnection") if conErr != nil {