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

WorkingDir inherit permissions of parent directory #7983

Conversation

chitrangpatel
Copy link
Contributor

@chitrangpatel chitrangpatel commented May 24, 2024

Prior to this PR, workingDirInit did not deal handle permissions of nested child directories in workingDirs. This PR provides the same permissions as that of the existing parent directory. This allows non-root users to also create relative sub diectories in a workspace if used as a workingDir.

Fixes #7804.

Changes

If the complete path in used as the workingDir already exists, the permissions are not modified.
Only non-existent child directories are created with the same permissions as the existing parent.

Submitter Checklist

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

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

WorkingDir inherit permissions of parent directory

/kind bug

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels May 24, 2024
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 24, 2024
@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 ask for approval from chitrangpatel after the PR has been reviewed.

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

@chitrangpatel
Copy link
Contributor Author

/assign @vdemeester

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/workingdirinit/main.go 23.1% 5.9% -17.2
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/workingdirinit/main.go 23.1% 5.9% -17.2
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@chitrangpatel chitrangpatel force-pushed the fix-workingdir-init-permissions branch from 8996c9c to b47ec86 Compare May 24, 2024 17:39
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@JeromeJu JeromeJu self-assigned this May 24, 2024
@chitrangpatel chitrangpatel force-pushed the fix-workingdir-init-permissions branch from b47ec86 to 764baa9 Compare May 24, 2024 19:10
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/workingdirinit/main.go 23.1% 5.9% -17.2
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/workingdirinit/main.go 23.1% 5.9% -17.2
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@@ -473,7 +473,6 @@ func TestPodBuild(t *testing.T) {
Image: images.WorkingDirInitImage,
Command: []string{"/ko-app/workingdirinit"},
Args: []string{filepath.Join(pipeline.WorkspaceDir, "test")},
WorkingDir: pipeline.WorkspaceDir,
Copy link
Member

Choose a reason for hiding this comment

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

Shall we keep this for backwards-compatibility? and add a new one without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need. The workingDir only enabled creating directories inside the /workspace folder. We already account for it. It does not matter what the workingDir is since the init container only handles absolute paths now.

@@ -61,12 +60,11 @@ func TestWorkingDirInit(t *testing.T) {
Name: "working-dir-initializer",
Image: images.WorkingDirInitImage,
Command: []string{"/ko-app/workingdirinit"},
Args: []string{"/workspace/bbb", "aaa", "zzz"},
WorkingDir: pipeline.WorkspaceDir,
Copy link
Member

Choose a reason for hiding this comment

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

ditto: shall we adding test cases instead of updating those?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again. I think the interesting bit is how this is used in conjunction with the init container. These are the arguments that we pass to the init container. We cannot keep things partially compatible. The eventual outcome is backwards compatible though.

If this is worrisome then I'm happy to split things up as they were. I just think this is cleaner and a transparent change so users shouldn't be affected by it.

Prior to this PR, workingDirInit did not deal handle permissions of
nested child directories in workingDirs. This PR provides the same
permissions as that of the existing parent directory. This allows
non-root users to also create relative sub diectories in a workspace
if used as a workingDir.
Fixes tektoncd#7804.
@chitrangpatel chitrangpatel force-pushed the fix-workingdir-init-permissions branch from 764baa9 to 5993c98 Compare May 27, 2024 15:44
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/workingdirinit/main.go 23.1% 6.1% -17.0
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
cmd/workingdirinit/main.go 23.1% 6.1% -17.0
pkg/pod/workingdir_init.go 95.0% 100.0% 5.0

@chitrangpatel chitrangpatel added this to the Pipeline v0.61 milestone May 27, 2024
@chitrangpatel chitrangpatel marked this pull request as draft May 29, 2024 16:44
@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 29, 2024
@chitrangpatel chitrangpatel removed this from the Pipeline v0.61 milestone Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Workingdir does not give write access to the group
4 participants