12 Commits

Author SHA1 Message Date
Chris Evich
bf242e8a52 Fix newuidmap...`: newuidmap: open of uid_map failed: Permission denied
Within a container, caps need to be set on /usr/bin/new{uid,gid}map
which reflect the (inner) podman user's root namespaced ID of 10000.

Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
2022-12-08 06:59:02 -05:00
Chris Evich
db6f2bceb9 Attempt fix v2.0.0 newuidmap permission denied
Recently, I believe an update or packaging problem has been causing
podman to throw errors like:

```
level=error msg="running `/usr/bin/newuidmap ...`: newuidmap: open of
uid_map failed: Permission denied\n"
```

This seems to have something to do with the shadow-utils package, which
owns this binary.  I've examined the file attribuites and permissions
along with /etc/sub{uid,gid} contents.  The only thing that seems to
resolve the issue is reinstalling shadow-utils.  Attempt that fix here
and hope it clears up the problem (present in v2.0.0)

Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
2022-12-07 06:14:45 -05:00
Chris Evich
f1423ae0b2 Merge branch 'fix_volumes' into 'main'
Fix volume mounts

See merge request qontainers/pipglr!14
2022-12-06 08:15:33 +00:00
Chris Evich
f88c1a43bd Fix volume mounts
* Add note about volume-mounts being cumulative with base-image
* Fix register & run labels to use (correct) base image's
  `/home/podman/.local/share/containers/` instead of defining
  a new (wrong/useless) `storage` volume.
* Fix register & run labels to mask over `/var/lib/containers`
  with a read-only tmpfs to block any nested rootful use of
  podman as a security precaution.

Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
2022-12-06 03:07:40 -05:00
Chris Evich
5b28cca4e1 Merge branch 'docs_and_cache' into 'main'
Docs: Update volume creation section

See merge request qontainers/pipglr!13
2022-12-06 07:31:15 +00:00
Chris Evich
4fbe33bdbd Revert "Cache prior build layers for ~5 days"
This reverts commit 4c1af406f7.  For
whatever reason, trying to build this using the community runners always
results in an out-of-diskspace error.

Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
2022-12-06 02:20:14 -05:00
Chris Evich
4c1af406f7 Cache prior build layers for ~5 days
This vastly improves build performance at the cost of some extra
registry server storage (which there is plenty of).   Note: The cache
TTL needs to be coordinated with the registry server's tag-cleanup
policy.

Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
2022-12-06 02:18:55 -05:00
Chris Evich
51ce5e4e0a Use single uid/gid map
The podman base-image is intended to support running nested-podman both
root and rootless.  Since pipglr only ever runs rootless, eliminate the
nested usernamespace mapping needed to support nested-root usage.

Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
2022-12-06 02:18:55 -05:00
Chris Evich
75bdc3196f Docs: Update volume creation section
Signed-off-by: Chris Evich <chris_gitlab@icuc.me>
2022-12-06 02:18:27 -05:00
Chris Evich
d36e05d452 Merge branch 'add_readme' into 'main'
Include docs inside image

See merge request qontainers/pipglr!12
2022-12-01 19:23:04 +00:00
Chris Evich
29a806305e Include docs inside image
Signed-off-by: Chris Evich <cevich@redhat.com>
2022-11-30 09:47:18 -05:00
Chris Evich
19a7e501be Docs update
Signed-off-by: Chris Evich <cevich@redhat.com>
2022-11-30 09:44:34 -05:00
2 changed files with 35 additions and 22 deletions

View File

@@ -57,6 +57,7 @@ RUN for rpm in ${EXCLUDE_PACKAGES}; do x+="--exclude=$rpm "; done && \
$DNFCMD update && \ $DNFCMD update && \
$DNFCMD install $x $RUNNER_RPM_URL && \ $DNFCMD install $x $RUNNER_RPM_URL && \
$DNFCMD upgrade && \ $DNFCMD upgrade && \
$DNFCMD reinstall shadow-utils && \
if [[ "${DNFCMD}" == "${_DNFCMD}" ]]; then \ if [[ "${DNFCMD}" == "${_DNFCMD}" ]]; then \
dnf clean all && \ dnf clean all && \
rm -rf /var/cache/dnf; \ rm -rf /var/cache/dnf; \
@@ -97,13 +98,15 @@ RUN sed -i -r \
chown -R podman:podman /home/podman && \ chown -R podman:podman /home/podman && \
chmod u+s /usr/bin/new{uid,gid}map && \ chmod u+s /usr/bin/new{uid,gid}map && \
rm -f /home/podman/.bash* && \ rm -f /home/podman/.bash* && \
echo DOCKER_HOST="unix:///tmp/podman-run-1000/podman/podman.sock" > /etc/profile.d/podman.sh echo DOCKER_HOST="unix:///tmp/podman-run-1000/podman/podman.sock" > /etc/profile.d/podman.sh && \
echo "podman:10000:10000" | tee /etc/subuid > /etc/subgid && \
setcap -n 10000 cap_setuid+ep /usr/bin/newuidmap && \
setcap -n 10000 cap_setuid+ep /usr/bin/newgidmap
# Runtime rootless-mode configuration # Runtime rootless-mode configuration
USER podman USER podman
VOLUME ["/home/podman/.local/share/containers/storage/",\ # N/B: Volumes are cumulative with the base image
"/home/podman/.gitlab-runner/", \ VOLUME ["/home/podman/.gitlab-runner/", "/cache"]
"/cache"]
WORKDIR /home/podman WORKDIR /home/podman
ENTRYPOINT ["/usr/local/bin/gitlab-runner-wrapper"] ENTRYPOINT ["/usr/local/bin/gitlab-runner-wrapper"]
@@ -142,10 +145,13 @@ ENV CLEAN_INTERVAL="$CLEAN_INTERVAL" \
DOCKER_PRIVILEGED="$PRIVILEGED_RUNNER" DOCKER_PRIVILEGED="$PRIVILEGED_RUNNER"
# Not a real build-arg. Simply here to save lots of typing. # Not a real build-arg. Simply here to save lots of typing.
ARG _pm="--systemd=true --device=/dev/fuse --security-opt label=disable --user podman --volume pipglr-podman-root:/home/podman/.local/share/containers/storage --volume pipglr-config:/home/podman/.gitlab-runner -v pipglr-podman-cache:/cache -e PODMAN_RUNNER_DEBUG -e LOG_LEVEL" ARG _pm="--systemd=true --device=/dev/fuse --security-opt label=disable --user podman --volume pipglr-podman-root:/home/podman/.local/share/containers --volume pipglr-config:/home/podman/.gitlab-runner -v pipglr-podman-cache:/cache --tmpfs /var/lib/containers,ro,size=1k -e PODMAN_RUNNER_DEBUG -e LOG_LEVEL"
# These labels simply make it easier to register and execute the runner. # These labels simply make it easier to register and execute the runner.
# Define them last so they are absent should a image-build failure occur. # Define them last so they are absent should a image-build failure occur.
LABEL register="podman run -it --rm $_pm --secret REGISTRATION_TOKEN,type=env \$IMAGE register" LABEL register="podman run -it --rm $_pm --secret REGISTRATION_TOKEN,type=env \$IMAGE register"
# Note: Privileged mode is required to permit building container images with inner-podman # Note: Privileged mode is required to permit building container images with inner-podman
LABEL run="podman run -d --privileged --name pipglr $_pm \$IMAGE run" LABEL run="podman run -d --privileged --name pipglr $_pm \$IMAGE run"
# In case it's helpful, include the documentation
ADD /README.md /home/podman/

View File

@@ -27,27 +27,28 @@ lacks this feature, Several labels are set on the image to support
easy registration and execution of a runner container using a special easy registration and execution of a runner container using a special
bash command. See the examples below for more information. bash command. See the examples below for more information.
#### [Volume Ownership Bug](https://github.com/containers/podman/issues/16576) #### [Volume setup]
Some versions of podman contain a bug where named local volumes aren't owned Since podman inside the container runs as user `podman`, the volumes
by the namespaced user within a rootless container (i.e. the 'podman' user). used by it need to be pre-created with ownership information. While,
Since the `podman` user/group inside the `pipglr` container is known, it's we're at it, might as well add the performance-improving `noatime`,
possible to manually setup ownership ahead of time. This should be be done option as well.
once, prior to registering your runners:
```bash ```bash
$ for VOLUME in pipglr-podman-root pipglr-config pipglr-podman-cache; do \ $ VOLOPTS="o=uid=1000,gid=1000,noatime"; \
PUPVM="podman unshare podman volume mount $VOLUME" for VOLUME in pipglr-podman-root pipglr-config pipglr-podman-cache; do \
podman volume create $VOLUME && \ podman volume create --opt $VOLOPTS $VOLUME || true ; \
podman unshare chown 1000:1000 $($PUPVM) && \ VOLPTH=$(podman unshare podman volume mount $VOLUME)
podman unshare chmod 02770 $($PUPVM) && \ podman unshare chown -c -R 1000:1000 $VOLPTH && \
podman unshare ls -land $($PUPVM) ; \ podman unshare chmod -c 02770 $VOLPTH && \
podman unshare podman volume unmount $VOLUME ; \
done done
``` ```
If you get `podman system service` startup permission-denied errors, or If you get `podman system service` startup permission-denied errors, or
errors from gitlab-runner, unable to connect to the podman socket, this is errors from gitlab-runner, unable to connect to the podman socket, this is
likely the cause. You can fix it after-the-fact using the same commands as above, just add a `-R` option to the `chown`/`chmod`, and additionally target `./*`. likely the cause. You can fix it after-the-fact using the same commands
above.
#### Runner registration #### Runner registration
@@ -107,7 +108,13 @@ sure to use the `podman unshare` command-wrapper to enter the usernamespace.
For example, to display the config: For example, to display the config:
```bash ```bash
$ podman unshare $(podman unshare podman volume mount pipglr-config)/config.toml $ podman unshare cat $(podman unshare podman volume mount pipglr-config)/config.toml
```
Edit the config with your favorite `$EDITOR`:
```bash
$ podman unshare $EDITOR $(podman unshare podman volume mount pipglr-config)/config.toml
``` ```
#### Debugging #### Debugging
@@ -118,9 +125,9 @@ The first thing to check is the container output:
$ podman logs --since 0 pipglr $ podman logs --since 0 pipglr
``` ```
Before starting the runner, you may `export PODMAN_RUNNER_DEBUG=debug` to enable Next, try running pipglr after an `export PODMAN_RUNNER_DEBUG=debug` to enable
debugging on the inner-podman. Whereas `export LOG_LEVEL=debug` can be used to debugging on the inner-podman. If more runner detail is needed, you can instead/additionally
debug the gitlab-runner itself. set `export LOG_LEVEL=debug` to debug the gitlab-runner itself.
## Building ## Building