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

Resolve all PipelineResources first before continuing #1353

Merged
merged 2 commits into from
Oct 1, 2019

Conversation

bobcatfish
Copy link
Collaborator

@bobcatfish bobcatfish commented Sep 24, 2019

Changes

Pre #1324

As part of #1184 I need to call GetSetup on all PipelineResources
early on in PipelineRun execution. Since PipelineRuns declare all their
resource up front, I wanted to be able to resolve all of them at once,
then call GetSetup on all of them. Also, as Pipelines got more complex
(we added Conditions) it turned out we were retrieving the resources in
a few different places. Also in #1324 @pritidesai is making it so that
these Resources can be provided by spec. By resolving all of this up
front at once, we can simplify the logic later on. And you can see in
this commit that we are able to reduce the responsibilities of
ResolvePipelineRun a bit too!

Post #1324

In #1324 we updated PipelineRuns to allow for embedding ResourceSpecs in
PipelineRuns. This commit makes it so that the logic for resolving (i.e.
deciding if PipelineResources are specified by Spec or Ref) is shared by
PipelineRuns + TaskRuns. This is done by making it so that the "binding"
uses the same type underneath. The only reason they can't be the exact
same type is that TaskRuns additionally need the "path" attribute, which
is actually only used for PVC copying, which will be removed in #1284,
and then we should be able to remove paths entirely and the type can be
the same.

Also added some additional comments around the use of SelfLink, and
made sure it was well covered in the reconciler test.

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

For folks importing the client libraries, when ResourceBindings are instantiated for TaskRuns, they now need to explicitly declare the newly embedded struct PipelineResourceBinding.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Sep 24, 2019
@tekton-robot tekton-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 24, 2019
@bobcatfish
Copy link
Collaborator Author

@pritidesai if this causes any conflicts with #1324 I'm happy to deal with the conflicts! But also maybe #1324 can get merged first and then I can deal with them in this PR :D

@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/reconciler/pipelinerun/pipelinerun.go 82.4% 82.6% 0.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 95.0% 95.2% 0.3
pkg/reconciler/taskrun/resources/input_resources.go 91.7% 94.3% 2.7
pkg/reconciler/taskrun/resources/taskresourceresolution.go 100.0% 89.5% -10.5

@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 Sep 24, 2019
@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/reconciler/pipelinerun/pipelinerun.go 82.4% 82.6% 0.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 95.0% 95.2% 0.3
pkg/reconciler/taskrun/resources/input_resources.go 92.6% 95.7% 3.2

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
/hold

Am adding the hold just to make sure that the merge doesn't happen prior to #1324

// getResource will return an instance of a PipelineResource to use for r, either by getting it with getter or by
// instantiating it from the embedded spec.
func getResource(r *v1alpha1.TaskResourceBinding, getter GetResource) (*v1alpha1.PipelineResource, error) {
// Check both resource ref or resource Spec are not present. Taskrun webhook should catch this in validation error.
Copy link

Choose a reason for hiding this comment

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

Very minor nit (and I see that this func has just been moved from another place, so it's totally not required to fix this now) but the block of code below this is pretty self-explanatory. This comment probably isn't needed?

Spec: *r.ResourceSpec,
}, nil
}
return nil, xerrors.New("Neither ResourseRef not ResourceSpec is defined")
Copy link

Choose a reason for hiding this comment

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

not -> nor

@tekton-robot tekton-robot assigned ghost Sep 25, 2019
@tekton-robot tekton-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Sep 25, 2019
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm
/meow boxes

@tekton-robot
Copy link
Collaborator

@vdemeester: cat image

In response to this:

/lgtm
/meow boxes

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish, 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:
  • OWNERS [bobcatfish,vdemeester]

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 removed the lgtm Indicates that a PR is ready to be merged. label Sep 25, 2019
@bobcatfish
Copy link
Collaborator Author

I think the meow plugin broke when we updated Prow 😭 This is my theory anyway. Here's a cat (Maru?) in a box to make up for it

image

@ghost
Copy link

