-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Ensure pullrequest-init is based on a root image #3055
Conversation
/kind bug |
The PullRequest Resource, when used as an output, is able to read in a pr.json to determine if there have been any changes that require syncing to github. pr.json may have been written by any prior Step with any ownership settings. If pr.json was written with root permissions then the PullRequest Resource needs to be have permissions to read that file. The PullRequest Resource image has been based on a nonroot image in our `.ko.yaml` since 0.13 of Tekton Pipelines ([`.ko.yaml` was updated here](#2606)). However, the published images did not match the configuration in the `.ko.yaml` until 0.15.0 ([our `tekton/publish.yaml` was brought into line with `.ko.yaml` here](#3018)). Given that copying or writing pr.json in a Step can result in the file being owned by root using a nonroot image is not a suitable choice of base image - the output PullRequest attempts to open pr.json and hits a permissions error. This commit updates the PullRequest image to be based on distroless static instead of nonroot and adds an example yaml file that should exercise the behaviour of copying the file from an input to output pullrequest resource.
Ohhhh! Nice debugging. |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bobcatfish 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 |
@@ -6,6 +6,9 @@ baseImageOverrides: | |||
github.com/tektoncd/pipeline/cmd/git-init: gcr.io/tekton-nightly/github.com/tektoncd/pipeline/build-base:latest | |||
# GCS fetcher needs root due to workspace permissions | |||
github.com/tektoncd/pipeline/vendor/github.com/GoogleCloudPlatform/cloud-builders/gcs-fetcher/cmd/gcs-fetcher: gcr.io/distroless/static:latest | |||
# PullRequest resource needs root because in output mode it needs to access pr.json | |||
# which might have been copied or written with any level of permissions. | |||
github.com/tektoncd/pipeline/cmd/pullrequest-init: gcr.io/distroless/static:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it true that this would apply to any container that needs to operate on any file written by a previous step? if so this feels like it might be a slightly larger problem since it feels like communicating b/w steps is a big part of our design 🤔 (maybe im over exaggerating that?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I do think that's a risk we might want to spend a bit more time analysing. Here I'm fixing the immediate issue we observed in dogfooding wrt the PR pipeline resource.
fixes #3054
Changes
The PullRequest Resource, when used as an output, is able to
read in a pr.json to determine if there have been any changes
that require syncing to github. pr.json may have been written
by any prior Step with any ownership settings. If pr.json
was written with root permissions then the PullRequest Resource
needs to be have permissions to read that file.
The PullRequest Resource image has been based on a nonroot
image in our
.ko.yaml
since 0.13 of Tekton Pipelines (.ko.yaml
wasupdated here).
However, the published images did not match the configuration in the
.ko.yaml
until 0.15.0 (ourtekton/publish.yaml
was brought into linewith
.ko.yaml
here).Given that copying or writing pr.json in a Step can result in the file
being owned by root using a nonroot image is not a suitable choice
of base image - the output PullRequest attempts to open pr.json and
hits a permissions error.
This commit updates the PullRequest image to be based on
distroless static instead of nonroot and adds an example yaml
file that should exercise the behaviour of copying the file from
an input to output pullrequest resource.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
Release Notes