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

ubuntu-24.04 Error during unshare(...): Operation not permitted #10443

Closed
2 of 13 tasks
Raboo opened this issue Aug 15, 2024 · 3 comments
Closed
2 of 13 tasks

ubuntu-24.04 Error during unshare(...): Operation not permitted #10443

Raboo opened this issue Aug 15, 2024 · 3 comments

Comments

@Raboo
Copy link

Raboo commented Aug 15, 2024

Description

I have a problem with this new ubuntu runner.

This is something that worked on 22.04.

    - name: Build Image
      id: build-image
      uses: redhat-actions/buildah-build@v2
      with:
        image: redir
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}
        oci: true
        containerfiles: |
          ./Containerfile
        platforms: ${{ matrix.platform }}

    - run: skopeo copy containers-storage:ghcr.io/${{ env.OWNER_LC }}/redir:build-${{ env.PODMAN_ARCH }} oci-archive:/tmp/${{ env.PODMAN_ARCH }}-oci.tar

Now instead it produces an error.

skopeo copy containers-storage:ghcr.io/raboo/redir:build-amd64 oci-archive:/tmp/amd64-oci.tar
Error during unshare(...): Operation not permitted

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • Ubuntu 24.04
  • macOS 12
  • macOS 13
  • macOS 13 Arm64
  • macOS 14
  • macOS 14 Arm64
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

I can't find this "Set up job" button anywhere.
I used yaml to create the action.
https://github.com/Raboo/redir/actions

Is it regression?

don't know

Expected behavior

skopeo copy should not produce an error.

Actual behavior

Getting an unshare error.

skopeo copy containers-storage:ghcr.io/raboo/redir:build-amd64 oci-archive:/tmp/amd64-oci.tar
Error during unshare(...): Operation not permitted

Repro steps

  1. Build an image with redhat-actions/buildah-build.

  2. try to copy the image to a tar archive like so skopeo copy containers-storage:ghcr.io/${{ env.OWNER_LC }}/redir:build-${{ env.PODMAN_ARCH }} oci-archive:/tmp/${{ env.PODMAN_ARCH }}-oci.tar

@ijunaidm
Copy link
Contributor

@Raboo - Thank you for bringing this issue to our attention. We will look into this issue and will update you on this issue after investigating.

@Prabhatkumar59
Copy link

Hi @Raboo - The error you're encountering with skopeo copy on Ubuntu 24.04 is related to the unprivileged user namespace (unshare) being restricted in the latest Ubuntu versions. This restriction is likely causing the "Operation not permitted" error when skopeo tries to use unshare.

I am providing workaround for you below:

Workarounds and Solutions

A. Enable User Namespace Remapping
On Ubuntu 24.04, the user namespace is disabled by default for security reasons. You can enable it by modifying the system's kernel parameters or the /etc/sysctl.conf file.

Add the following line to /etc/sysctl.conf:
kernel.unprivileged_userns_clone=1

Then apply changes as:-
sudo sysctl -p

This might not be an option if you're using a CI runner where you don't have root access.

B. Run skopeo in a Privileged Container
Another option is to run skopeo in a privileged container where the unshare operation is permitted. You can modify your GitHub Actions workflow to execute this within a Docker container that has the necessary privileges.

Here’s how you could modify your workflow:

- name: Run skopeo in a privileged container
  run: |
    docker run --privileged -v /tmp:/tmp -v /var/run/docker.sock:/var/run/docker.sock \
    quay.io/skopeo/stable copy containers-storage:ghcr.io/${{ env.OWNER_LC }}/redir:build-${{ env.PODMAN_ARCH }} oci-archive:/tmp/${{ env.PODMAN_ARCH }}-oci.tar

C. Switch to Podman
If enabling user namespaces or running in a privileged container isn't possible, consider switching from skopeo to podman for managing your containers. podman is designed to work without root privileges and might offer a more seamless experience on Ubuntu 24.04.

You can install and use podman like so:

- name: Install Podman
  run: sudo apt-get install -y podman

- name: Use Podman for copying the image
  run: podman save -o /tmp/${{ env.PODMAN_ARCH }}-oci.tar ghcr.io/${{ env.OWNER_LC }}/redir:build-${{ env.PODMAN_ARCH }}

D. Revert to Ubuntu 22.04
If the above options aren't viable, you could temporarily revert to using an Ubuntu 22.04 runner where this operation is known to work. This might be a quick fix while you explore more permanent solutions.

So, overall the "Operation not permitted" error with skopeo on Ubuntu 24.04 is due to restrictions on user namespaces. You can enable the necessary kernel parameter, run skopeo in a privileged container, switch to podman, or revert to Ubuntu 22.04 as potential workarounds.
Hence, by using above steps, you should get proper resolution.

@Raboo
Copy link
Author

Raboo commented Aug 20, 2024

@Prabhatkumar59 I opted for the podman save.

- run: podman save -o /tmp/${{ env.PODMAN_ARCH }}-oci.tar --format oci-archive ghcr.io/${{ env.OWNER_LC }}/redir:build-${{ env.PODMAN_ARCH }}

Thanks!

@Raboo Raboo closed this as completed Aug 20, 2024
ddelnano added a commit to pixie-io/pixie that referenced this issue Sep 6, 2024
…ers (#2010)

Summary: Another attempt to remediate user namespace issues with ubuntu
24.04 runners

This reverts the failed previous attempt and re-enables user namespaces
on ubuntu 24.04. This is a well known behavior change between Ubuntu
22.04 and 24.04
(actions/runner-images#10443 (comment)).
Since podman is running rootless, I think it's possible that the user
namespace creation (clone syscall) is failing.

Relevant Issues: #1993

Type of change: /kind bugfix

Test Plan: Run another production release build after merging this
- Verified that this sysctl cli invocation is similar to our [existing
example](https://github.com/pixie-io/pixie/blob/aa1f72a69f0a072d97accd721081f89cb8108fd1/.github/workflows/build_and_test.yaml#L87)

---------

Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants