-
Notifications
You must be signed in to change notification settings - Fork 64
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
Support for multiple podman sockets #371
Conversation
…ome other small debugging work
…om the api instance
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
…out the socket we're gonna return
@tgross Do you have any feedback on this PR? Or time in the coming weeks to review this? It's not urgent but I don't want it to die a silent dead either. |
Hi @adriaandens, I've been on PTO the last couple weeks. I've added this to our triage board though. |
Awesome stuff, and would remove an ugly workaround we have for running both rootful and rootless podman containers on the same node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @adriaandens! I've left some comments around configuration especially that I think could use a little redesign, but overall this is looking really good!
Also, can you make sure all your commits are using the email address you signed the CLA with? That'll make the compliance people happy. (Feel free to squash)
driver.go
Outdated
taskConfig: taskState.TaskConfig, | ||
procState: drivers.TaskStateUnknown, | ||
startedAt: taskState.StartedAt, | ||
exitResult: &drivers.ExitResult{}, | ||
logger: d.logger.Named("podmanHandle"), | ||
logger: d.logger.Named("podmanHandle"), // TODO: does this need to be podmanClient aware? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to podman.<socket name>
but I don't see it reflected in journald/journalctl output?
…se the Socket name in the TaskConfig to directly use the correct podman client
…in variables (rootless, cgroup) from driver to podman API because they're podman API dependent (root needs rootless=false, ...)
…our of sockets to be more 'nomad'-like
…se the default socket
@tgross I made several new commits to this PR to take into account your comments. I'll test drive the podman driver in my dev setup to see if I hit any new bugs. The current tests in If you're OK with the new HCL config implementation (a socket path and name (if omitted, resolves to "default")), I can update the README, docs, and also write some examples so it's easy for people to switch over their configs (goal is still to be backwards compatible with the old single |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adriaandens there's a few items the linter just picked up and a couple of as-yet-unresolved comments from before. Another minor item I didn't notice before is that you made all the source files executable (i.e. changed from 0644 to 0755). Can you fix that too?
If you're OK with the new HCL config implementation (a socket path and name (if omitted, resolves to "default")), I can update the README, docs, and also write some examples so it's easy for people to switch over their configs
Sounds good! We'll want a changelog entry as well.
Sorry @adriaandens, the new HCL files need |
Better explanations in README Co-authored-by: Tim Gross <[email protected]>
… from 4.2 the docs mention /run/podman-init: https://docs.podman.io/en/v4.2/markdown/podman-run.1.html
@tgross I ran into the issue of the In the code, I've added an API version to the api.API struct, which I use in the For the Github Actions, it would (although outside of scope for this PR) make sense to run all the tests with multiple Podman versions: the minimal supported by this driver, latest, stable, latest from each major version (3.4.4, 4.9.3, 5.2.3), ... so that there's coverage of the most used versions. |
Yeah this really isn't part of the API per se but our test is making assertions on internal implementation details that we probably shouldn't be. Out of scope for this PR to worry about.
Probably a good idea, but yeah outside of the scope of this PR for sure. I think we're getting close here, but |
…out (fixes Image_Pull_Timeout test)
My PR removes the slowPodman driver (a driver with no http timeout) since having multiple podman sockets would mean additional slowPodman drivers for each. I fixed the issue now by using the streaming http client in the existing driver implementation if a context is passed with a deadline higher than the timeout of the http client in the api. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Spending a bit of time looking at StartTask
is making me think there are some investments we could make in refactoring here. And as noted in the discussion, we should follow-up with improving the test matrix to cover versions of podman we intend to support (it's not clear to me what we've decided there). But this is good-to-merge as-is.
Problem description: I'm using nomad with this driver to run workloads on several VPSs and I want to have support to run containers in rootless mode under different low-privilege users. The current driver only allows you to specify one rootless socket in the driver configuration. Having different host users run containers makes sure that the container UIDs don't map to the same user on the host.
Fix: I have added support for multiple "socket" blocks in the driver configuration. The Tasks can reference a socket using the name of the socket. As far as I have manually tested I have made it backwards compatible (but mutually exclusive) to be combined with the existing
socket_path
. I've added some code so there's always a default podman client option even if it's not specified by the user (preferably this is tackled in the HCL parsing but I didn't find how I could it handle this as an error early in the spec parsing).Would resolve #284 (you can have a root socket and a low-priv user socket), resolve #84 (it implements exactly as the title asks)
In the driver config you can make multiple
socket
blocks mentioning the socket path, the host user and give it a name :In the task HCL we can specify the socket name from the driver:
The image
localhost/mijnreggie
being referenced above was built with podman from theDockerfile
below:Since podman reads containers from the local user registry, it needs to be available on each user that will run the container.
Output of nomad running the job:
The processes as seen with
ps
:/etc/subuid
maps the two container users to subordinate users on the host (so the UID above is begin of range + uid 1337 - 1):You can also inspect the containers with
podman ps
under the user running the container:To do:
socket_path
implementationFeedback needed around using the "user" field: The user field in Task HCL is currently used to decide what user is run inside the container but this would better used to specify the host user that runs the container task. An additional parameter
container_user
could be added to give topodman
commands to specify which user to run theCMD
as inside the container. I understood this is for compatibility with the docker driver but it's confusing. If wanted, I can add this implementation to this PR too but it'll break backwards compatibility.Not in scope of this PR: Fixing the open issue with FIFO logging #189 . This to me looks like a problem in nomad itself that creates a FIFO without looking at the task "user" field to set the owner correctly (newLogRotatorMapper calls the mkfifo here ). When specifying
journald
the driver does not crash because it avoids the FIFO issues. If we remap theuser
key to be the host user, I can make a PR to fix the FIFO problem (since then we know the podman user and can change the rights on the pipe)Any feedback is welcome.