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

Add ID-mapping capabilities #1392

Merged
merged 3 commits into from
Nov 4, 2024
Merged

Conversation

sondavidb
Copy link
Contributor

@sondavidb sondavidb commented Oct 9, 2024

Issue #, if available:

Description of changes:
Working off the POC at Kern--/idmap-v2, added id-mapping capabilities to the snapshotter.

The PR additionally has a commit to add a separate ctr binary nerdctl binary (EDIT: later iterations changed this to a nerdctl binary) to the container. This is because containerd doesn't support id-mapping in ctr nerdctl in an official release yet, so we need a specific binary to pass the proper labels. This is done by adding a new Makefile target and copying it in the Dockerfile, but I'm open to different approaches here.

Testing performed:
make test and make integration

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sondavidb sondavidb requested a review from a team as a code owner October 9, 2024 01:28
@github-actions github-actions bot added dependencies Pull requests that update a dependency file go Pull requests that update Go code testing Unit and/or integration tests labels Oct 9, 2024
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch 4 times, most recently from 2d0cf6d to 7f2fd08 Compare October 9, 2024 03:32
Copy link
Contributor

@austinvazquez austinvazquez left a comment

Choose a reason for hiding this comment

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

Thanks for including the modified ctr as a individual commit. Makes it easy to revert if containerd accepts the upstream contribution later.

Overall nice work iterating on this. I would like to see the logging cleaned up a bit. Some considerations:

  1. Quite a bit of info logging occurring. Should some of these be reduced to debug or trace logs? Users running in production operate a large scale, so cost of logs increases quickly. So make each log count.
  2. Prefer structured logging over formatting. Think about the tech that gets paged and has a hard time finding where in code an error originated because it has been formatted.

Makefile Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
fs/fs.go Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
snapshot/snapshot.go Outdated Show resolved Hide resolved
snapshot/snapshot.go Outdated Show resolved Hide resolved
snapshot/snapshot.go Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
fs/layer/node.go Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch from 7f2fd08 to b87f962 Compare October 13, 2024 16:06
@sondavidb
Copy link
Contributor Author

sondavidb commented Oct 13, 2024

New changes address logging concerns as well (EDIT: missed some) as moved the FUSE server setup to a new function. I think this also made the tests pass properly, possibly because I previously didn't setup the fuse logging properly before? NVM, still not good, seems the FUSE servers aren't being set up properly. Might have to do with the layer bit Austin mentioned...There's also parts w/ overlay fallback which means that the layer isn't being setup properly, but the new code shouldn't even be called unless id-mapping is turned on? So I'm a bit confused...

Also added a new internal patch which will make the diff look even bigger but it's just so we can store the patch locally.

@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch from b87f962 to 79b17e1 Compare October 13, 2024 16:50
@sondavidb
Copy link
Contributor Author

FWIW, I tested these changes on the ubuntu runners and they all seemed to pass?? Not sure what it might be indicative of.

sondavidb#20

Copy link
Contributor

@Kern-- Kern-- left a comment

Choose a reason for hiding this comment

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

I'm still reviewing, but I wanted to get my comments in so far before they drift too far.

fs/fs.go Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
idtools/idmap.go Outdated Show resolved Hide resolved
idtools/idmap.go Outdated Show resolved Hide resolved
snapshot/snapshot.go Outdated Show resolved Hide resolved
snapshot/snapshot.go Outdated Show resolved Hide resolved
integration/run_test.go Show resolved Hide resolved
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch 2 times, most recently from 3cb0543 to 28872ee Compare October 28, 2024 23:08
@sondavidb sondavidb closed this Oct 28, 2024
@sondavidb sondavidb reopened this Oct 28, 2024
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch from 28872ee to 02a1575 Compare October 29, 2024 01:03
@sondavidb
Copy link
Contributor Author

Looks like I undid a ton of changes and messed things up while rebasing 😓 Manually re-added everything I think but should double check.

Will double-check multi-uid/gid mapping shenanigans tomorrow as well as using nerdctl instead of ctr but I'll have to see.

@sondavidb sondavidb closed this Oct 29, 2024
@sondavidb sondavidb reopened this Oct 29, 2024
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch from 02a1575 to fe36d4d Compare October 29, 2024 01:14
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch from 63bb0a7 to 0728c4b Compare October 30, 2024 22:00
Copy link
Contributor

@Shubhranshu153 Shubhranshu153 left a comment

Choose a reason for hiding this comment

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

not sure about the -pR change, we need to test more to approve this
if with -a the concerns about hardlink is indeed true then we can change, otherwise i will prefer not to change this option.

idtools/idmap.go Outdated Show resolved Hide resolved
Shubhranshu153
Shubhranshu153 previously approved these changes Oct 30, 2024
@sondavidb
Copy link
Contributor Author

Ended up just using -a --no-preserve=links and it seems to work

Shubhranshu153
Shubhranshu153 previously approved these changes Oct 31, 2024
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch from 33c0b64 to 49f5d3b Compare October 31, 2024 17:44
@github-actions github-actions bot removed the github_actions Pull requests that update GitHub Actions code label Oct 31, 2024
@sondavidb
Copy link
Contributor Author

Rebased with main

nerdctl currently does not support ID mapping natively, so this commit
adds the code for us to use a patched version of nerdctl that supports
this.

Once this is supported upstream natively, we can revert this.

Signed-off-by: David Son <[email protected]>
Taken from containerd commit 83aaa89, this adds the necessary tools to
add idmapping capabilities to SOCI.

Signed-off-by: David Son <[email protected]>
austinvazquez
austinvazquez previously approved these changes Oct 31, 2024
Copy link
Contributor

@austinvazquez austinvazquez left a comment

Choose a reason for hiding this comment

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

Thanks for tightening up the logging. It looks much better!

Change LGTM.

fs/fs.go Show resolved Hide resolved
idtools/idmap.go Show resolved Hide resolved
idtools/idmap.go Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
fs/fs.go Outdated Show resolved Hide resolved
integration/run_test.go Show resolved Hide resolved
snapshot/snapshot.go Outdated Show resolved Hide resolved
@sondavidb sondavidb force-pushed the add-uid-gid-mapping branch 2 times, most recently from a536f13 to c19f309 Compare November 1, 2024 00:26
@sondavidb
Copy link
Contributor Author

Newest changes should address most recent concerns with variable naming and also adds testing for files inside the container as well

@sondavidb
Copy link
Contributor Author

After this is merged I think documentation on how to actually use this feature would be nice. I can take it as a followup.

Kern--
Kern-- previously approved these changes Nov 1, 2024
This commit adds ID mapping functionality in SOCI. ID mapping is enabled
if the correct labels are passed through.

To avoid having containerd handle the ID mapping, we must declare in the
containerd config file that the snapshotter supports ID mapping.

Note that usage of this feature requires proxy plugins to have
capabilities, which is only supported in containerd v1.7.23 onwards.

Signed-off-by: David Son <[email protected]>
@sondavidb sondavidb merged commit f8309af into awslabs:main Nov 4, 2024
21 checks passed
@sondavidb sondavidb deleted the add-uid-gid-mapping branch November 6, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file go Pull requests that update Go code testing Unit and/or integration tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants