-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add SetDefaults for pipelineSpec in reconciler #5176
Add SetDefaults for pipelineSpec in reconciler #5176
Conversation
Skipping CI for Draft Pull Request. |
/kind bug |
The following is the coverage report on the affected files.
|
/retest |
@@ -274,6 +274,10 @@ func ValidateParameterTypes(ctx context.Context, params []ParamSpec) (errs *apis | |||
|
|||
// ValidateType checks that the type of a ParamSpec is allowed and its default value matches that type | |||
func (p ParamSpec) ValidateType() *apis.FieldError { | |||
// For resources not call SetDefaults(), empty type should be valid. |
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.
NIT - suggested comment
A resource may have been created before type was available in
paramSpec
and thus have no type set
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.
couldn't we call SetDefaults() before calling validation instead of just skipping validation?
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.
couldn't we call SetDefaults() before calling validation instead of just skipping validation?
yeah I would prefer this way! I'm testing if that can work
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.
(or at least in this function, we should assume no type == defaultType)
69c4079
to
57025e4
Compare
The following is the coverage report on the affected files.
|
/retest |
@@ -274,6 +274,10 @@ func ValidateParameterTypes(ctx context.Context, params []ParamSpec) (errs *apis | |||
|
|||
// ValidateType checks that the type of a ParamSpec is allowed and its default value matches that type | |||
func (p ParamSpec) ValidateType() *apis.FieldError { | |||
// For resources not call SetDefaults(), empty type should be valid. | |||
if p.Type == "" { |
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 you add a unit test in pipeline reconciler that the param type is null, to make sure this wouldn't introduce any new bugs? Thanks
if err := ts.Validate(context.Background()); err != nil { | ||
t.Errorf("TaskSpec.Validate() = %v", err) | ||
} | ||
}) |
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.
In the test, can we compare the returned v.s. expected error like this example rather than just check if err is nil?
/hold |
It's worth mentioning that when I deleted a problem |
Hi @abayer, kind: Task
apiVersion: tekton.dev/v1beta1
metadata:
name: test-task
spec:
params:
- name: arg
steps:
- name: echo
image: bash:latest
args: ["echo", "$(params.arg)"]
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: test-pipeline
spec:
params:
- name: mystring
tasks:
- name: echo-test
params:
- name: arg
value: $(params.mystring)
taskRef:
name: test-task
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: test-pipeline-run
spec:
params:
- name: mystring
value: abc.com
pipelineRef:
name: test-pipeline
|
Ok, turns out the problem was incredibly stupid and specific - in the |
🤦🤦🤦 |
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
2b46c0b
to
cc495aa
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
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.
I'm a bit confused about what this PR is doing given the original PR message and the conversation that's happened. It looks like this sets defaults in the reconciler to ensure that defaults are applied to resources that were created before these code changes were applied to the server. Is this still an issue with params without types, disregarding the annotations that were mistakenly kept around on our dogfooding cluster?
@@ -565,6 +565,7 @@ spec: | |||
serviceAccountName: test-sa | |||
taskRef: | |||
name: unit-test-task | |||
kind: Task |
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.
What's the reason to add kind: Task
to all of these taskRefs?
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.
setdefaults will add kind for task as well, if not adding them the current tests will fail
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
Yes, that's the goal
There are some other discussions in this issue #5175. And for taskrun when we get the taskspec, it will call pipeline/pkg/reconciler/taskrun/resources/taskspec.go Lines 46 to 55 in 10a5ae6
but for pipelinerun we don't have it. It may make sense to add for pipelinerun as wellpipeline/pkg/reconciler/pipelinerun/pipelinespec/pipelinespec.go Lines 40 to 48 in 10a5ae6
|
b7d17a0
to
3333072
Compare
This commit adds SetDefaults for pipelineSpec in reconciler after they are fetched. This is to avoid failing the resources that are not mutated to add default values.
3333072
to
8f0ba47
Compare
/retest |
indeed that's probably a mistake, it should be there for pipelinerun as well. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lbernick The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
/lgtm |
Cherry-picked from tektoncd#5176 This commit adds SetDefaults for pipelineSpec in reconciler after they are fetched. This is to avoid failing the resources that are not mutated to add default values. Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Cherry-picked from #5176 This commit adds SetDefaults for pipelineSpec in reconciler after they are fetched. This is to avoid failing the resources that are not mutated to add default values. Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Changes
This commit adds SetDefaults for pipelineSpec in reconciler
after it is fetched from cluster. This is to avoid failing the resources that
are not mutated and add default values.
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes