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

Validate PipelineTask name as Task names 📛 #2099

Merged

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Feb 25, 2020

Changes

As reported, a Pipeline task name (Pipelinetask) can be created
that will violate TaskRun naming rules, making it fail at runtime.

This changes this by validation PipelineTask name the same way we
validation TaskRun names, to make sure we won't fail for this at
runtime.

Closes #2095

Signed-off-by: Vincent Demeester [email protected]

/cc @bobcatfish @afrittoli @danielhelfand

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Validate PipelineTask name as Task names

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Feb 25, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 25, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha2/pipeline_validation.go 94.2% 93.5% -0.7

return &apis.FieldError{
Message: fmt.Sprintf("invalid value %q", t.Name),
Paths: []string{fmt.Sprintf("spec.tasks[%d].name", i)},
Details: "Pipeline Task step name must be a valid DNS Label, For more info refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the error message to be consistent with Task?

The Task "FooTask" is invalid: metadata.name: Invalid value: "FooTask": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Remove step after Pipeline Task:

Suggested change
Details: "Pipeline Task step name must be a valid DNS Label, For more info refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names",
Details: "Pipeline Task name must be a valid DNS Label. For more info refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing there was another push here, but I am not seeing an update to the error message.

My thought is to make it so the error message here is consistent with what is shown for a Task that a user tries to create the violates naming conventions.

@vdemeester vdemeester force-pushed the 2095-pipelinetask-validation branch from ad1924c to b93fd4e Compare February 26, 2020 14:13
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha2/pipeline_validation.go 94.2% 93.5% -0.7

@vdemeester
Copy link
Member Author

/cc @sbwsg @dibyom I would like to get this one in for 0.11 👼

@danielhelfand
Copy link
Member

danielhelfand commented Mar 2, 2020

@vdemeester Can this comment below be addressed before this goes in?

Do we want the error message to be consistent with Task?

The Task "FooTask" is invalid: metadata.name: Invalid value: "FooTask": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the error message change has been addressed.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbwsg

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 2, 2020
@vdemeester vdemeester force-pushed the 2095-pipelinetask-validation branch from b93fd4e to ff3a6ce Compare March 2, 2020 14:30
Copy link
Member

@danielhelfand danielhelfand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipeline_validation.go 97.5% 95.9% -1.6
pkg/apis/pipeline/v1alpha2/pipeline_validation.go 94.2% 93.5% -0.7

As reported, a `Pipeline` task name (`Pipelinetask`) can be created
that will violate `TaskRun` naming rules, making it fail at runtime.

This changes this by validation PipelineTask name the same way we
validation `TaskRun` names, to make sure we won't fail for this at
runtime.

Signed-off-by: Vincent Demeester <[email protected]>
@vdemeester vdemeester force-pushed the 2095-pipelinetask-validation branch from ff3a6ce to 64b139f Compare March 2, 2020 14:47
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on pkg/.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1alpha1/pipeline_validation.go 97.5% 95.9% -1.6
pkg/apis/pipeline/v1beta1/pipeline_validation.go 94.2% 93.5% -0.7

@danielhelfand
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2020
@tekton-robot tekton-robot merged commit 7d14810 into tektoncd:master Mar 2, 2020
@vdemeester vdemeester deleted the 2095-pipelinetask-validation branch March 2, 2020 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PipelineTask Names Can Be Created That Violate TaskRun Naming Rules
4 participants