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

overlay: create the merged path only if it does not exist #1858

Conversation

giuseppe
Copy link
Member

follow-up for ccb70a7

more information here: #1827 (comment)

Copy link
Contributor

openshift-ci bot commented Mar 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe

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

if err := idtools.MkdirAs(mergedDir, 0o700, rootUID, rootGID); err != nil && !os.IsExist(err) {
return "", err
// attempt to create the merged dir only if it doesn't exist.
if _, err := os.Stat(mergedDir); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to move the os.IsExist check here.

Any chance we can add a test?

Copy link
Member

Choose a reason for hiding this comment

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

Probably not a bad idea to add byt the MkdirAs command below will blow up with similar error.

@giuseppe giuseppe force-pushed the create-merged-only-if-it-doesnot-exist branch from 09b8195 to 0441674 Compare March 11, 2024 14:27
@giuseppe
Copy link
Member Author

added test and amended the suggestion

if err := idtools.MkdirAs(mergedDir, 0o700, rootUID, rootGID); err != nil && !os.IsExist(err) {
return "", err
// Attempt to create the merged dir only if it doesn't exist.
if _, err := os.Stat(mergedDir); err != nil && !os.IsExist(err) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if _, err := os.Stat(mergedDir); err != nil && !os.IsExist(err) {
if _, err := os.Stat(mergedDir); err != nil && os.IsExist(err) {

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, it should really be os.IsNotExist(err)

Copy link
Member

Choose a reason for hiding this comment

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

And you are not supposted to use IsExist any longer, errors.Is(err, fs.ErrNotExist) But it looks like we have some cases of IsNotExist in podman.

@giuseppe giuseppe force-pushed the create-merged-only-if-it-doesnot-exist branch from 0441674 to 0fbd068 Compare March 11, 2024 14:51
follow-up for ccb70a7

more information here: containers#1827 (comment)

Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe giuseppe force-pushed the create-merged-only-if-it-doesnot-exist branch from 0fbd068 to 846f78a Compare March 11, 2024 15:08
@rhatdan
Copy link
Member

rhatdan commented Mar 11, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Mar 11, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 8fbdbaa into containers:main Mar 11, 2024
18 checks passed
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.

3 participants