-
Notifications
You must be signed in to change notification settings - Fork 1.9k
don't validate skipped task results for pipeline results #6157
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "strings" | ||
|
|
||
| "github.com/tektoncd/pipeline/pkg/apis/config" | ||
|
|
||
| "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" | ||
| "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" | ||
| "github.com/tektoncd/pipeline/pkg/substitution" | ||
|
|
@@ -313,11 +314,18 @@ func replaceParamValues(params []v1beta1.Param, stringReplacements map[string]st | |
| // and omitted from the returned slice. A nil slice is returned if no results are passed in or all | ||
| // results are invalid. | ||
| func ApplyTaskResultsToPipelineResults( | ||
| ctx context.Context, | ||
| results []v1beta1.PipelineResult, | ||
| taskRunResults map[string][]v1beta1.TaskRunResult, | ||
| customTaskResults map[string][]v1beta1.CustomRunResult) ([]v1beta1.PipelineRunResult, error) { | ||
| customTaskResults map[string][]v1beta1.CustomRunResult, | ||
| skippedTasks []v1beta1.SkippedTask) ([]v1beta1.PipelineRunResult, error) { | ||
| var runResults []v1beta1.PipelineRunResult | ||
| var invalidPipelineResults []string | ||
| skippedTaskNames := map[string]bool{} | ||
| for _, t := range skippedTasks { | ||
| skippedTaskNames[t.Name] = true | ||
| } | ||
|
|
||
| stringReplacements := map[string]string{} | ||
| arrayReplacements := map[string][]string{} | ||
| objectReplacements := map[string]map[string]string{} | ||
|
|
@@ -338,6 +346,11 @@ func ApplyTaskResultsToPipelineResults( | |
| continue | ||
| } | ||
| variableParts := strings.Split(variable, ".") | ||
| // if the referenced task is skipped, we should also skip the results replacements | ||
| if _, ok := skippedTaskNames[variableParts[1]]; ok { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not something to be changed in this PR, but I wonder if having constants for the various indexes of parts and a function for the split would make this code more readable? Like, variableParts := splitResultVariable(variable)
skippedTaskNames[variableParts[VARIABLE_RESULT_TASK_NAME_INDEX]]
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense, I can fix this |
||
| validPipelineResult = false | ||
| continue | ||
| } | ||
| if (variableParts[0] != v1beta1.ResultTaskPart && variableParts[0] != v1beta1.ResultFinallyPart) || variableParts[2] != v1beta1.ResultResultPart { | ||
| validPipelineResult = false | ||
| invalidPipelineResults = append(invalidPipelineResults, pipelineResult.Name) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we please add a log message or something to communicate to users that a pipelineresult references a skipped taskresult so the value cannot be substituted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a log message when we skip the skipped task result reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controller log file won't typically be accessible by users, and having a log entry in the "info" level about this feels like something that might spam logs if users often skipped tasks. I would rather have a debug log level here.
If we want to let users know about this, perhaps we could replace the result reference (or extend it) with a comment, saying that the result is not available as the task was skipped, but I'm not sure if that'd be a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yongxuanzhang any update on this? I still see an info-level log message on L352
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry I missed your comment! @afrittoli
I will change this to debug level log.