Skip to content

refactor(pkg/archive): factor out createImpliedDirectories helper #44196

Merged
thaJeztah merged 2 commits intomoby:masterfrom
neersighted:createImpliedDirectories
Sep 27, 2022
Merged

refactor(pkg/archive): factor out createImpliedDirectories helper #44196
thaJeztah merged 2 commits intomoby:masterfrom
neersighted:createImpliedDirectories

Conversation

@neersighted
Copy link
Copy Markdown
Member

@neersighted neersighted commented Sep 26, 2022

- What I did

  • Factor out common 'implied' directory creation code in pkg/archive into a helper.
  • Update the non-diff/overlay codepath to use the same permissions mask as the (more common) overlay codepath.
  • Document why the constant 0755 was chosen, and why image authors cannot currently rely on this value given it is not standardized/is fully implementation-defined.
  • Add tests to ensure the constant is used and directories are created with the expected permissions.

- How to verify it
CI

- Description for the changelog
Update the default permissions for directories implied but not explicitly defined by a layer to 0755 across all graphdrivers.

- A picture of a cute animal (not mandatory but encouraged)
image

@neersighted neersighted added status/2-code-review impact/changelog area/images Image Service kind/refactor PR's that refactor, or clean-up code labels Sep 26, 2022
@neersighted neersighted added this to the v-next milestone Sep 26, 2022
@neersighted
Copy link
Copy Markdown
Member Author

For additional context regarding why this value is presently unreliable/implementation defined, see #44106 (comment).

@neersighted neersighted force-pushed the createImpliedDirectories branch from 3b119a2 to 395f455 Compare September 26, 2022 14:56
Comment thread pkg/archive/archive.go
Comment thread pkg/archive/archive.go Outdated
Comment thread pkg/archive/archive.go Outdated
Comment thread pkg/archive/archive_test.go Outdated
Comment thread pkg/archive/archive_test.go Outdated
Comment thread pkg/archive/archive_test.go Outdated
Comment thread pkg/archive/archive_test.go Outdated
This code was duplicated in two places -- factor it out, add
documentation, and move magic numbers into a constant.

Additionally, use the same permissions (0755) in both code paths, and
ensure that the ID map is used in both code paths.

Co-authored-by: Vasiliy Ulyanov <[email protected]>
Signed-off-by: Bjorn Neergaard <[email protected]>
Signed-off-by: Vasiliy Ulyanov <[email protected]>
@neersighted neersighted force-pushed the createImpliedDirectories branch from 395f455 to 64e5936 Compare September 26, 2022 17:19
@neersighted neersighted requested a review from corhere September 26, 2022 17:20
@neersighted neersighted force-pushed the createImpliedDirectories branch from 64e5936 to 2e64eb6 Compare September 26, 2022 17:43
Co-authored-by: Cory Snider <[email protected]>
Signed-off-by: Bjorn Neergaard <[email protected]>
@neersighted neersighted force-pushed the createImpliedDirectories branch from 2e64eb6 to 5dff494 Compare September 26, 2022 17:46
Copy link
Copy Markdown
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

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

:shipit:

Comment thread pkg/archive/archive.go
Comment thread pkg/archive/archive.go
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah
Copy link
Copy Markdown
Member

arf... I edited the top description, but that triggered another run of Jenkins, well 🤷‍♂️

@neersighted
Copy link
Copy Markdown
Member Author

arf... I edited the top description, but that triggered another run of Jenkins, well 🤷‍♂️

For what it's worth, I already included the issue linking in the body, but at the bottom. I'll adopt the bulleted-on-top style in the future 😅

@thaJeztah
Copy link
Copy Markdown
Member

For what it's worth, I already included the issue linking in the body, but at the bottom.

Oh! I completely overlooked.

I nowadays also use the bullet-list formatting (where suitable), which renders the links with the linked description; not always useful, but sometimes saves me from having to "mouse-hover" (or "click") to see the linked issue/

@thaJeztah thaJeztah merged commit a4f3c08 into moby:master Sep 27, 2022
@neersighted neersighted deleted the createImpliedDirectories branch September 27, 2022 17:46
@neersighted
Copy link
Copy Markdown
Member Author

@thaJeztah I've gone ahead and applied the cherry-pick label since backporting this was mentioned. Feel free to remove it if you conclude that it's not worth backporting (likewise, I am happy to backport on request, but don't have any special interest personally).

@thaJeztah
Copy link
Copy Markdown
Member

@neersighted ah, thanks; thought it was on there already; yes, if you have time to prepare a cherry pick, that'd be good 👍

@neersighted
Copy link
Copy Markdown
Member Author

@neersighted ah, thanks; thought it was on there already; yes, if you have time to prepare a cherry pick, that'd be good 👍

#44207 is up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong directory permissions with btrfs or devicemapper storage drivers

3 participants