From c8794edd0332f65cbde3efd34e1f0b437f5adde3 Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Sat, 8 Mar 2025 18:25:44 +0100 Subject: [PATCH 1/6] pass billing owner id between run service calls --- actionsrunner/runner.go | 6 ++++-- actionsrunner/worker_context.go | 9 +++++---- protocol/misc.go | 1 + protocol/run/contracts.go | 18 ++++++++++-------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/actionsrunner/runner.go b/actionsrunner/runner.go index b6af2b7..6350815 100644 --- a/actionsrunner/runner.go +++ b/actionsrunner/runner.go @@ -401,6 +401,7 @@ type RunnerJobRequestRef struct { Id string `json:"id"` RunnerRequestId string `json:"runner_request_id"` RunServiceUrl string `json:"run_service_url"` + BillingOwnerId string `json:"billing_owner_id,omitempty"` } type plainTextFormatter struct { @@ -454,8 +455,9 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro acquirejobUrl.Path = path.Join(acquirejobUrl.Path, "acquirejob") vssConnection.TenantURL = runServiceUrl payload := &runservice.AcquireJobRequest{ - StreamID: rjrr.RunnerRequestId, - JobMessageID: rjrr.RunnerRequestId, + StreamID: rjrr.RunnerRequestId, + JobMessageID: rjrr.RunnerRequestId, + BillingOwnerId: rjrr.BillingOwnerId, } err = vssConnection.RequestWithContext2(jobctx, "POST", acquirejobUrl.String(), "", payload, &src) } diff --git a/actionsrunner/worker_context.go b/actionsrunner/worker_context.go index c9fd131..d1852ec 100644 --- a/actionsrunner/worker_context.go +++ b/actionsrunner/worker_context.go @@ -31,10 +31,11 @@ type DefaultWorkerContext struct { func (wc *DefaultWorkerContext) FinishJob(result string, outputs *map[string]protocol.VariableValue) { if strings.EqualFold(wc.Message().MessageType, "RunnerJobRequest") { payload := &run.CompleteJobRequest{ - PlanID: wc.Message().Plan.PlanID, - JobID: wc.Message().JobID, - Conclusion: strings.ToLower(result), - Outputs: nil, + PlanID: wc.Message().Plan.PlanID, + JobID: wc.Message().JobID, + Conclusion: strings.ToLower(result), + Outputs: nil, + BillingOwnerId: wc.Message().BillingOwnerId, } if outputs != nil { payload.Outputs = *outputs diff --git a/protocol/misc.go b/protocol/misc.go index 500921a..31723be 100644 --- a/protocol/misc.go +++ b/protocol/misc.go @@ -104,6 +104,7 @@ type AgentJobRequestMessage struct { Variables map[string]VariableValue Steps []ActionStep FileTable []string + BillingOwnerId string `json:"billingOwnerId,omitempty"` } func (jobreq *AgentJobRequestMessage) GetConnection(name string) (*VssConnection, map[string]string, error) { diff --git a/protocol/run/contracts.go b/protocol/run/contracts.go index 25047e9..6f88ec4 100644 --- a/protocol/run/contracts.go +++ b/protocol/run/contracts.go @@ -9,17 +9,19 @@ import ( ) type AcquireJobRequest struct { - StreamID string `json:"streamId,omitempty"` // Deprecated: https://github.com/actions/runner/pull/2547 - JobMessageID string `json:"jobMessageId"` + StreamID string `json:"streamId,omitempty"` // Deprecated: https://github.com/actions/runner/pull/2547 + JobMessageID string `json:"jobMessageId"` + BillingOwnerId string `json:"billingOwnerId,omitempty"` } type CompleteJobRequest struct { - PlanID string `json:"planId,omitempty"` - JobID string `json:"jobId,omitempty"` - Conclusion string `json:"conclusion"` - Outputs map[string]protocol.VariableValue `json:"outputs,omitempty"` - StepResults []StepResult `json:"stepResults,omitempty"` - Annotations []Annotation `json:"annotations,omitempty"` + PlanID string `json:"planId,omitempty"` + JobID string `json:"jobId,omitempty"` + Conclusion string `json:"conclusion"` + Outputs map[string]protocol.VariableValue `json:"outputs,omitempty"` + StepResults []StepResult `json:"stepResults,omitempty"` + Annotations []Annotation `json:"annotations,omitempty"` + BillingOwnerId string `json:"billingOwnerId,omitempty"` } type RenewJobRequest struct { From e5243ffb770c7eabef5fedbb501ec4a0e8194e37 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Thu, 21 Aug 2025 00:13:01 +0200 Subject: [PATCH 2/6] Update misc.go --- protocol/misc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/misc.go b/protocol/misc.go index b528232..3b8b0fc 100644 --- a/protocol/misc.go +++ b/protocol/misc.go @@ -105,7 +105,7 @@ type AgentJobRequestMessage struct { Variables map[string]VariableValue Steps []ActionStep FileTable []string - BillingOwnerId string `json:"billingOwnerId,omitempty"` + BillingOwnerID string `json:"billingOwnerId,omitempty"` } func (jobreq *AgentJobRequestMessage) GetConnection(name string) (*VssConnection, map[string]string, error) { From 335b82e1af536d1b146bfe4269f8f763871025b0 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Thu, 21 Aug 2025 00:13:19 +0200 Subject: [PATCH 3/6] Update contracts.go --- protocol/run/contracts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/run/contracts.go b/protocol/run/contracts.go index ae640d7..098a24f 100644 --- a/protocol/run/contracts.go +++ b/protocol/run/contracts.go @@ -21,7 +21,7 @@ type CompleteJobRequest struct { Outputs map[string]protocol.VariableValue `json:"outputs,omitempty"` StepResults []StepResult `json:"stepResults,omitempty"` Annotations []Annotation `json:"annotations,omitempty"` - BillingOwnerId string `json:"billingOwnerId,omitempty"` + BillingOwnerID string `json:"billingOwnerId,omitempty"` } type RenewJobRequest struct { From 6bd0a90a29d838adce1b41c17f41af73f8309711 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Thu, 21 Aug 2025 00:13:39 +0200 Subject: [PATCH 4/6] Update contracts.go --- protocol/run/contracts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/run/contracts.go b/protocol/run/contracts.go index 098a24f..d75518f 100644 --- a/protocol/run/contracts.go +++ b/protocol/run/contracts.go @@ -11,7 +11,7 @@ import ( type AcquireJobRequest struct { StreamID string `json:"streamId,omitempty"` // Deprecated: https://github.com/actions/runner/pull/2547 JobMessageID string `json:"jobMessageId"` - BillingOwnerId string `json:"billingOwnerId,omitempty"` + BillingOwnerID string `json:"billingOwnerId,omitempty"` } type CompleteJobRequest struct { From e54d33fa262279c64e1e759096642c1aa0ba9f82 Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Thu, 21 Aug 2025 00:14:26 +0200 Subject: [PATCH 5/6] Update worker_context.go --- actionsrunner/worker_context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionsrunner/worker_context.go b/actionsrunner/worker_context.go index 4ef3f30..9cba70a 100644 --- a/actionsrunner/worker_context.go +++ b/actionsrunner/worker_context.go @@ -44,7 +44,7 @@ func (wc *DefaultWorkerContext) FinishJob(result string, outputs *map[string]pro JobID: wc.Message().JobID, Conclusion: strings.ToLower(result), Outputs: nil, - BillingOwnerId: wc.Message().BillingOwnerId, + BillingOwnerID: wc.Message().BillingOwnerID, } if outputs != nil { payload.Outputs = *outputs From 6d8f4a4322126d416c7ab38ba5f4315185a8d6fa Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Thu, 21 Aug 2025 00:16:57 +0200 Subject: [PATCH 6/6] Update runner.go --- actionsrunner/runner.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionsrunner/runner.go b/actionsrunner/runner.go index 06cee7c..d6960dd 100644 --- a/actionsrunner/runner.go +++ b/actionsrunner/runner.go @@ -494,8 +494,8 @@ func runJob(runnerenv RunnerEnvironment, joblock *sync.Mutex, vssConnection *pro acquirejobURL.Path = path.Join(acquirejobURL.Path, "acquirejob") vssConnection.TenantURL = runServiceURL payload := &runservice.AcquireJobRequest{ - StreamID: rjrr.RunnerRequestID, - JobMessageID: rjrr.RunnerRequestID, + StreamID: rjrr.RunnerRequestID, + JobMessageID: rjrr.RunnerRequestID, BillingOwnerID: rjrr.BillingOwnerID, } requestErr = vssConnection.RequestWithContext2(jobctx, "POST", acquirejobURL.String(), "", payload, &src)