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

Adding support to enable resourceSpec #1324

Merged
merged 1 commit into from
Sep 25, 2019

Conversation

pritidesai
Copy link
Member

@pritidesai pritidesai commented Sep 17, 2019

Its now possible to embed resourceSpec into PipelineRun, for example:

apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
  name: pipelinerun-echo-greetings
spec:
  resources:
    - name: git-repo
        resourceRef:
          name: my-git-repo

Can be specified as:

apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
  name: pipelinerun-echo-greetings
spec:
  resources:
    - name: git-repo
      resourceSpec:
        type: git
        params:
          - name: url
            value: https://github.com/myrepo/myrepo.git

Partially Fixes #872

Changes

This PR has lot of changes :) and WIP, still adding integration test.
First, added new fields in PipelineRunSpec (pipelinerun_types.go) and PipelineResourceBinding (resource_types.go). Followed by reading and resolving Inputs/Outputs to read specifications if specified. Also updated unit tests and added documentation.

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

Describe any user facing changes here, or delete this block.

Examples of user facing changes:
- API changes
- Bug fixes
- Any changes in behavior

@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 17, 2019
@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Sep 17, 2019
@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 17, 2019
@tekton-robot
Copy link
Collaborator

Hi @pritidesai. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@pritidesai
Copy link
Member Author

/wip

@bobcatfish
Copy link
Collaborator

@pritidesai this is very exciting!!! Thanks so much for working on this :D (And for including docs right off the bad!!)

Adding support to enable pipelineSpec and resourceSpec

Apologies for this request because it might be a bit frustrating to do, but would it be possible to separate embedding of the pipelineSpec and the resourceSpec into 2 separate PRs? I think we all agree that embedding resourceSpecs is something we want to do, but afaik we don't have total agreement about PipelineSpecs 🙏

@pritidesai pritidesai force-pushed the pipeline-run-resource-spec branch 2 times, most recently from 929a705 to 36c8df9 Compare September 18, 2019 18:12
@pritidesai
Copy link
Member Author

pritidesai commented Sep 18, 2019

hey @bobcatfish sure, I will create a separate PR 😢 what happened to adding pipelineSpec ?

Its a lot of code movement from one branch to another, would hope for a conclusion in near future on pipelineSpec.

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 18, 2019
@pritidesai pritidesai force-pushed the pipeline-run-resource-spec branch 5 times, most recently from 6df069d to 7690da0 Compare September 18, 2019 21:53
@pritidesai pritidesai changed the title Adding support to enable pipelineSpec and resourceSpec Adding support to enable resourceSpec Sep 18, 2019
@dibyom
Copy link
Member

dibyom commented Sep 19, 2019

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 19, 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/resources/input_output_steps.go 95.2% 89.3% -6.0
test/builder/pipeline.go 87.1% 87.3% 0.2

@bobcatfish
Copy link
Collaborator

I0919 14:55:47.116] ---- Checking links in the markdown files ----
I0919 14:55:47.116] ----------------------------------------------
I0919 14:56:13.854] docs/pipelineruns.md
I0919 14:56:13.854] 	ERROR	https://www.apache.org/licenses/LICENSE-2.0
I0919 14:56:13.854] 		Dialing to the given TCP address timed out
I0919 14:56:14.629] --------------------------------------

hmmm weird

/test pull-tekton-pipeline-build-tests

@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/resources/input_output_steps.go 95.2% 89.3% -6.0
test/builder/pipeline.go 87.1% 87.3% 0.2

bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Sep 24, 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!
Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

It looks like some of the coverage went down a bit - i think the functions resolveConditionResources and ToTaskResourceBindings are each just missing a new test case. But again since #1353 is refactoring that anyway, I'm super happy to merge this as is! (Esp since it already includes great docs + examples + end to end tests!! ❤️ )

/lgtm

Gotta leave this on hold for at least one more OWNER to approve tho :)

- name: revision
value: master
- name: url
value: https://github.com/tektoncd/pipeline
Copy link
Collaborator

Choose a reason for hiding this comment

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

great example!

