OCPBUGS-87454: Updating ose-cluster-samples-operator-container image to be consistent with ART for 5.0#700
Conversation
6e9f364 to
402fdd5
Compare
|
Created by ART pipeline job run https://art-jenkins.apps.prod-stable-spoke1-dc-iad2.itup.redhat.com/job/aos-cd-builds/job/build%252Fsync-ci-images/216 |
WalkthroughThis PR updates the cluster-samples-operator build infrastructure to use Go 1.26 and OpenShift 5.0 base images. The CI operator configuration and Dockerfile are updated in coordination to reference the newer base image tags across both the build and runtime stages. ChangesBase image and builder version upgrade
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: openshift-bot The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@openshift-bot: This pull request references Jira Issue OCPBUGS-87454, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@openshift-bot: This pull request references Jira Issue OCPBUGS-87454, which is valid. 3 validation(s) were run on this bug
DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Dockerfile (1)
1-19:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd HEALTHCHECK directive.
The Dockerfile is missing a HEALTHCHECK definition, which is required by the coding guidelines. Health checks are essential for Kubernetes/OpenShift to monitor the operator's runtime health and restart it if necessary.
🏥 Proposed fix to add HEALTHCHECK
USER cluster-samples-operator +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD ["/usr/bin/cluster-samples-operator", "healthz"] ENTRYPOINT [] CMD ["/usr/bin/cluster-samples-operator"]Note: Verify that the operator binary supports a
healthzcommand or adjust to use an appropriate health check mechanism.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Dockerfile` around lines 1 - 19, Add a HEALTHCHECK instruction near the end of the Dockerfile to enable container liveness probing; invoke the operator's health endpoint or command (e.g., run the operator binary at /usr/bin/cluster-samples-operator with a health or healthz subcommand) and set sensible intervals/retries, failing with a non-zero exit so the container is marked unhealthy; place the HEALTHCHECK after ENTRYPOINT/CMD (or before them if you prefer) and adjust the command if the operator exposes a different health path or requires curl against an HTTP /healthz endpoint.Source: Coding guidelines
🧹 Nitpick comments (1)
Dockerfile (1)
1-19: ⚖️ Poor tradeoffConsider enabling read-only root filesystem.
The coding guidelines specify using read-only rootfs where possible for security hardening. The current Dockerfile does not configure this, which leaves the container's root filesystem writable.
If the operator writes temporary files, consider using a tmpfs volume mount or emptyDir in the Kubernetes deployment rather than allowing writes to the root filesystem.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Dockerfile` around lines 1 - 19, Make the image safe to run with a read-only root filesystem by ensuring all runtime-writable paths are created and owned by the non-root user (USER cluster-samples-operator) and by documenting that the Kubernetes deployment should mount ephemeral writable volumes (tmpfs/emptyDir) for any runtime state instead of writing to /. Concretely, in the Dockerfile create dedicated writable dirs (e.g., /tmp, /var/run, /var/log, /var/lib/cluster-samples-operator or an app-specific path under /var/lib or /opt/openshift/operator), chown them to cluster-samples-operator before switching to USER cluster-samples-operator, and ensure ENTRYPOINT/CMD (/usr/bin/cluster-samples-operator) uses only those writable locations; update deployment manifests to mount emptyDir/tmpfs at those paths so the container can be run with readOnlyRootFilesystem=true.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Dockerfile`:
- Line 3: The Dockerfile currently uses a broad COPY . . which pulls the entire
build context into the image; replace that with explicit COPY lines that only
bring in the files needed to build (for example COPY package.json yarn.lock ./,
COPY go.mod go.sum ./, COPY cmd/ ./cmd/, COPY pkg/ ./pkg/, COPY Makefile ./) or
the exact source directories your build requires for make build, and remove the
COPY . . line so only those targeted files are included in the builder stage.
---
Outside diff comments:
In `@Dockerfile`:
- Around line 1-19: Add a HEALTHCHECK instruction near the end of the Dockerfile
to enable container liveness probing; invoke the operator's health endpoint or
command (e.g., run the operator binary at /usr/bin/cluster-samples-operator with
a health or healthz subcommand) and set sensible intervals/retries, failing with
a non-zero exit so the container is marked unhealthy; place the HEALTHCHECK
after ENTRYPOINT/CMD (or before them if you prefer) and adjust the command if
the operator exposes a different health path or requires curl against an HTTP
/healthz endpoint.
---
Nitpick comments:
In `@Dockerfile`:
- Around line 1-19: Make the image safe to run with a read-only root filesystem
by ensuring all runtime-writable paths are created and owned by the non-root
user (USER cluster-samples-operator) and by documenting that the Kubernetes
deployment should mount ephemeral writable volumes (tmpfs/emptyDir) for any
runtime state instead of writing to /. Concretely, in the Dockerfile create
dedicated writable dirs (e.g., /tmp, /var/run, /var/log,
/var/lib/cluster-samples-operator or an app-specific path under /var/lib or
/opt/openshift/operator), chown them to cluster-samples-operator before
switching to USER cluster-samples-operator, and ensure ENTRYPOINT/CMD
(/usr/bin/cluster-samples-operator) uses only those writable locations; update
deployment manifests to mount emptyDir/tmpfs at those paths so the container can
be run with readOnlyRootFilesystem=true.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: fe620b61-f8cf-448e-8b52-f92b72a4ce3d
📒 Files selected for processing (2)
.ci-operator.yamlDockerfile
| @@ -1,9 +1,9 @@ | |||
| FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS builder | |||
| FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.26-openshift-5.0 AS builder | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify base image source and type for OpenShift operators
# Check if there are other Dockerfiles in the repo using catalog.redhat.com
echo "=== Checking for catalog.redhat.com usage in Dockerfiles ==="
rg -n 'FROM.*catalog\.redhat\.com' --type dockerfile -g 'Dockerfile*'
# Check for UBI minimal/distroless patterns
echo -e "\n=== Checking for UBI minimal or distroless base images ==="
rg -n 'FROM.*(ubi.*-minimal|distroless)' --type dockerfile -g 'Dockerfile*'
# Check for documentation about base image requirements
echo -e "\n=== Searching for base image documentation ==="
fd -t f 'README|CONTRIBUTING|HACKING' -x rg -l 'base.image|UBI|catalog.redhat' {}Repository: openshift/cluster-samples-operator
Length of output: 335
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== Locate Dockerfile(s) ==="
fd -a -t f -g 'Dockerfile*' . -x echo {} 2>/dev/null | head -n 50 || true
DOCKERFILE=$(fd -a -t f 'Dockerfile' . -x echo {} 2>/dev/null | head -n 1 || true)
echo "Detected Dockerfile: ${DOCKERFILE:-<none>}"
echo -e "\n=== Show Dockerfile header (1-120) with line numbers ==="
if [[ -n "${DOCKERFILE:-}" ]]; then
nl -ba "$DOCKERFILE" | head -n 160
else
echo "No Dockerfile found."
fi
echo -e "\n=== Quick checks inside Dockerfile (if present) ==="
if [[ -n "${DOCKERFILE:-}" ]]; then
echo "-- FROM lines"
rg -n '^FROM ' "$DOCKERFILE" || true
echo "-- COPY lines"
rg -n '^COPY ' "$DOCKERFILE" || true
echo "-- USER line"
rg -n '^USER ' "$DOCKERFILE" || true
echo "-- HEALTHCHECK"
rg -n '^HEALTHCHECK' "$DOCKERFILE" || true
echo "-- read-only rootfs hints (volume/mount options)"
rg -n 'read[- ]only|ReadonlyRootFilesystem|readOnlyRootFilesystem' "$DOCKERFILE" || true
fi
echo -e "\n=== Check for catalog.redhat.com usage in any Dockerfile ==="
fd -a -t f 'Dockerfile*' . | while read -r f; do
rg -n 'FROM.*catalog\.redhat\.com' "$f" && echo "---- $f"
done || true
echo -e "\n=== Check for UBI minimal/distroless base images in any Dockerfile ==="
fd -a -t f 'Dockerfile*' . | while read -r f; do
rg -n 'FROM.*(ubi.*-minimal|distroless)' "$f" && echo "---- $f"
done || trueRepository: openshift/cluster-samples-operator
Length of output: 384
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== List Dockerfile* files ==="
DOCKERFILES=()
while IFS= read -r f; do DOCKERFILES+=("$f"); done < <(fd -a -t f -g 'Dockerfile*' . 2>/dev/null || true)
printf '%s\n' "${DOCKERFILES[@]:-<none>}"
echo -e "\n=== Inspect first 200 lines of each Dockerfile* (or until end) ==="
for f in "${DOCKERFILES[@]:-}"; do
echo -e "\n---- FILE: $f ----"
wc -l "$f" || true
head -n 200 "$f" | cat -n
done
echo -e "\n=== Quick extraction across Dockerfile* files ==="
for f in "${DOCKERFILES[@]:-}"; do
echo -e "\n---- FILE: $f ----"
echo "-- FROM:"
rg -n '^FROM ' "$f" || true
echo "-- COPY:"
rg -n '^(COPY|ADD) ' "$f" || true
echo "-- USER:"
rg -n '^USER ' "$f" || true
echo "-- HEALTHCHECK:"
rg -n '^HEALTHCHECK' "$f" || true
echo "-- read-only rootfs hints (mount/readonly):"
rg -n 'read[- ]only|ReadonlyRootFilesystem|readOnlyRootFilesystem' "$f" || true
done
echo -e "\n=== Check for catalog.redhat.com usage in any Dockerfile* ==="
for f in "${DOCKERFILES[@]:-}"; do
rg -n 'FROM.*catalog\.redhat\.com' "$f" && echo "---- $f" || true
done
echo -e "\n=== Check for UBI minimal/distroless base images in any Dockerfile* ==="
for f in "${DOCKERFILES[@]:-}"; do
rg -n 'FROM.*(ubi.*-minimal|distroless)' "$f" && echo "---- $f" || true
done
echo -e "\n=== Search repo docs for base image requirements terms ==="
rg -n 'base\.image|UBI|minimal/distroless|catalog\.redhat\.com|registry\.ci\.openshift\.org' -S README* .github* docs* 2>/dev/null || trueRepository: openshift/cluster-samples-operator
Length of output: 184
🏁 Script executed:
#!/bin/bash
set -euo pipefail
tmpfile="/tmp/dockerfiles_list.txt"
rm -f "$tmpfile"
echo "=== Discover Dockerfile* files ==="
fd -a -t f -g 'Dockerfile*' . > "$tmpfile" 2>/dev/null || true
if [[ ! -s "$tmpfile" ]]; then
echo "No Dockerfile* files found by fd."
exit 0
fi
cat "$tmpfile"
echo -e "\n=== Inspect each Dockerfile* (header + key directives) ==="
while IFS= read -r f; do
echo -e "\n---- FILE: $f ----"
echo "First 120 lines:"
head -n 120 "$f" | cat -n
echo -e "\nFROM lines:"
rg -n '^FROM ' "$f" || true
echo -e "\nCOPY/ADD lines:"
rg -n '^(COPY|ADD) ' "$f" || true
echo -e "\nUSER lines:"
rg -n '^USER ' "$f" || true
echo -e "\nHEALTHCHECK lines:"
rg -n '^HEALTHCHECK' "$f" || true
echo -e "\nRead-only rootfs hints (mount/readonly/ReadonlyRootFilesystem):"
rg -n 'read[- ]only|ReadonlyRootFilesystem|readOnlyRootFilesystem' "$f" || true
done < "$tmpfile"
echo -e "\n=== Cross-check: catalog.redhat.com usage in any Dockerfile* ==="
while IFS= read -r f; do
rg -n 'FROM.*catalog\.redhat\.com' "$f" && echo "---- $f" || true
done < "$tmpfile"
echo -e "\n=== Cross-check: UBI minimal/distroless base images in any Dockerfile* ==="
while IFS= read -r f; do
rg -n 'FROM.*(ubi.*-minimal|distroless)' "$f" && echo "---- $f" || true
done < "$tmpfile"
echo -e "\n=== Cross-check: registry.ci.openshift.org usage in any Dockerfile* ==="
while IFS= read -r f; do
rg -n 'FROM.*registry\.ci\.openshift\.org' "$f" && echo "---- $f" || true
done < "$tmpfile"Repository: openshift/cluster-samples-operator
Length of output: 6477
Fix Docker base-image/security guideline violations in Dockerfile(s)
- Base images come from
registry.ci.openshift.org(notcatalog.redhat.com) and the runtime image is not UBI minimal/distroless (Dockerfile:FROM registry.ci.openshift.org/ocp/5.0:base-rhel9;Dockerfile.okd/Dockerfile.rhel7: final stage usesFROM .../ocp/builder:rhel-*-base-openshift-*). - Builder context is copied wholesale (
COPY . .) inDockerfile,Dockerfile.okd, andDockerfile.rhel7(guideline requires copying specific files). - No
HEALTHCHECKinstruction exists in anyDockerfile*(Dockerfile,Dockerfile.okd,Dockerfile.rhel7). - No read-only-rootfs hardening is expressed in the Dockerfile(s) (no relevant config beyond
USER cluster-samples-operator).
Source: Coding guidelines
| FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS builder | ||
| FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.26-openshift-5.0 AS builder | ||
| WORKDIR /go/src/github.com/openshift/cluster-samples-operator | ||
| COPY . . |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Avoid copying entire build context.
Line 3 copies the entire repository context (.) into the builder stage. As per coding guidelines, COPY should target specific files rather than the entire context to minimize the attack surface and prevent unintended file inclusion during build.
🔒 Proposed fix to copy specific files
-COPY . .
+COPY go.mod go.sum ./
+COPY cmd/ cmd/
+COPY pkg/ pkg/
+COPY vendor/ vendor/
+COPY Makefile ./Note: Adjust the paths based on what make build actually requires.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| COPY . . | |
| COPY go.mod go.sum ./ | |
| COPY cmd/ cmd/ | |
| COPY pkg/ pkg/ | |
| COPY vendor/ vendor/ | |
| COPY Makefile ./ |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Dockerfile` at line 3, The Dockerfile currently uses a broad COPY . . which
pulls the entire build context into the image; replace that with explicit COPY
lines that only bring in the files needed to build (for example COPY
package.json yarn.lock ./, COPY go.mod go.sum ./, COPY cmd/ ./cmd/, COPY pkg/
./pkg/, COPY Makefile ./) or the exact source directories your build requires
for make build, and remove the COPY . . line so only those targeted files are
included in the builder stage.
Source: Coding guidelines
|
@openshift-bot: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
ART wants to connect issue OCPBUGS-87708 to this PR, but found it is currently hooked up to ['OCPBUGS-87454']. Please consult with #forum-ocp-art if it is not clear what there is to do. |
Updating ose-cluster-samples-operator-container image to be consistent with ART for 5.0
TLDR:
Product builds by ART can be configured for different base and builder images than corresponding CI
builds. This automated PR requests a change to CI configuration to align with ART's configuration;
please take steps to merge it quickly or contact ART to coordinate changes.
The configuration in the following ART component metadata is driving this alignment request:
ose-cluster-samples-operator.yml.
Detail:
This repository is out of sync with the downstream product builds for this component. The CI
configuration for at least one image differs from ART's expected product configuration. This should
be addressed to ensure that the component's CI testing accurate reflects what customers will
experience.
Most of these PRs are opened as an ART-driven proposal to migrate base image or builder(s) to a
different version, usually prior to GA. The intent is to effect changes in both configurations
simultaneously without breaking either CI or ART builds, so usually ART builds are configured to
consider CI as canonical and attempt to match CI config until the PR merges to align both. ART may
also configure changes in GA releases with CI remaining canonical for a brief grace period to enable
CI to succeed and the alignment PR to merge. In either case, ART configuration will be made
canonical at some point (typically at branch-cut before GA or release dev-cut after GA), so it is
important to align CI configuration as soon as possible.
PRs are also triggered when CI configuration changes without ART coordination, for instance to
change the number of builder images or to use a different golang version. These changes should be
coordinated with ART; whether ART configuration is canonical or not, preferably it would be updated
first to enable the changes to occur simultaneously in both CI and ART at the same time. This also
gives ART a chance to validate the intended changes first. For instance, ART compiles most
components with the Golang version being used by the control plane for a given OpenShift release.
Exceptions to this convention (i.e. you believe your component must be compiled with a Golang
version independent from the control plane) must be granted by the OpenShift staff engineers and
communicated to the ART team.
Roles & Responsibilities:
tests OR that necessary metadata changes are reported to the ART team
in
#forum-ocp-arton Slack. If necessary, the changes required by this pull request can beintroduced with a separate PR opened by the component team. Once the repository is aligned,
this PR will be closed automatically.
verify-depsis complaining. In that case, please opena new PR with the dependency issues addressed (and base images bumped). ART-9595 for reference.
any required labels to ensure the PR merges once tests are passing. In cases where ART config is
canonical, downstream builds are already being built with these changes, and merging this PR
only improves the fidelity of our CI. In cases where ART config is not canonical, this provides
a grace period for the component team to align their CI with ART's configuration before it becomes
canonical in product builds.
ART has been configured to reconcile your CI build root image (see https://docs.ci.openshift.org/docs/architecture/ci-operator/#build-root-image).
In order for your upstream .ci-operator.yaml configuration to be honored, you must set the following in your openshift/release ci-operator configuration file:
Change behavior of future PRs:
set up automatically. This means that such a PR would merge without human intervention (and awareness!) in the future.
To do so, open a PR to set the
auto_labelattribute in the image configuration. ExampleUPSTREAM: <carry>:. An example.If you have any questions about this pull request, please reach out in the
#forum-ocp-artSlack channel.