fix: finch linux rootless containerd detection#8650
fix: finch linux rootless containerd detection#8650robbrad wants to merge 10 commits intoaws:developfrom
Conversation
Updated LinuxHandler.get_finch_socket_path() to check multiple standard socket locations instead of using a hardcoded path.
Added comprehensive tests for all socket detection scenarios on Linux.
There was a problem hiding this comment.
One thing that needs to be modified in this PR is actually where we're collecting metrics:
aws-sam-cli/samcli/lib/telemetry/metric.py
Lines 543 to 572 in b9aa1ab
You can see that we determine container engine based on the socket path. Anything that has
finch.sock will be labeled as finch, but the containerd.sock will fall through to unknown. The part I don't quite understand is how we'd categorize containerd here; correct me if I'm wrong, but I don't think this is really a finch specific socket, so it doesn't really fit in that bucket. I left another comment on the PR to that effect.
On another note, I haven't fully reviewed the tests either, I can get to those later. There's also some formatting errors, but those could probably be cleaned up with make format or make lint.
| # Rootless containerd socket (most common on Linux) | ||
| containerd_sock = os.path.join(xdg_runtime_dir, "containerd", "containerd.sock") | ||
| if os.path.exists(containerd_sock): | ||
| LOG.debug(f"Found Finch socket at XDG_RUNTIME_DIR: {containerd_sock}") |
There was a problem hiding this comment.
Is the containerd_sock exclusively for finch, though? Couldn't other container clients/engines be using this socket?
| @@ -123,11 +123,49 @@ def _read_config(self) -> Optional[str]: | |||
|
|
|||
There was a problem hiding this comment.
we should add a basic e2e test with rootless setup to see if it actually works.
Unit test i feel is not sufficient to check system related configs.
There was a problem hiding this comment.
This will also check the networking works as we probably will need to pull some container.
There was a problem hiding this comment.
My one concern is that an added integration test for this situation will end up adding a lot of complexity to our testing structure, especially because this is a niche situation that requires a non-trivial amount of changes to the environment. I can discuss this further with the team.
|
|
||
| # Default fallback to system socket | ||
| return "unix:///var/run/finch.sock" | ||
| Returns the socket path for Linux, checking multiple locations. |
There was a problem hiding this comment.
needs integ test to check builds work too in rootless mode?
Update based on PR review comments
Rearranged the priority order for socket path checks and updated comments for clarity regarding Finch and containerd socket usage.
Add test for finch.sock preference over containerd.sock
This PR fixes Finch detection on Linux systems using rootless containerd by checking multiple standard socket locations instead of using a hardcoded path.
Which issue(s) does this change fix?
fixes #8649
Problem
SAM CLI fails with "No container runtime available" on Linux with rootless containerd despite Finch being installed and working. The issue is that SAM CLI only checks
/var/run/finch.sock, but rootless containerd uses$XDG_RUNTIME_DIR/containerd/containerd.sock.Solution
Updated
LinuxHandler.get_finch_socket_path()to check multiple locations in priority order:$XDG_RUNTIME_DIR/containerd/containerd.sock(rootless containerd)$XDG_RUNTIME_DIR/finch.sock(Finch-specific)~/.finch/finch.sock(user home directory)/var/run/finch.sock(system-wide fallback)Nonewhen no socket found (enables future CLI fallback)Changes
samcli/local/docker/platform_config.pyTesting
Risk
LOW - Only affects Linux socket detection, no changes to macOS or Windows
Related Issues
Fixes issue where SAM CLI fails to detect Finch on Linux with rootless containerd.
Mandatory Checklist
PRs will only be reviewed after checklist is complete
make prpassesmake update-reproducible-reqsif dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.