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

feat: use Tekton Resolvers for a standard on cluster build #1843

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

zroubalik
Copy link
Contributor

@zroubalik zroubalik commented Jul 4, 2023

Changes

  • 🎁 Standard Tekton On-cluster builds (non PAC) are using resolvers to get referenced tasks - users don't have to install them
  • 🧹 PAC related templates are stored in .tekton directory in files pipeline-pac.yaml and pipeline-run-pac.yaml (added the -pac suffix to distingush them from standard ones
  • 🐛 PAC templates contain knative/func related labels

I have changed the way how Pipeline and PipelineRun resources are created - not using go client anymore, but using Manifestival to apply YAML resources - this simplifies templating and follows the pattern used for PAC builds.
Another benefit is, that users don't have preinstall Tasks anymore, they should be resolved by Tekton.

The workflow is following:

  1. user runs func deploy --remote
  2. if there are files pipeline.yaml and/or pipeline-run.yaml in the .tekton directory in the function project, we use the resources defined there to create the Pipeline and/or PipelineRun
  3. if these files are not present there, new resources are created on the fly and applied to the cluster

Ability to save the pipelines to the .tekton directory is not implemented yet, it will be in the follow up PR.

Relates #620

@knative-prow
Copy link

knative-prow bot commented Jul 4, 2023

@zroubalik: The label(s) kind/<kind> cannot be applied, because the repository doesn't have them.

In response to this:

Changes

/kind

Fixes #

Release Note


Docs


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.

@knative-prow
Copy link

knative-prow bot commented Jul 4, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 4, 2023
@knative-prow
Copy link

knative-prow bot commented Jul 4, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zroubalik

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

@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 4, 2023
@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Patch coverage: 69.65% and project coverage change: -2.38 ⚠️

Comparison is base (b38d19b) 62.50% compared to head (b795fbe) 60.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1843      +/-   ##
==========================================
- Coverage   62.50%   60.13%   -2.38%     
==========================================
  Files         107      107              
  Lines       13800    13710      -90     
==========================================
- Hits         8626     8244     -382     
- Misses       4349     4628     +279     
- Partials      825      838      +13     
Flag Coverage Δ
e2e-test ?
e2e-test-oncluster 30.63% <46.15%> (-0.60%) ⬇️
e2e-test-oncluster-runtime 25.67% <52.99%> (?)
integration-tests 51.40% <64.95%> (+3.24%) ⬆️
unit-tests-macos-latest 49.33% <52.56%> (-0.31%) ⬇️
unit-tests-ubuntu-latest 50.12% <52.56%> (-0.27%) ⬇️
unit-tests-windows-latest 49.33% <52.56%> (-0.31%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/builders/builders.go 85.00% <0.00%> (-4.48%) ⬇️
pkg/pipelines/tekton/pipelines_pac_provider.go 42.85% <43.75%> (+38.28%) ⬆️
pkg/k8s/manifestival.go 50.00% <50.00%> (ø)
pkg/pipelines/tekton/pipelines_provider.go 57.54% <62.22%> (+2.96%) ⬆️
pkg/pipelines/tekton/templates.go 73.01% <75.46%> (+0.69%) ⬆️
pkg/pipelines/tekton/resources.go 81.81% <100.00%> (-8.14%) ⬇️

... and 14 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@zroubalik zroubalik marked this pull request as ready for review July 4, 2023 12:58
@zroubalik zroubalik changed the title [WIP] use Tekton Resolvers for a standard on cluster build feat: use Tekton Resolvers for a standard on cluster build Jul 4, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 4, 2023
@knative-prow knative-prow bot requested a review from nainaz July 4, 2023 12:58
@zroubalik
Copy link
Contributor Author

I have no idea why does Code Style / style / suggester / shell (pull_request) fail.

@lance
Copy link
Member

lance commented Jul 4, 2023

/override "style / suggester / shell"

@knative-prow
Copy link

knative-prow bot commented Jul 4, 2023

@lance: Overrode contexts on behalf of lance: style / suggester / shell

In response to this:

/override "style / suggester / shell"

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.

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

Looks good @zroubalik! I'd like to understand how we might use this in the openshift dev console as well. It's great that the tasks don't need to be explicitly installed now which will help scenarios like developer sandbox (where users don't have permission to install tasks). Currently dev sandbox does explicitly need to install both the tasks, AND the pipeline (here: https://github.com/openshift-knative/kn-plugin-func/blob/serverless-1.29.0/pkg/pipelines/resources/tekton/pipeline/dev-console/0.1/nodejs-pipeline.yaml). It would be great to eliminate the need for all of that to be installed, which it seems this PR does. We need to communicate with the dev console folks to ensure that we're all on the same page though. Thanks!

@zroubalik
Copy link
Contributor Author

/override "style / suggester / shell"

@knative-prow
Copy link

knative-prow bot commented Jul 7, 2023

@zroubalik: /override requires failed status contexts, check run or a prowjob name to operate on.
The following unknown contexts/checkruns were given:

  • style / suggester / shell

Only the following failed contexts/checkruns were expected:

  • EasyCLA
  • style / suggester / github_actions
  • style / suggester / yaml
  • tide
  • unit-tests_func_main

If you are trying to override a checkrun that has a space in it, you must put a double quote on the context.

In response to this:

/override "style / suggester / shell"

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.

@zroubalik
Copy link
Contributor Author

zroubalik commented Jul 7, 2023

Looks good @zroubalik! I'd like to understand how we might use this in the openshift dev console as well. It's great that the tasks don't need to be explicitly installed now which will help scenarios like developer sandbox (where users don't have permission to install tasks). Currently dev sandbox does explicitly need to install both the tasks, AND the pipeline (here: https://github.com/openshift-knative/kn-plugin-func/blob/serverless-1.29.0/pkg/pipelines/resources/tekton/pipeline/dev-console/0.1/nodejs-pipeline.yaml). It would be great to eliminate the need for all of that to be installed, which it seems this PR does. We need to communicate with the dev console folks to ensure that we're all on the same page though. Thanks!

Yeah, that's correct. You don't need to install Tasks, Pipeline etc manually.

Does Dev Console solution run func deploy? If so, then all should be set there as well.

The only thing I don't like about this solution is that Tasks need to be fetched from git (and checking out https://github.com/knative/func.git can take some time). I think that we can workaround this by moving tasks to a separate repo (thus a smaller one) or to Tekton Hub, which I prefer. Btw Tekton PAC resolvers (a different technology) can fetch tasks directly from url, which is faster than pulling whole repo...

// Following section contains references for Tasks to be used in Pipeline templates,
// there is a difference if we use PAC approach or standard Tekton approach.
//
// This can be simplified once we start consuming tasks from Tekton Hub
taskFuncBuildpacksTaskRef = `taskRef:
resolver: git
params:
- name: url
value: https://github.com/%s.git
- name: revision
value: %s
- name: pathInRepo
value: pkg/pipelines/resources/tekton/task/func-buildpacks/0.1/func-buildpacks.yaml`
taskFuncBuildpacksPACTaskRef = `taskRef:
kind: Task
name: func-buildpacks`
taskFuncS2iTaskRef = `taskRef:
resolver: git
params:
- name: url
value: https://github.com/%s.git
- name: revision
value: %s
- name: pathInRepo
value: pkg/pipelines/resources/tekton/task/func-s2i/0.1/func-s2i.yaml`
taskFuncS2iPACTaskRef = `taskRef:
kind: Task
name: func-s2i`
taskFuncDeployTaskRef = `taskRef:
resolver: git
params:
- name: url
value: https://github.com/%s.git
- name: revision
value: %s
- name: pathInRepo
value: pkg/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml`
taskFuncDeployPACTaskRef = `taskRef:
kind: Task
name: func-deploy`

@knative knative deleted a comment from knative-prow bot Jul 7, 2023
@lance
Copy link
Member

lance commented Jul 11, 2023

/override "style / suggester / shell"

@knative-prow
Copy link

knative-prow bot commented Jul 11, 2023

@lance: /override requires failed status contexts, check run or a prowjob name to operate on.
The following unknown contexts/checkruns were given:

  • style / suggester / shell

Only the following failed contexts/checkruns were expected:

  • EasyCLA
  • style / suggester / github_actions
  • style / suggester / yaml
  • tide
  • unit-tests_func_main

If you are trying to override a checkrun that has a space in it, you must put a double quote on the context.

In response to this:

/override "style / suggester / shell"

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.

@lance
Copy link
Member

lance commented Jul 11, 2023

/override "style / suggester / github_actions"
/override "style / suggester / yaml"

@knative-prow
Copy link

knative-prow bot commented Jul 11, 2023

@lance: Overrode contexts on behalf of lance: style / suggester / github_actions, style / suggester / yaml

In response to this:

/override "style / suggester / github_actions"
/override "style / suggester / yaml"

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.

@lance
Copy link
Member

lance commented Jul 11, 2023

/override unit-tests_func_main

@knative-prow
Copy link

knative-prow bot commented Jul 11, 2023

@lance: Overrode contexts on behalf of lance: unit-tests_func_main

In response to this:

/override unit-tests_func_main

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.

@lance
Copy link
Member

lance commented Jul 11, 2023

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 11, 2023
@lance
Copy link
Member

lance commented Jul 11, 2023

LOL I was trying to override everything, thinking prow was still balking on stuff - but the problem was simply that it didn't have the lgtm

@knative-prow knative-prow bot merged commit 79c36ee into knative:main Jul 11, 2023
40 of 41 checks passed
@matejvasek
Copy link
Contributor

@zroubalik does this work on Red Hat Sandbox?

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. 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.

3 participants