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

Don't call UpdateLayerIDMap when creating a layer with no parent #1735

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Oct 19, 2023

Warning: I don’t really know what I’m doing.

AFAICS this call is intended to "remap" the parent layer's contents to the desired IDMappings; but when there is no parent layer, there is nothing to remap.

Motivation: I’m trying to get c/image tests of c/storage working completely unprivileged.

On macOS that actually works out of the box (where some potentially relevant points are that after #811 , pkg/chrootarchive does not chroot on Darwin, and that pkg/idtools.SafeChown does not really chown on Darwin).

On Linux, the out-of-the-box setup starts initializing vfs by chowning to (0, 0), and that fails. There is some pre-existing code in https://github.com/containers/image/blob/6bf0d1f0ae6682a5dd9a9d07d41f78be160d4383/storage/storage_test.go#L69-L78 to avoid that by remapping (“user-to-current”), and that part seems to work on Linux…

… but with the “user-to-current” ID maps, on macOS, layer creation fails of the first (no-parent) layer fails, because the current logic gets the ID map from the new layer from the store’s configuration (”user-to-current”), but defaults the ID map of the (nonexistent) parent to empty, sees a difference, and triggers UpdateLayerIDMap. And that tries to really chroot, and fails.

(Ultimately, on Linux, layer extraction seems to always chroot, so I am failing with my overall goal. Anyway, this seems to be conceptually the right thing to do.)


So, this entirely avoids the UpdateLayerIDMap call. Again, warning: I don’t know what I’m doing.

Some alternatives:

  • Currently, Store.PutLayer sets the ID maps from its options; but the nonexistent-parent ID map is set to entirely empty. Instead, Store.PutLayer could call layerStore.create with new options providing the store’s ID map to use as the nonexistent-parent ID map value. That would have the same effect, except that layerStore.create would think there is a “parent ID map”. I think that’s more invasive, and conceptually a bit less correct (there is no parent, so there is no parent ID map at all).
  • Maybe the UpdateLayerIDMap implementation should follow in steps of Limited support for operating on images on macOS #811 and not chroot, even if it is called.

@nalind @giuseppe PTAL

@giuseppe
Copy link
Member

I am fine with this change, I've tested it and seems to work well

@rhatdan
Copy link
Member

rhatdan commented Oct 20, 2023

LGTM

@rhatdan
Copy link
Member

rhatdan commented Oct 25, 2023

@mtrmac ready to go forward with this?

@mtrmac
Copy link
Collaborator Author

mtrmac commented Oct 25, 2023

Yes, I think this makes sense to merge.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, mtrmac

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

@giuseppe
Copy link
Member

/hold

@giuseppe
Copy link
Member

@mtrmac do you want to change the commit message or do we keep the "RFC:" tag there?

@rhatdan rhatdan changed the title RFC: Don't call UpdateLayerIDMap when creating a layer with no parent Don't call UpdateLayerIDMap when creating a layer with no parent Oct 25, 2023
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
AFAICS this call is intended to "remap" the parent layer's contents to the
desired IDMappings; but when there is no parent layer, there is
nothing to remap.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@mtrmac
Copy link
Collaborator Author

mtrmac commented Oct 25, 2023

Oops, fixed the commit title. Thanks.

@giuseppe
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 25, 2023
@openshift-ci openshift-ci bot merged commit a254f71 into containers:main Oct 25, 2023
19 checks passed
@mtrmac mtrmac deleted the no-chown-on-first-layer branch October 25, 2023 17:57
mtrmac added a commit to mtrmac/image that referenced this pull request Oct 25, 2023
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
mtrmac added a commit to mtrmac/image that referenced this pull request Oct 25, 2023
After containers/storage#1735 , we don't need
the conditional, so remove it.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
mtrmac added a commit to mtrmac/image that referenced this pull request Oct 25, 2023
After containers/storage#1735 , we don't need
the condition, so remove it.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
mtrmac added a commit to mtrmac/image that referenced this pull request Oct 31, 2023
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
mtrmac added a commit to mtrmac/image that referenced this pull request Oct 31, 2023
After containers/storage#1735 , we don't need
the condition, so remove it.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
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.

None yet

3 participants