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 "volume" PipelineResource #1184

Closed
wants to merge 1 commit into from
Closed

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Aug 12, 2019

Changes

This change adds a new resource type called "Volume", that exposes a Kubernetes Volume to the Task. This volume can be a reference to an existing Volume, or one can be created automatically.

This builds on #1087 and should obsolete it.

Fixes #1062

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.

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

A new Storage resource type called "Volume" is now available.

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@tekton-robot tekton-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 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/storage_resource.go 45.0% 42.9% -2.1
pkg/apis/pipeline/v1alpha1/taskrun_types.go 78.6% 75.9% -2.7
pkg/apis/pipeline/v1alpha1/volume_resource.go Do not exist 30.0%

@abayer
Copy link
Contributor

abayer commented Aug 12, 2019

@googlebot I consent

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit and removed cla: no labels Aug 12, 2019
@abayer
Copy link
Contributor

abayer commented Aug 12, 2019

@dlorenc Looks dang good at first glance. I'll give it a closer review ASAP.

@bobcatfish bobcatfish changed the title Abayer volume Add "volume" PipelineResource Aug 12, 2019
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.

I am excited about this!

Few requests:

GetUploadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error)
GetDownloadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error)
GetDownloadVolumeSpec(*TaskSpec, *TaskRun, kubernetes.Interface) ([]corev1.Volume, error)
GetUploadVolumeSpec(*TaskSpec, *TaskRun, kubernetes.Interface) ([]corev1.Volume, error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we include docstrings for these to explain what the function is expected to do (and what the new params are for?)

}
}

func (s *VolumeResource) GetDownloadVolumeSpec(ts *TaskSpec, tr *TaskRun, c kubernetes.Interface) ([]corev1.Volume, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can has docstrings for all new functions 🙏

Copy link
Collaborator

Choose a reason for hiding this comment

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

do you think it could make sense to pass specifically in the function for creating volumes, instead of the whole kubernetes.Interface? (would probably make it easier to write some unit tests for that also)

)

// VolumeResource is a volume from which to get artifacts which is required
// by a Build/Task for context (e.g. a archive from which to build an image).
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably can use "task" instead of "build/task"