@@ -597,9 +597,6 @@ func TaskRunOutputsResource(name string, ops ...TaskResourceBindingOp) TaskRunOu
return func(i *v1alpha1.TaskRunOutputs) {
binding := &v1alpha1.TaskResourceBinding{
Name: name,
ResourceRef: v1alpha1.PipelineResourceRef{
Name: name,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks for fixing this!!! 🙏 pretty weird that we got away with it all this time 😅

Name: resourceBinding.Name,
},
Spec: *resourceBinding.ResourceSpec,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that in #1353 I'm refactoring the PipelineRun resource resolution logic so it will all happen in one place - then we should only need to do this check in function instead of in a few different places :D

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 24, 2019
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Sep 24, 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!
@@ -290,9 +290,6 @@ func TestResolvedConditionCheck_ToTaskResourceBindings(t *testing.T) {

expected := []v1alpha1.TaskResourceBinding{{
Name: "git-resource",
ResourceRef: v1alpha1.PipelineResourceRef{
Copy link
Member

Choose a reason for hiding this comment

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

Why was this deleted?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sometimes you want to have a ResourceBinding without a Ref (e.g. if you're using a spec!). So in the tests for embedded TaskRun Resource specs, this was being set even tho it shouldn't be

(The other function actually doesn't set this)

(Might be worth adding this to the commit message if it isn't there already @pritidesai !)

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish, dibyom, pritidesai

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

bobcatfish added a commit to dlorenc/build-pipeline that referenced this pull request Sep 24, 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!
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Sep 24, 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!
@bobcatfish
Copy link
Collaborator

Looks like you hit the approve button @dibyom (vs. /approve) so imma merge!

/hold cancel

@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 Sep 25, 2019
@bobcatfish
Copy link
Collaborator

I guess we'll just leave the commit message as is XD

@bobcatfish
Copy link
Collaborator

Looks like this might be a real failure @pritidesai !

sidecar_test.go:84: Creating Task "sidecar-test-task-1"
sidecar_test.go:89: Creating TaskRun "sidecar-test-task-run-1"
sidecar_test.go:99: Error waiting for TaskRun "sidecar-test-task-run-1" to finish: task run sidecar-test-task-run-1 failed!
sidecar_test.go:111: Error waiting for Pod "" to terminate both the primary and sidecar containers: resource name may not be empty
sidecar_test.go:116: Error getting TaskRun pod: resource name may not be empty
sidecar_test.go:140: Either the primary or sidecar containers did not terminate

But just in case:

/test pull-tekton-pipeline-integration-tests

@pritidesai
Copy link
Member Author

Looks like this might be a real failure @pritidesai !

sidecar_test.go:84: Creating Task "sidecar-test-task-1"
sidecar_test.go:89: Creating TaskRun "sidecar-test-task-run-1"
sidecar_test.go:99: Error waiting for TaskRun "sidecar-test-task-run-1" to finish: task run sidecar-test-task-run-1 failed!
sidecar_test.go:111: Error waiting for Pod "" to terminate both the primary and sidecar containers: resource name may not be empty
sidecar_test.go:116: Error getting TaskRun pod: resource name may not be empty
sidecar_test.go:140: Either the primary or sidecar containers did not terminate

But just in case:

/test pull-tekton-pipeline-integration-tests

will check just in few, it has happened before where integration tests failed but then with retest, they succeeded, but will confirm.

@tekton-robot tekton-robot merged commit bcbba97 into tektoncd:master Sep 25, 2019
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Sep 25, 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!
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request 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!
Name: name,
ResourceRef: v1alpha1.PipelineResourceRef{
}
if r.SelfLink != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

hey @pritidesai, somehow I didn't notice this when I looked before: what's the significance of selfLink here? it seems like its being used to decide if a resource should be embedded or not? 🤔

Copy link
Member Author

@pritidesai pritidesai Sep 26, 2019

Choose a reason for hiding this comment

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

hey @pritidesai, somehow I didn't notice this when I looked before: what's the significance of selfLink here? it seems like its being used to decide if a resource should be embedded or not? 🤔

Hey @bobcatfish yes selfLink is the deciding factor here and most reliable, if resource is specified through reference (resourceRef), selfLink will never be empty and set to something like /apis/tekton.dev/pipelineresources/my-git-resource since my-git-resource is already created and can be referred to through this link. This was the best choice, as in inputs being type of map[string]*v1alpha1.PipelineResource in input_output_steps.go line 56 always had name set to the resource name and PipelineResource.name set to the same name as resource name even when a resource specification were given (using resourceSpec). Hope this helps.

bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Sep 27, 2019
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.
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Sep 27, 2019
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.
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Sep 27, 2019
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.
bobcatfish added a commit to bobcatfish/pipeline that referenced this pull request Oct 1, 2019
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 pushed a commit that referenced this pull request Oct 1, 2019
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!
tekton-robot pushed a commit that referenced this pull request Oct 1, 2019
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.
ncskier pushed a commit to ncskier/experimental that referenced this pull request Oct 17, 2019
Fixes tektoncd#240
PR tektoncd/pipeline#1324 makes it possible to
embed PipelineResourceSpecs into a PipelineRun.

This PR updates our PipelineRuns and TaskRuns to use an embedded
PipelineResourceSpec. So, we will no longer encounter race conditions
between the PipelineResources and PipelineRun/TaskRun.

The Gopkg.toml file was updated to use revision
8871979dfc08fb65ae544c6ad2de83f8bab617b0 of tektoncd/pipeline, so we can
ensure PR 1324 will be available.
This pull request was closed.
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Allow embedding specs in Pipeline and PipelineRun instead of referencing.
5 participants