ghost commented Sep 26, 2019

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 26, 2019
As part of tektoncd#1184 I need to call `GetSetup` on all PipelineResources
early on in PipelineRun execution. Since PipelineRuns declare all their
resource up front, I wanted to be able to resolve all of them at once,
then call `GetSetup` on all of them. Also, as Pipelines got more complex
(we added Conditions) it turned out we were retrieving the resources in
a few different places. Also in tektoncd#1324 @pritidesai is making it so that
these Resources can be provided by spec. By resolving all of this up
front at once, we can simplify the logic later on. And you can see in
this commit that we are able to reduce the responsibilities of
ResolvePipelineRun a bit too!
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Sep 26, 2019
@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/reconciler/pipelinerun/pipelinerun.go 82.4% 82.6% 0.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 92.6% 95.2% 2.7
pkg/reconciler/taskrun/resources/input_resources.go 92.6% 95.7% 3.2

@bobcatfish
Copy link
Collaborator Author

/hold

still re-doing some things post #1324

@tekton-robot tekton-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 27, 2019
@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/reconciler/pipelinerun/pipelinerun.go 82.4% 82.6% 0.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 92.6% 95.2% 2.7
pkg/reconciler/taskrun/resources/input_resources.go 92.6% 95.7% 3.2

@bobcatfish bobcatfish force-pushed the follow_the_resources branch 2 times, most recently from 10b6f5b to ef5c635 Compare September 27, 2019 20:50
@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/reconciler/pipelinerun/pipelinerun.go 82.4% 82.6% 0.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 92.6% 95.2% 2.7
pkg/reconciler/taskrun/resources/input_resources.go 92.6% 95.7% 3.2

@bobcatfish
Copy link
Collaborator Author

Okay! Now rebased on #1324, PTAL @pritidesai @sbwsg @vdemeester (note @vdemeester note the potential impact on the client usage for the CLI - maybe dashboard too? - I can avoid this by instead duplicating the logic to determine if a binding is a Ref or a Spec, but once we get to #1284 we'll probably remove "path" from the TaskRun binding so it's gonna change at that point anyway. Lemme know if you feel strongly and plz tag anyone else you think would be interested.

@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/reconciler/pipelinerun/pipelinerun.go 82.4% 82.6% 0.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 92.6% 95.2% 2.7
pkg/reconciler/taskrun/resources/input_resources.go 92.6% 95.7% 3.2

@pritidesai
Copy link
Member

/lgtm

This is great and works like a charm, thanks @bobcatfish for the simplification, the code is much more readable now ❤️

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 27, 2019
@vdemeester
Copy link
Member

note @vdemeester note the potential impact on the client usage for the CLI - maybe dashboard too?

The API doesn't change, so this is just a matter of bump the dependency. But both an old client or new client will still work against the API, so no need to duplicate things 😉

@ghost
Copy link

ghost commented Sep 30, 2019

/lgtm

@bobcatfish
Copy link
Collaborator Author

/hold cancel

Thanks for the feedback all!!

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2019
@bobcatfish
Copy link
Collaborator Author

why hello stronger linting, don't mind if i do

I1001 14:05:29.226] pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go:1062:9: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
I1001 14:05:29.227] 	} else {
I1001 14:05:29.227] 	       ^
I1001 14:05:29.228] pkg/reconciler/pipelinerun/resources/pipelinerunresolution_test.go:1071:9: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
I1001 14:05:29.228] 	} else {

In tektoncd#1324 we updated PipelineRuns to allow for embedding ResourceSpecs in
PipelineRuns. This commit makes it so that the logic for resolving (i.e.
deciding if PipelineResources are specified by Spec or Ref) is shared by
PipelineRuns + TaskRuns. This is done by making it so that the "binding"
uses the same type underneath. The only reason they can't be the exact
same type is that TaskRuns additionally need the "path" attribute, which
is actually only used for PVC copying, which will be removed in tektoncd#1284,
and then we should be able to remove paths entirely and the type can be
the same.

Also added some additional comments around the use of `SelfLink`, and
made sure it was well covered in the reconciler test.
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2019
@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/reconciler/pipelinerun/pipelinerun.go 82.4% 82.6% 0.1
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 92.6% 95.2% 2.7
pkg/reconciler/taskrun/resources/input_resources.go 92.6% 95.7% 3.2

@ghost
Copy link

ghost commented Oct 1, 2019

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2019
@tekton-robot tekton-robot merged commit 73ba02b into tektoncd:master Oct 1, 2019
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants