Skip to content

Commit a296839

Browse files
authored
NO-JIRA: tests(gha): fix check-payload to work with PRs and without podman login for root user (#1084)
Turns out, there were two problems with previous implementation, that were only revealed when * the action was running on a push to a repository that has private github container registry * the action was running on a pull request that modified some image In the first case, action was unable to pull from repository that requires authentication. In the second case, the image is not pushed anywhere, so attempts to pull are futile. The solution appears to be what was implemented in * openshift/check-payload#154 That way we can run against a locally present image.
1 parent 90654c8 commit a296839

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.github/workflows/build-notebooks-TEMPLATE.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ jobs:
561561
562562
# endregion
563563

564-
# region Trivy vulnerability scan
564+
# region check-payload for FIPS compliance
565565

566566
- id: check-payload-vars
567567
run: |
@@ -584,6 +584,11 @@ jobs:
584584
rm -f /tmp/openshift-client-linux.tar.gz
585585
sudo mv ./oc /usr/local/bin
586586
587+
# perform `podman image mount` ourselves, and then follow the scenario from
588+
# https://github.com/openshift/check-payload/pull/154, that is because
589+
# `check-payload scan image --spec` insists on pulling the image, even if already present,
590+
# that causes trouble when checking PRs (image not pushed) and requires `podman login` as root
591+
# (we run podman as root in the GHA to reuse container storage in Kubernetes)
587592
# use sudo to avoid
588593
# podman error (args=[image mount ghcr.io/...])
589594
# (stderr=Error: cannot use command "podman image mount" with the remote podman client
@@ -592,7 +597,14 @@ jobs:
592597
- name: Check image with check-payload for FIPS compliance
593598
run: |
594599
set -Eeuxo pipefail
595-
sudo --preserve-env=PATH go run github.com/openshift/check-payload scan image --spec "${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
600+
# resolve podman under current user, not under sudo/root
601+
PODMAN="$(which podman)"
602+
# mount the image
603+
IMAGE_MOUNT_DIR=$(sudo "${PODMAN}" image mount "${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}")
604+
# run the check-payload scan
605+
sudo --preserve-env=PATH go run github.com/openshift/check-payload scan local --path "${IMAGE_MOUNT_DIR}"
606+
# unmount the image
607+
sudo "${PODMAN}" image unmount --all
596608
working-directory: scripts/check-payload
597609
env:
598610
GOPATH: ${{ steps.check-payload-vars.outputs.GOPATH }}

scripts/check-payload/config.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,20 @@ files = [
234234

235235
# https://issues.redhat.com/browse/RHOAIENG-24290
236236

237+
# when scanning with `scan image --spec`
237238
[[payload.python-311-container.ignore]]
238239
error = "ErrNotDynLinked"
239240
files = [
240241
# executable is not dynamically linked
241242
"/opt/app-root/bin/py-spy",
242243
]
244+
# when scanning with `scan local --path`, the above does not apply
245+
[[ignore]]
246+
error = "ErrNotDynLinked"
247+
files = [
248+
# executable is not dynamically linked
249+
"/opt/app-root/bin/py-spy",
250+
]
243251

244252
[[rpm.code-server.ignore]]
245253
error = "ErrNotDynLinked"

0 commit comments

Comments
 (0)