Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 79272ef

Browse files
authored
fix(backend): add PR name substitution for scheduled runs. (#1344)
Signed-off-by: Humair Khan <HumairAK@users.noreply.github.com>
1 parent 84f2a85 commit 79272ef

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

backend/src/crd/controller/scheduledworkflow/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ func (c *Controller) submitNewWorkflowIfNotAlreadySubmitted(
504504
}
505505

506506
// If the workflow is not found, we need to create it.
507-
newWorkflow, err := swf.NewWorkflow(nextScheduledEpoch, nowEpoch)
507+
newWorkflow, err := swf.NewWorkflow(nextScheduledEpoch, nowEpoch, workflowName)
508508
createdWorkflow, err := c.workflowClient.Create(ctx, swf.Namespace, newWorkflow)
509509
if err != nil {
510510
return false, "", err

backend/src/crd/controller/scheduledworkflow/util/scheduled_workflow.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package util
1616

1717
import (
1818
"fmt"
19+
"github.com/pkg/errors"
1920
"hash/fnv"
2021
"math"
2122
"sort"
@@ -152,7 +153,7 @@ func (s *ScheduledWorkflow) getWorkflowParametersAsMap() map[string]string {
152153
// the appropriate OwnerReferences on the resource so handleObject can discover
153154
// the Schedule resource that 'owns' it.
154155
func (s *ScheduledWorkflow) NewWorkflow(
155-
nextScheduledEpoch int64, nowEpoch int64) (*commonutil.Workflow, error) {
156+
nextScheduledEpoch int64, nowEpoch int64, workflowName string) (*commonutil.Workflow, error) {
156157

157158
const (
158159
workflowKind = "PipelineRun"
@@ -185,6 +186,12 @@ func (s *ScheduledWorkflow) NewWorkflow(
185186
result.OverrideParameters(formattedParams)
186187

187188
result.SetCannonicalLabels(s.Name, nextScheduledEpoch, s.nextIndex())
189+
result.SetLabels(commonutil.LabelOriginalPipelineRunName, workflowName)
190+
err = result.ReplaceOrignalPipelineRunName(workflow.Name)
191+
if err != nil {
192+
return nil, errors.Wrap(err, "Failed to replace workflow original pipelineRun name")
193+
}
194+
188195
// Pod pipeline/runid label is used by v2 compatible mode.
189196
result.SetLabels(commonutil.LabelKeyWorkflowRunId, uuid.String())
190197
// Replace {{workflow.uid}} with runId

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ require (
3636
github.com/tidwall/pretty v1.1.0 // indirect
3737
go.uber.org/zap v1.24.0
3838
golang.org/x/net v0.11.0
39+
google.golang.org/api v0.128.0
3940
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc
4041
google.golang.org/grpc v1.56.2
4142
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0

go.sum

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)