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

Initialize working dirs inside workspace dir #726

Closed
wants to merge 1 commit into from

Conversation

dicarlo2
Copy link
Contributor

@dicarlo2 dicarlo2 commented Apr 4, 2019

Changes

In order to allow steps to define workingDirs that are subdirectories of the workspace directory we need to make sure they have been created first since they will not exist on startup.

Fixes #725

Note: this PR does not solve the general problem of ensuring all valid combinations of workingDir + volumes + volume mounts will not fail, instead opting to keep things simple and solve the most common case as a first pass - setting the working directory to the cloned git repository (or other input resource folder). We also do not check that the workingDir path actually refers to the implicit workspace volume (as opposed to a user defined one that they've mounted at the same path) because it keeps the logic simple and the worst case is we have an additional empty directory in the implicit workspace volume.

Adds an additional parameter to the controller config for the image to use for this container. We could have reused the other bash image parameter, but it makes for a nice extension point to tekton to keep them separate IMO since it allows overriding specific bits of functionality should the user desire.

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.

Release Notes

Fix setting workingDirs that are subdirectories of the default workspace directory

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Apr 4, 2019
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 4, 2019
@dwnusbaum
Copy link
Contributor

/ok-to-test

@tekton-robot tekton-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 4, 2019
@dicarlo2
Copy link
Contributor Author

dicarlo2 commented Apr 4, 2019

/retest

@@ -35,6 +35,7 @@ spec:
"-git-image", "github.com/tektoncd/pipeline/cmd/git-init",
"-nop-image", "github.com/tektoncd/pipeline/cmd/nop",
"-bash-noop-image", "github.com/tektoncd/pipeline/cmd/bash",
"-bash-working-dir-image", "github.com/tektoncd/pipeline/cmd/bash",
Copy link
Member

Choose a reason for hiding this comment

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

Why not using bash-noop-image instead of having a new flag ? (we were also thinking of renaming this one as the noop make it more scarier than it is)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use the noop image, though my thinking was that it's nice to have separate arguments for users to override if necessary. I.e. if for some reason in a user's setup they need to override the image that's used for creating working directories, e.g. to have their own custom logic run, but don't want to change it for the current use of bash-noop-image (inside of the artifact setup). Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

That SGTM @dicarlo2

Copy link
Collaborator

Choose a reason for hiding this comment

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

(besides @vdemeester I think we can actually get rid of the noop-image now that we're not using init containers right? i'm having deja vu like we already discussed this... 🤔🤔🤔)

Copy link
Collaborator

Choose a reason for hiding this comment

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

(ahahahaa that was a different image and you already removed it @dicarlo2 🤣 🤣 🤣 #715 thank you 🙏 ... meanwhile we have got to get noop out of the name of that flag so ppl like me dont get confuse...)

Copy link
Collaborator

Choose a reason for hiding this comment

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

... and #715 hasn't been merged yet ... i'm going to catch up eventually i promise...

@vdemeester
Copy link
Member

/test pull-tekton-pipeline-integration-tests

@dlorenc
Copy link
Contributor

dlorenc commented Apr 15, 2019

This LGTM except for the question about the prefix check on WorkingDir

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.

Thanks for this @dicarlo2 !! I have some feedback about creating some slightly more focused unit tests (and as a result, potentially changing the function interface a bit)

I also want to know, have you checked how much overhead this adds to TaskRuns that execute the extra container?

@@ -35,6 +35,7 @@ spec:
"-git-image", "github.com/tektoncd/pipeline/cmd/git-init",
"-nop-image", "github.com/tektoncd/pipeline/cmd/nop",
"-bash-noop-image", "github.com/tektoncd/pipeline/cmd/bash",
"-bash-working-dir-image", "github.com/tektoncd/pipeline/cmd/bash",
Copy link
Collaborator

Choose a reason for hiding this comment

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

(besides @vdemeester I think we can actually get rid of the noop-image now that we're not using init containers right? i'm having deja vu like we already discussed this... 🤔🤔🤔)

pkg/reconciler/v1alpha1/taskrun/resources/pod.go Outdated Show resolved Hide resolved
pkg/reconciler/v1alpha1/taskrun/resources/pod.go Outdated Show resolved Hide resolved
@dicarlo2
Copy link
Contributor Author

This LGTM except for the question about the prefix check on WorkingDir

I might just be blind, but I'm not seeing the question. With that said, I did change the check to look at the relpath rather than the prefix, so maybe I fixed it :)

@@ -249,6 +251,52 @@ func TestMakePod(t *testing.T) {
},
Volumes: implicitVolumes,
},
}, {
desc: "working-dir-in-workspace-dir",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this test in so that there's at least one test sanity checking that we add the container as expected.

Copy link
Member

@chmouel chmouel left a comment

Choose a reason for hiding this comment

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

LGTM

workingDirs: []string{"/workspace/foo", "/workspace/bar", "/baz"},
want: "mkdir -p /workspace/foo /workspace/bar",
}, {
desc: "empty",
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe add a test that checks for workingDirs and returns empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'm not following (maybe because I'm tired and it's pretty late here). Can you restate/give an example?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks for clarifying 😄

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chmouel, dicarlo2
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: imjasonh

If they are not already assigned, you can assign the PR to them by writing /assign @imjasonh in a comment when ready.

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

@dicarlo2
Copy link
Contributor Author

I also want to know, have you checked how much overhead this adds to TaskRuns that execute the extra container?

The container executes in < 1 second (GKE n1-standard-8, fwiw). I'd expect the overhead would be dominated by the time taken to download the container, which will vary across user setups. On that note, it might make sense to combine some of the binaries into a single image by default, in particular for the init container images (place tools, and this one).

@chmouel
Copy link
Member

chmouel commented Apr 23, 2019

On that note, it might make sense to combine some of the binaries into a single image by default, in particular for the init container images (place tools, and this one).

👍 that would be a great optimisation indeed!

@dicarlo2
Copy link
Contributor Author

Oh, also, I expect the integration tests will fail since the override-with-bash-working-dir:latest image does not exist - if someone could give me a hand with fixing it that'd be awesome :)

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.

@dicarlo2 I think we don't need to add a new image, just re-use a existing one 👼
Also, small comments on the code 😉

pkg/reconciler/v1alpha1/taskrun/resources/pod.go Outdated Show resolved Hide resolved
pkg/reconciler/v1alpha1/taskrun/resources/pod.go Outdated Show resolved Hide resolved
@dlorenc
Copy link
Contributor

dlorenc commented Apr 23, 2019

I might just be blind, but I'm not seeing the question. With that said, I did change the check to look at the relpath rather than the prefix, so maybe I fixed it :)

D'oh, yeah I think I didn't hit submit or something. Looks good now!

@dlorenc
Copy link
Contributor

dlorenc commented Apr 30, 2019

Looks like this needs a rebase and has a few comments left to address. @dicarlo2 are you still planning to get this fixed up?

@dicarlo2
Copy link
Contributor Author

dicarlo2 commented May 3, 2019

Yup, sorry about the delay, had another one of those weeks where I had too many things on my plate.

@dlorenc
Copy link
Contributor

dlorenc commented May 3, 2019

/test pull-tekton-pipeline-integration-tests

In order to allow steps to define workingDirs that are subdirectories of the workspace directory we need to make sure they have been created first since they will not exist on startup.

Fixes tektoncd#725
@dicarlo2
Copy link
Contributor Author

dicarlo2 commented May 3, 2019

Looks like the override-with-bash-noop image also does not exist.

@abayer
Copy link
Contributor

abayer commented May 8, 2019

/retest

@tekton-robot
Copy link
Collaborator

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

Test name Commit Details Rerun command
tekton-pipeline-unit-tests 2f3691e link /test tekton-pipeline-unit-tests
pull-tekton-pipeline-integration-tests 2f3691e 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.

abayer added a commit to abayer/tektoncd-pipeline that referenced this pull request May 8, 2019
Subsumes tektoncd#726, with a unit test fix and a tweak to make sure that
artifact_bucket_test doesn't try to run in parallel, since that messes
up various PipelineRun tests.

Signed-off-by: Andrew Bayer <[email protected]>
tekton-robot pushed a commit that referenced this pull request May 8, 2019
Subsumes #726, with a unit test fix and a tweak to make sure that
artifact_bucket_test doesn't try to run in parallel, since that messes
up various PipelineRun tests.

Signed-off-by: Andrew Bayer <[email protected]>
@vdemeester
Copy link
Member

#843 is merged, we can close this one 😁
/close

@tekton-robot
Copy link
Collaborator

@vdemeester: Closing this PR.

In response to this:

#843 is merged, we can close this one 😁
/close

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.

@abayer abayer mentioned this pull request May 8, 2019
3 tasks
wlynch pushed a commit to wlynch/pipeline that referenced this pull request May 20, 2019
Subsumes tektoncd#726, with a unit test fix and a tweak to make sure that
artifact_bucket_test doesn't try to run in parallel, since that messes
up various PipelineRun tests.

Signed-off-by: Andrew Bayer <[email protected]>
nikhil-thomas pushed a commit to nikhil-thomas/pipeline that referenced this pull request Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit 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.

Steps with workingDir refuse to start because the directory does not exist on pod startup
9 participants