func (s *VolumeResource) GetPvcMount() corev1.VolumeMount {
return corev1.VolumeMount{
Name: s.Name, // resource pvc name
MountPath: VolumeMountDir, // nothing should be mounted here
Copy link
Collaborator

Choose a reason for hiding this comment

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

the comments above dont really add a lot , i think we've been copy and pasting them around for a while now

@cameronbraid
Copy link

It might be a good idea to support specifying a storage class in addition to the volume size

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit labels Sep 17, 2019
@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 17, 2019
@bobcatfish bobcatfish force-pushed the abayer-volume branch 2 times, most recently from 1caba45 to 7811c5f Compare September 17, 2019 23:39
@bobcatfish bobcatfish added cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit and removed cla: no labels Sep 17, 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!
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
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/build_gcs_resource.go 86.1% 83.8% -2.3
pkg/apis/pipeline/v1alpha1/cloud_event_resource.go 88.2% 83.3% -4.9
pkg/apis/pipeline/v1alpha1/cluster_resource.go 76.3% 74.4% -2.0
pkg/apis/pipeline/v1alpha1/gcs_resource.go 87.2% 85.0% -2.2
pkg/apis/pipeline/v1alpha1/git_resource.go 78.9% 75.0% -3.9
pkg/apis/pipeline/v1alpha1/image_resource.go 56.2% 52.9% -3.3
pkg/apis/pipeline/v1alpha1/pipelineresource_validation.go 89.4% 87.5% -1.9
pkg/apis/pipeline/v1alpha1/pull_request_resource.go 85.0% 81.0% -4.0
pkg/apis/pipeline/v1alpha1/resource_types.go 11.8% 16.7% 4.9
pkg/apis/pipeline/v1alpha1/storage_resource.go 95.0% 85.7% -9.3
pkg/apis/pipeline/v1alpha1/taskrun_types.go 72.7% 69.6% -3.2
pkg/apis/pipeline/v1alpha1/volume_resource.go Do not exist 63.2%
pkg/reconciler/pipelinerun/pipelinerun.go 82.6% 81.7% -0.9
pkg/reconciler/taskrun/taskrun.go 71.6% 72.2% 0.6
test/pvc.go Do not exist 0.0%

@bobcatfish bobcatfish added cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit and removed cla: no labels Oct 1, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@bobcatfish
Copy link
Collaborator

        message: 'Invalid TaskSpec: Operation cannot be fulfilled on resourcequotas "gke-resource-quotas":
          StorageError: invalid object, Code: 4, Key: /registry/resourcequotas/arendelle-7hqfr/gke-resource-quotas,
          ResourceVersion: 0, AdditionalErrorMsg: Precondition failed: UID in precondition:
          65c88d9d-e482-11e9-8227-42010a8001ce, UID in object meta: '

wut

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign dlorenc
You can assign the PR to them by writing /assign @dlorenc in a comment when ready.

The full list of commands accepted by this bot can be found 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

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@tekton-robot tekton-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 9, 2019
@googlebot googlebot added cla: no and removed cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit labels Oct 9, 2019
@bobcatfish bobcatfish added cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit and removed cla: no labels Oct 10, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@tekton-robot
Copy link
Collaborator

This will allow copying content either into or out of a `TaskRun`,
either to an existing volume or a newly created volume. The immediate
use case is for copying a pipeline's workspace to be made available as
the input for another pipeline's workspace without needing to deal
with uploading everything to a bucket. The volume, whether already
existing or created, will not be deleted at the end of the
`PipelineRun`, unlike the artifact storage PVC.

The Volume resource is a sub-type of the general Storage resource.

Since this type will require the creation of a PVC to function (to be
configurable later), this commit adds a Setup interface that
PipelineResources can implement if they need to do setup that involves
instantiating objects in Kube. This could be a place to later add
features like caching, and also is the sort of design we'd expect once
PipelineResources are extensible (PipelineResources will be free to do
whatever setup they need).

The behavior of this volume resource is:
1. For inputs, copy data _from_ the PVC to the workspace path
2. For outputs, copy data _to_ the PVC from the workspace path

If a user does want to control where the data is copied from, they can:
1. Add a step that copies from the location they want to copy from on
   disk to /workspace/whatever
2. Use the "targetPath" argument in the PipelineResource to control the
   location the data is copied to (still relative to targetPath
   https://github.com/tektoncd/pipeline/blob/master/docs/resources.md#controlling-where-resources-are-mounted)
3. Use `path` https://github.com/tektoncd/pipeline/blob/master/docs/resources.md#overriding-where-resources-are-copied-from
   (tbd if we want to keep this feature post PVC)

The underlying PVC will need to be created by the Task reonciler, if
only a TaskRun is being used, or by the PipelineRun reconciler if a
Pipeline is being used. The PipelineRun reconciler cannot delegate this
to the TaskRun reconciler b/c when two different reconcilers create PVCs
and Tekton is running on a regional GKE cluster, they can get created in
different zones, resulting in a pod that tries to use both being
unschedulable.

In order to actually schedule a pod using two volume resources, we had
to:
- Use a storage class that can be scheduled in a GKE regional cluster
  https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/regional-pd
- Either use the same storage class for the PVC attached automatically
  for input/output linking or don't use the PVC (chose the latter!)

This commit removes automatic PVC copying for input output linking of
the VolumeResource b/c since it itself is a PVC, there is no need to
copy between an intermediate PVCs. This makes it simpler to make a Task
using the VolumeResource schedulable, removes redundant copying, and
removes a side effect where if a VolumeResources output was linked to an
input, the Task with the input would see _only_ the changes made by the
output and none of the other contents of the PVC.

Also removing the docs on the `paths` param (i.e. "overriding where
resources are copied from") because it was implemented such that it
would only work in the output -> input linking PVC case and can't
actually be used by users and it will be removed in tektoncd#1284.

fixes tektoncd#1062

Co-authored-by: Dan Lorenc <lorenc.d@gmail.com>
Co-authored-by: Christie Wilson <bobcatfish@gmail.com>
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit labels Oct 10, 2019
@bobcatfish
Copy link
Collaborator

I'm gonna close this and start a new pull request.

@bobcatfish bobcatfish closed this Oct 10, 2019
@tekton-robot
Copy link
Collaborator

@tekton-robot
Copy link
Collaborator

@dlorenc: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-tekton-pipeline-build-tests 18bd7ff link /test pull-tekton-pipeline-build-tests
pull-tekton-pipeline-integration-tests 18bd7ff link /test pull-tekton-pipeline-integration-tests

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: no 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.

Add "volume" input/output resource
6 participants