Skip to content

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

Merged
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
giuseppe:create-merged-only-if-it-doesnot-exist
Mar 11, 2024
Merged

overlay: create the merged path only if it does not exist#1858
openshift-merge-bot[bot] merged 1 commit intocontainers:mainfrom
giuseppe:create-merged-only-if-it-doesnot-exist

Conversation

@giuseppe
Copy link
Copy Markdown
Member

follow-up for ccb70a7

more information here: #1827 (comment)

@openshift-ci
Copy link
Copy Markdown
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

Details 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <gscrivan@redhat.com>
@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
Copy Markdown
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
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