Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): add PR name substitution for scheduled runs. #1344

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/crd/controller/scheduledworkflow/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (c *Controller) submitNewWorkflowIfNotAlreadySubmitted(
}

// If the workflow is not found, we need to create it.
newWorkflow, err := swf.NewWorkflow(nextScheduledEpoch, nowEpoch)
newWorkflow, err := swf.NewWorkflow(nextScheduledEpoch, nowEpoch, workflowName)
createdWorkflow, err := c.workflowClient.Create(ctx, swf.Namespace, newWorkflow)
if err != nil {
return false, "", err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package util

import (
"fmt"
"github.com/pkg/errors"
"hash/fnv"
"math"
"sort"
Expand Down Expand Up @@ -152,7 +153,7 @@ func (s *ScheduledWorkflow) getWorkflowParametersAsMap() map[string]string {
// the appropriate OwnerReferences on the resource so handleObject can discover
// the Schedule resource that 'owns' it.
func (s *ScheduledWorkflow) NewWorkflow(
nextScheduledEpoch int64, nowEpoch int64) (*commonutil.Workflow, error) {
nextScheduledEpoch int64, nowEpoch int64, workflowName string) (*commonutil.Workflow, error) {

const (
workflowKind = "PipelineRun"
Expand Down Expand Up @@ -185,6 +186,12 @@ func (s *ScheduledWorkflow) NewWorkflow(
result.OverrideParameters(formattedParams)

result.SetCannonicalLabels(s.Name, nextScheduledEpoch, s.nextIndex())
result.SetLabels(commonutil.LabelOriginalPipelineRunName, workflowName)
err = result.ReplaceOrignalPipelineRunName(workflow.Name)
if err != nil {
return nil, errors.Wrap(err, "Failed to replace workflow original pipelineRun name")
}

// Pod pipeline/runid label is used by v2 compatible mode.
result.SetLabels(commonutil.LabelKeyWorkflowRunId, uuid.String())
// Replace {{workflow.uid}} with runId
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require (
github.com/tidwall/pretty v1.1.0 // indirect
go.uber.org/zap v1.24.0
golang.org/x/net v0.11.0
google.golang.org/api v0.128.0
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc
google.golang.org/grpc v1.56.2
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading