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

Setup WorkingDir for place-tools init container to avoid permission error #3979

Merged
merged 1 commit into from
Jun 1, 2021

Conversation

barthy1
Copy link
Member

@barthy1 barthy1 commented May 26, 2021

Changes

With 1001 user run-steps-as-non-root test can fail because of missing access permissions, see #3978

Possible solutions are to use 65532 user, which is configured one for gcr.io/distroless/static:nonroot base image or to change working directory to "/" from the default "/home/nonroot"

"/" working directory allows to use not only 65532 user, so this path is chosen.

/kind misc

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in or deleted (only if no user facing changes)

Release Notes

NONE

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. labels May 26, 2021
@tekton-robot tekton-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 26, 2021
@barthy1 barthy1 closed this May 26, 2021
@barthy1 barthy1 reopened this May 26, 2021
@tekton-robot tekton-robot added the kind/misc Categorizes issue or PR as a miscellaneuous one. label May 26, 2021
@ghost
Copy link

ghost commented May 26, 2021

The way this change currently works it appears we're telling users that they may not use any UID in their TaskRun's securityContext which is not provided by the distroless image. But that's an image Tekton is "forcing" on users by having it as the base of the place-tools init container.

One of the steps in this example uses uid 2000 but the ubuntu image does not seem to provide this user. I wonder - does the same error appear when running this step? I guess maybe not because the ubuntu image has the WORKDIR set to /, which is allowed for any UID even if they don't exist in /etc/passwd?

I don't think there's anything specific in place-tools that requires the workingDir to be /home/nonroot. We could override this in Tekton to be be / instead? That way hopefully a TaskRun's securityContext wouldn't trigger this error in our init containers.

With 1001 user run-steps-as-non-root test can fail because of missing
permissions, see tektoncd#3978

Possible solutions is to use 65532 user, which is configured one for
gcr.io/distroless/static:nonroot base image or to change working directory
to "/" from the default "/home/nonroot" as per GoogleContainerTools/distroless#718

"/" working directory allows to use not only 65532 user, so
this path is chosen.

Signed-off-by: Yulia Gaponenko <yulia.gaponenko1@de.ibm.com>
@tekton-robot tekton-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 27, 2021
@@ -95,6 +95,10 @@ func orderContainers(entrypointImage string, commonExtraEntrypointArgs []string,
initContainer := corev1.Container{
Name: "place-tools",
Image: entrypointImage,
// Rewrite default WorkingDir from "/home/nonroot" to "/"
// as suggested at https://github.com/GoogleContainerTools/distroless/issues/718
Copy link

Choose a reason for hiding this comment

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

👍 nice reference.

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, thank you for pointing me out to the option with WorkingDir, I went deeper and found this great and detailed description of the situation.

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 27, 2021
@barthy1 barthy1 changed the title Change nonroot user for examples test Setup WorkingDir for place-tools init container to avoid permission error May 27, 2021
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 Jun 1, 2021
@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

@barthy1
Copy link
Member Author

barthy1 commented Jun 1, 2021

/test pull-tekton-pipeline-alpha-integration-tests

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. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. kind/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesnt merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants