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 support for from usage in Pipeline Conditions #1527

Merged
merged 1 commit into from
Jan 10, 2020

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Nov 5, 2019

Changes

Resources in Pipeline Conditions can now declare that they depend on the
output of previous tasks using the from clause. Using from in a
conditional resource implies ordering for the pipeline task i.e. if
task B has a condition (say, C) that takes in an output resource from
task A, task A will run first, followed by the conditional C, and then B

Fixes #1256

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

Resources in Pipeline Conditions can now declare that they depend on the
output of previous tasks using the `from` clause. 

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Nov 5, 2019
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 5, 2019
@dibyom dibyom changed the title Add support for from usage in Pipeline Conditions WIP: Add support for from usage in Pipeline Conditions Nov 5, 2019
@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 5, 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/apis/pipeline/v1alpha1/dag.go 100.0% 98.2% -1.8
pkg/apis/pipeline/v1alpha1/pipeline_validation.go 97.9% 98.0% 0.1

@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/dag.go 100.0% 98.1% -1.9
pkg/apis/pipeline/v1alpha1/pipeline_validation.go 97.9% 98.0% 0.1

@dibyom dibyom changed the title WIP: Add support for from usage in Pipeline Conditions Add support for from usage in Pipeline Conditions Nov 6, 2019
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 6, 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/apis/pipeline/v1alpha1/pipeline_validation.go 97.9% 98.0% 0.1

@dibyom
Copy link
Member Author

dibyom commented Nov 12, 2019

/cc @sbwsg @afrittoli @bobcatfish @vdemeester I haven't fully kept up with all the cool new resource stuff but do you think adding support for the from syntax for conditions still makes sense in the new world?

@ghost
Copy link

ghost commented Nov 12, 2019

Yes I think so! Supporting it for the existing pipeline resources implementation makes sense to me.

@@ -326,3 +337,82 @@ func TestBuild_Invalid(t *testing.T) {
})
}
}

func TestBuild_ConditionResources(t *testing.T) {
// a,b, c, d := regularTask
Copy link

Choose a reason for hiding this comment

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

remove dead code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, more like a outdated comment 😅

@ghost
Copy link

ghost commented Nov 12, 2019

/lgtm

@tekton-robot tekton-robot assigned ghost Nov 12, 2019
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 12, 2019
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 12, 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/apis/pipeline/v1alpha1/pipeline_validation.go 97.9% 98.0% 0.1

@dibyom
Copy link
Member Author

dibyom commented Nov 13, 2019

/test pull-tekton-pipeline-integration-tests

@ghost
Copy link

ghost commented Nov 13, 2019

/lgtm

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

@afrittoli afrittoli 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, this is really useful!

spec:
inputs:
outputs:
Copy link
Member

@afrittoli afrittoli Dec 7, 2019

Choose a reason for hiding this comment

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

oh, I though we deprecated git pipeline resource as output, at least until we have an actual output resource - only holding off the LGTM to clarify this

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, did not know that....I can switch the example to a GCS resource or something

Conditions: []v1alpha1.PipelineTaskCondition{cond2DependsOnB},
}

// a b c
Copy link
Member

Choose a reason for hiding this comment

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

Nice :)

@@ -152,15 +152,6 @@ type PipelineDeclaredResource struct {
Type PipelineResourceType `json:"type"`
}

// PipelineConditionResource allows a Pipeline to declare how its DeclaredPipelineResources
// should be provided to a Condition as its inputs.
type PipelineConditionResource struct {
Copy link
Member

Choose a reason for hiding this comment

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

As far as I understand this was removed to make the logic in the code simpler, since you have to deal with PipelineTaskInputResource only; I wonder if we may need different behaviours for task input resources and condition resources, but we can still add this back if becomes necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I don't think we do at the moment; but if we do we can add this back later on. Right now, this is basically an unused/extra level of indirection

@dibyom
Copy link
Member Author

dibyom commented Dec 9, 2019

Thanks for the review @afrittoli Looks like there have been some major changes to the DAG....so the rebase will need some work..I'll give that shot on Friday!

@vdemeester
Copy link
Member

Thanks for the review @afrittoli Looks like there have been some major changes to the DAG....so the rebase will need some work..I'll give that shot on Friday!

I don't think they are that major 😅 but ping me if you need help 😝

@vdemeester vdemeester added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2019
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 7, 2020
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.

Naive question, can I create a deadlock with that from ? Like refering to a task that has a from on the current task. Something like the following ?

tasks:
  - name: first-create-file
    taskRef:
      name: create-file
    resources:
      outputs:
        - name: workspace
          resource: source-repo
  - name: then-check
    conditions:
      - conditionRef: "file-exists"
        resources:
          - name: workspace
            resource: source-repo
            from: [then-again]
    taskRef:
      name: echo-hello
  - name: then-again
    resources:
      outputs:
        - name: workspace
          resource: source-repo
          from: [then-check]
    taskRef:
      name: echo-hello

Asking because I think we should try to prevent that from happening.

@dibyom
Copy link
Member Author

dibyom commented Jan 9, 2020

Naive question, can I create a deadlock with that from ? Like refering to a task that has a from on the current task. Something like the following ?

I'd hope not 😅 I think we detect the cycles in the DAG...let me verify

@dibyom
Copy link
Member Author

dibyom commented Jan 9, 2020

Tried this out:

apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
  name: conditional-pipeline
spec:
  resources:
    - name: source-repo
      type: git
  params:
    - name: "path"
      default: "README.md"
  tasks:
   - name: task-1
     conditions:
       - conditionRef: "file-exists"
         params:
           - name: "path"
             value: "$(params.path)"
         resources:
           - name: workspace
             resource: source-repo
             from: [task-2]
     taskRef:
       name: create-readme-file-1
     resources:
       inputs:
       - name: workspace1
         resource: source-repo
       outputs:
       - name: workspace
         resource: source-repo
   - name: task-2
     taskRef:
      name: create-readme-file-1
     resources:
       inputs:
       - name: workspace1
         resource: source-repo
         from: [task-1]
       outputs:
       - name: workspace
         resource: source-repo

webhook validation failed:

invalid value: couldn't add link between task-2 and task-1: couldn't create link from task-1 to task-2: cycle detected: task-2 -> task-1 -> task-2: spec.tasks

@dibyom
Copy link
Member Author

dibyom commented Jan 9, 2020

/test pull-tekton-pipeline-integration-tests

@dibyom dibyom removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 9, 2020
@dibyom
Copy link
Member Author

dibyom commented Jan 9, 2020

/test pull-tekton-pipeline-build-tests

@ghost
Copy link

ghost commented Jan 9, 2020

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2020
Resources in Pipeline Conditions can now declare that they depend on the
output of previous tasks using the `from` clause. Using `from` in a
conditional resource implies ordering for the pipeline task i.e. if
task B has a condition (say, C) that takes in an output resource from
task A, task A will run first, followed by the conditional C, and then B

Signed-off-by: Dibyo Mukherjee <[email protected]>
@dibyom
Copy link
Member Author

dibyom commented Jan 9, 2020

/test pull-tekton-pipeline-integration-tests

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

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbwsg, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dibyom
Copy link
Member Author

dibyom commented Jan 10, 2020

/test pull-tekton-pipeline-integration-tests

1 similar comment
@dibyom
Copy link
Member Author

dibyom commented Jan 10, 2020

/test pull-tekton-pipeline-integration-tests

@tekton-robot tekton-robot merged commit 4b6a390 into tektoncd:master Jan 10, 2020
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support from clause for resources in Conditionals
5 participants