-
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
Reject embedded Task
s with APIVersion
and/or Kind
specified
#5018
Reject embedded Task
s with APIVersion
and/or Kind
specified
#5018
Conversation
/assign @wlynch @vdemeester @lbernick @jerop |
The following is the coverage report on the affected files.
|
|
||
// Reject cases where APIVersion and/or Kind are specified alongside an embedded Task. | ||
// We determine if this is an embedded Task by checking of TaskSpec.TaskSpec.Steps has items. | ||
if pt.TaskSpec != nil && len(pt.TaskSpec.TaskSpec.Steps) > 0 { |
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.
If anyone has a better way to determine whether the PipelineTask
is, in fact, an embedded Task
, I'd love to hear it. =)
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.
We could at least extract this in a function on PipelineTask
, so that if we change the way to determine it, it won't change that code (and would make that code more readable ? 🙃 )
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.
We require today that kind
is specified if apiVersion
is, but we don't check the content of kind
and apiVersion
.
Should we determine if it's an embedded Task
or an embedded custom task based on the content of kind
and apiVersion
? We could say that (tekton.dev/*
, Task
) means it's an embedded Task
and should be validated accordingly, else it's an embedded custom task and we cannot validate further.
Once we implement PIP, we can add Pipeline
to the list types that we validate.
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.
@vdemeester Good call, doing so.
@afrittoli I thought about that, but decided that it was better to be consistent, especially since Pipeline
won't be in pt.TaskSpec.TaskSpec
as an inline 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.
Also, the current behavior, with custom tasks enabled, with apiVersion
/kind
and TaskSpec.TaskSpec
populated results in a Run
getting created and never doing anything, so we're not breaking any existing use cases by being strict. And supporting Task
in the TypeMeta
would mean changes to reconciler logic to not treat those cases as custom tasks, which doesn't feel like it's worth doing.
|
||
// Reject cases where APIVersion and/or Kind are specified alongside an embedded Task. | ||
// We determine if this is an embedded Task by checking of TaskSpec.TaskSpec.Steps has items. | ||
if pt.TaskSpec != nil && len(pt.TaskSpec.TaskSpec.Steps) > 0 { |
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.
We could at least extract this in a function on PipelineTask
, so that if we change the way to determine it, it won't change that code (and would make that code more readable ? 🙃 )
695dee7
to
c4e3812
Compare
The following is the coverage report on the affected files.
|
/retest |
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.
thanks @abayer! Could you document that the api version of a task embedded within a pipeline should match the api version of the pipeline?
func (pt PipelineTask) validateEmbeddedOrType() (errs *apis.FieldError) { | ||
// Reject cases where APIVersion and/or Kind are specified alongside an embedded Task. | ||
// We determine if this is an embedded Task by checking of TaskSpec.TaskSpec.Steps has items. | ||
if pt.TaskSpec != nil && len(pt.TaskSpec.TaskSpec.Steps) > 0 { |
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.
why is checking if there are steps necessary? can we just check if pt.TaskSpec.TaskSpec != nil
?
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.
pt.TaskSpec.TaskSpec
is just an inline TaskSpec
, not a pointer, so this was the best I could come up with.
@lbernick Not sure about what to document in that regard - what this change is doing is making specifying |
Ah yeah I misspoke-- we could say that embedded Tasks within a Pipeline will create TaskRuns with the same API version as the pipeline |
@lbernick 👍 - in practice, that's obviously just clarifying what's always been the case, but still worth having. =) |
fixes tektoncd#4543 If custom tasks are enabled and either of `PipelineTask.TaskSpec.APIVersion` or `PipelineTask.TaskSpec.Kind` are specified, the `PipelineTask` will be treated as a custom task. This is still the case if an actual embedded `Task` is specified in `PipelineTask.TaskSpec.TaskSpec`, so we should be failing validation for those cases. Signed-off-by: Andrew Bayer <[email protected]>
c4e3812
to
71aa0c6
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester 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 |
/lgtm |
The following is the coverage report on the affected files.
|
Changes
fixes #4543
If custom tasks are enabled and either of
PipelineTask.TaskSpec.APIVersion
orPipelineTask.TaskSpec.Kind
are specified, thePipelineTask
will be treated as a custom task. This is still the case if an actual embeddedTask
is specified inPipelineTask.TaskSpec.TaskSpec
, so we should be failing validation for those cases./kind bug
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
(if there are no user facing changes, use release note "NONE")
Release Notes