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

Add resolution types to the API #4502

Merged
merged 1 commit into from Feb 10, 2022
Merged

Add resolution types to the API #4502

merged 1 commit into from Feb 10, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jan 20, 2022

Changes

TEP-0060 introduces remote resource resolution to Tekton Pipelines, allowing PipelineRuns and TaskRuns to reference Pipelines and Tasks in remote places like git repos.

This PR adds the fields for the remote resolution feature to the v1beta1.TaskRef and v1beta1.PipelineRef types. Also includes validations and unit test coverage. These fields can only be included when the enable-api-fields feature-flag is set to alpha. Even then, utilizing these fields only results in the reconcilers printing errors.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

Release Notes

Syntax support for remote resolution, an alpha feature in development, has been added to pipelineRef and taskRef fields. Using the remote resolution fields is not yet possible, however, and will only result in errors.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 20, 2022
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 20, 2022
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.9%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.5% 98.3% -0.2
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.9%

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.9%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.5% 98.3% -0.2
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.9%

@ghost
Copy link
Author

ghost commented Jan 20, 2022

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 20, 2022
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.5% 98.3% -0.2
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

@@ -261,6 +261,63 @@ func TestTaskRunSpec_Invalidate(t *testing.T) {
},
wantErr: apis.ErrInvalidValue("breakito is not a valid breakpoint. Available valid breakpoints include [onFailure]", "debug.breakpoint"),
wc: enableAlphaAPIFields,
}, {
Copy link
Member

Choose a reason for hiding this comment

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

could you add some test cases with valid taskrefs for the new syntax?

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, updated with tests of valid resolution syntax when alpha gate is enabled.

@@ -1471,6 +1471,24 @@
}
}
},
"v1beta1.ResolverRef": {
Copy link
Member

Choose a reason for hiding this comment

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

Just for my own understanding what is this file for? Are the changes generated or manual?

Copy link
Author

Choose a reason for hiding this comment

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

It's generated by, I think, ./hack/openapigen.sh

I believe swagger.json can be used to generate API clients for other programming languages. I don't know of any examples of folks using it, though.

@@ -370,9 +370,10 @@ func TestPipelineRun_Validate(t *testing.T) {

func TestPipelineRunSpec_Invalidate(t *testing.T) {
Copy link
Member

@lbernick lbernick Feb 2, 2022

Choose a reason for hiding this comment

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

similar comment as for TaskRef, could you add a test case where the ref is valid?

Copy link
Author

Choose a reason for hiding this comment

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

Added a test for taskref with resolver field + alpha gate and a test for taskref with resolver field + resource fields + alpha gate.

@bobcatfish
Copy link
Collaborator

Love the incremental PR approach @sbwsg 💃 🎉 !!

@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 7, 2022
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.8% 98.6% -0.1
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

@lbernick
Copy link
Member

lbernick commented Feb 7, 2022

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 7, 2022
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

Thank you @sbwsg for the iterative approach in implementing Remote Resolution 😀

Left some comments about the types ResolverRef:

  • Resolver - considering using string alias instead of string (K8s convention)
  • Resource - considering using Parameters instead of map (K8s convention)

What do you think about adding the relevant documentation for the API change and validation so that we can review it alongside the change? (we can add a bolded disclaimer that the functionality doesn't work yet, even though users can pass in the fields)

Comment on lines 27 to 32
// Resource contains the parameters used to identify the
// referenced Tekton resource. Example entries might include
// "repo" or "path" but the set of params ultimately depends on
// the chosen resolver.
// +optional
Resource map[string]string `json:"resource,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering about usingmap[string]string for Resource - could we use Parameters instead?
Especially considering that the proposal suggests using object Parameters in this field when it's available - maybe using a list of string Parameters here would help in the transition later?

Note that the fields under resource: are validated by a resolver, not by Tekton Pipelines. TEP-0075 (Dictionary
Params)
describes adding support for JSON object schema to Params. It would make sense to bring in the same schema support for the resource: field as well and eventually resolvers might be able to publish the schema they accept so that Pipelines can enforce it during validation of a TaskRun or PipelineRun.
~ TEP-0060

K8s API convention encouraging use of sub-objects instead of maps: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#lists-of-named-subobjects-preferred-over-maps

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback. I've changed this to use the following syntax:

taskRef:
  remote: git
  resource:
  - name: repo
    value: https://github.com/tektoncd/catalog.git
  - name: path
    value: /task/golang-build/0.3/golang-build.yaml

Comment on lines 23 to 26
// Resolver is the name of the resolver that should perform
// resolution of the referenced Tekton resource, such as "git".
// +optional
Resolver string `json:"resolver,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

The TEP proposes a specific set of resolvers: git, bundle and in-cluster

What do you think about using aliases for the strings, instead of strings directly, and adding validation for resolvers themselves?

K8s API convention encouraging use of string aliases when fields will have a list of allowed values (enumerations): https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#constants

Copy link
Author

Choose a reason for hiding this comment

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

This field is intentionally free-form. The resolution feature is intended to allow integration with any resolver an operator wants to install and that could include ones that Tekton hasn't explicitly named in its source code. e.g. "svn", "bzr", "gcs"

So, I guess I don't see this being in the spirit of what the Resolution TEP is aiming to achieve for the Tekton project but I also don't want to introduce freeform data if you feel strongly that you'd prefer to have the options explicitly named. Let me know.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the additional context!

How about we declare the Resolver type, specify the ones we provide, then integrators can specify their own:

# in tekton pipelines
type Resolver string

const (
	git     Resolver = "git"
	bundle  Resolver = "bundle"
	cluster Resolver = "cluster"
)
# in an integration
const (
	svn tekton.Resolver = "svn"
	bzr tekton.Resolver = "bzr"
	gcs tekton.Resolver = "gcs"
)

Similarly to how we use selection.Operator from K8s apimachinery in operator field in when expressions

What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

OK, I've updated the type from string to v1beta1.ResolverName.

@jerop
Copy link
Member

jerop commented Feb 10, 2022

/assign

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 10, 2022
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.8% 98.6% -0.1
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.8% 98.6% -0.1
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.8% 98.6% -0.1
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

@ghost
Copy link
Author

ghost commented Feb 10, 2022

I've added initial documentation to taskruns.md, pipelinerun.md, and install.md

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.8% 98.6% -0.1
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.8% 98.6% -0.1
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

TEP-0060 adds remote resource resolution to Tekton Pipelines,
allowing PipelineRuns and TaskRuns to reference Pipelines and Tasks
in remote places like git repos.

This PR adds the initial alpha syntax for the remote resolution feature
to the v1beta1.TaskRef and v1beta1.PipelineRef types along with validation
for them. Some initial documentation is added describing the syntax for
remote tasks and pipelines.
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/pipelineref_validation.go Do not exist 96.8%
pkg/apis/pipeline/v1beta1/pipelinerun_validation.go 98.8% 98.6% -0.1
pkg/apis/pipeline/v1beta1/taskref_validation.go Do not exist 96.8%

Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

excited to try this out soon, thank you @sbwsg 🎉

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop

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 Feb 10, 2022
@jerop
Copy link
Member

jerop commented Feb 10, 2022

Reopened the issue tracking the flakey test: TestTaskRunPipelineRunCancel

/test pull-tekton-pipeline-alpha-integration-tests

@lbernick
Copy link
Member

/lgtm
🎉

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 10, 2022
@tekton-robot tekton-robot merged commit 5d3f23e into tektoncd:main Feb 10, 2022
@abayer abayer mentioned this pull request Jul 28, 2022
7 tasks
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants