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

composefs fixes #2069

Conversation

giuseppe
Copy link
Member

some improvements for composefs, more details in each patch

Copy link
Contributor

openshift-ci bot commented Aug 20, 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

@cgwalters
Copy link
Contributor

Is this aiming to fix #2042 ?

Copy link
Contributor

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

This is only a slightly-past-superficial level of review, but LGTM

Comment on lines 1467 to 1468
if err := fileutils.Exists(mergedDir); err != nil && os.IsNotExist(err) {
if err := idtools.MkdirAllAs(mergedDir, 0o700, rootUID, rootGID); err != nil && !os.IsExist(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this code existed before and you're just moving it but...IMO doing stat+mkdir is just unnecessary syscall traffic - we're already checking !os.IsExist from the MkdirAllAs invocation.

(BTW in almost every code base I'm involved with I end up with an EnsureDirectory helper API which is the equivalent of these two things)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we added the outer fileutils.Exists because MkdirAllAs chowns an existing directory, while in this case we don't want to do it when the merged directory exists (it might be in an additional store).

I'll change it to use MkdirAllAndChownNew

// not a composefs layer, ignore it
continue
}
dir, err := os.MkdirTemp(d.runhome, "composefs-mnt")
fd, err := openComposefsMount(composefsData)
Copy link
Contributor

Choose a reason for hiding this comment

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

but access directly the files through the mount fd.

Huh...I didn't know one could do that...interesting and quite useful!

Copy link
Contributor

@cgwalters cgwalters Aug 20, 2024

Choose a reason for hiding this comment

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

Reminder to myself and anyone interested in more: https://brauner.io/2023/02/28/mounting-into-mount-namespaces.html notes this:

... and with the added benefit that the mount never actually had to appear anywhere in the filesystem hierarchy and thus never had to belong to any mount namespace. This alone is already a very powerful tool but we won’t go into depth today.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
this is a preparation patch for the next commit

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
but access directly the files through the mount fd.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
move the check for a previously mounted "merged" directory before
attempting any composefs mount.
It prevents mounting the composefs blobs to then throw them away as it
reuses the already existing mounted path when possible.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@giuseppe giuseppe force-pushed the composefs-do-not-make-mount-visible branch from bcbeb7d to 57a4177 Compare August 21, 2024 06:20
@giuseppe
Copy link
Member Author

Is this aiming to fix #2042 ?

Since it fails on move_mount, I feel it has something to do with mount propagations, so this PR might have an impact as we need less mounts, but I am not sure as I was never able to reproduce it locally yet.

use MkdirAllAndChownNew instead of checking for the directory
existence first and then create it if missing.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@rhatdan
Copy link
Member

rhatdan commented Aug 21, 2024

LGTM

@cgwalters
Copy link
Contributor

Since it fails on move_mount, I feel it has something to do with mount propagations, so this PR might have an impact as we need less mounts, but I am not sure as I was never able to reproduce it locally yet.

OK, makes sense - that's the kind of thing that I think would be good in one of the commit messages just for future reference for others to avoid needing to backref to the PR: say in f6ca317 or so.

But that's just something for future changes
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Aug 21, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 7908bb8 into containers:main Aug 21, 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