OCPBUGS-87453: Updating ose-cluster-kube-controller-manager-operator-container image to be consistent with ART for 5.0#942
Conversation
|
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 build infrastructure to Go 1.26 and OpenShift 5.0. The CI operator build root image tag and Docker multi-stage base images are updated consistently. The final runtime image also switches from the ChangesGo 1.26 and OpenShift 5.0 Build Environment
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@openshift-bot: This pull request references Jira Issue OCPBUGS-87453, 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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-87453, 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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Dockerfile.rhel7 (1)
7-16:⚠️ Potential issue | 🔴 CriticalFix root/healthcheck gaps in Dockerfile.rhel7 runtime stage
- Critical:
Dockerfile.rhel7final stage (FROM ...:base-rhel9) has noUSER, so the container runs as root by default (violates “USER non-root; never run as root”).- Major: No
HEALTHCHECKdirective is defined.- Major: Final stage uses
...:base-rhel9(non-minimal). Prefer the minimal variant unless there’s a documented dependency requiring the non-minimal base.🛡️ Proposed security hardening
FROM registry.ci.openshift.org/ocp/5.0:base-rhel9 + +# Create non-root user +RUN useradd -r -u 1001 -g 0 kube-controller-manager-operator + RUN mkdir -p /usr/share/bootkube/manifests/bootstrap-manifests/ /usr/share/bootkube/manifests/config/ /usr/share/bootkube/manifests/manifests/ COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/bootstrap-manifests /usr/share/bootkube/manifests/bootstrap-manifests/ COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/config /usr/share/bootkube/manifests/config/ COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/bindata/bootkube/manifests /usr/share/bootkube/manifests/manifests/ COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/cluster-kube-controller-manager-operator /usr/bin/ COPY --from=builder /go/src/github.com/openshift/cluster-kube-controller-manager-operator/cluster-kube-controller-manager-operator-tests-ext.gz /usr/bin/ COPY manifests /manifests + +USER 1001 + +HEALTHCHECK --interval=30s --timeout=3s \ + CMD ["/usr/bin/cluster-kube-controller-manager-operator", "healthcheck"] || exit 1 + LABEL io.openshift.release.operator trueNote: Ensure the binary supports the
healthcheckcommand/args (adjust HEALTHCHECK accordingly).🤖 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.rhel7` around lines 7 - 16, The final stage in Dockerfile.rhel7 leaves the container running as root, lacks a HEALTHCHECK, and uses the non-minimal base; fix by switching the FROM to the minimal base image (e.g., replace base-rhel9 with base-rhel9-minimal) unless there is a documented dependency, ensure the runtime binary and manifests are owned by a non-root UID and add a USER directive (create or use a fixed non-root UID such as 1000 and chown /usr/bin/cluster-kube-controller-manager-operator and /manifests accordingly), and add a HEALTHCHECK that calls the operator binary’s health endpoint/command (e.g., invoke cluster-kube-controller-manager-operator healthcheck or a suitable HTTP/CLI probe with sensible interval/retries) so the container reports liveness; update comments/doc if you must keep the non-minimal base.Sources: Coding guidelines, Linters/SAST tools
🤖 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.rhel7`:
- Line 3: The Dockerfile's builder stage currently does a broad COPY . . which
risks including .git, temp files, or secrets; update the builder stage to copy
only needed files/directories (e.g., COPY package.json package-lock.json ./ and
COPY src/ ./) or create/extend a .dockerignore to exclude .git, .github, *.md,
tmp/, *.log so only required build artifacts are included; ensure the COPY
commands in the builder stage are replaced with specific COPY entries (or add a
.dockerignore) rather than copying the entire context.
---
Outside diff comments:
In `@Dockerfile.rhel7`:
- Around line 7-16: The final stage in Dockerfile.rhel7 leaves the container
running as root, lacks a HEALTHCHECK, and uses the non-minimal base; fix by
switching the FROM to the minimal base image (e.g., replace base-rhel9 with
base-rhel9-minimal) unless there is a documented dependency, ensure the runtime
binary and manifests are owned by a non-root UID and add a USER directive
(create or use a fixed non-root UID such as 1000 and chown
/usr/bin/cluster-kube-controller-manager-operator and /manifests accordingly),
and add a HEALTHCHECK that calls the operator binary’s health endpoint/command
(e.g., invoke cluster-kube-controller-manager-operator healthcheck or a suitable
HTTP/CLI probe with sensible interval/retries) so the container reports
liveness; update comments/doc if you must keep the non-minimal base.
🪄 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: d4215308-b800-4a53-8d28-4fe071e4c1c2
📒 Files selected for processing (2)
.ci-operator.yamlDockerfile.rhel7
| 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-kube-controller-manager-operator | ||
| COPY . . |
There was a problem hiding this comment.
Restrict COPY to specific files/directories in builder stage.
The builder stage copies the entire build context (.), which may include unnecessary files like .git, temporary files, or sensitive data. While this is in the builder stage (not the final image), it still violates the guideline to copy specific files.
Consider listing only the required directories/files or using a .dockerignore file to exclude unnecessary content.
🔒 Recommended approach
Option 1: Use .dockerignore to exclude unnecessary files:
.git
.github
*.md
tmp/
*.log
Option 2: Copy only specific directories if the structure allows:
-COPY . .
+COPY go.mod go.sum ./
+COPY cmd/ cmd/
+COPY pkg/ pkg/
+COPY vendor/ vendor/
+COPY bindata/ bindata/
+COPY Makefile .As per coding guidelines: "COPY specific files, not entire context" applies to container builds to minimize attack surface and prevent accidental inclusion of sensitive data.
🤖 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.rhel7` at line 3, The Dockerfile's builder stage currently does a
broad COPY . . which risks including .git, temp files, or secrets; update the
builder stage to copy only needed files/directories (e.g., COPY package.json
package-lock.json ./ and COPY src/ ./) or create/extend a .dockerignore to
exclude .git, .github, *.md, tmp/, *.log so only required build artifacts are
included; ensure the COPY commands in the builder stage are replaced with
specific COPY entries (or add a .dockerignore) rather than copying the entire
context.
Source: Coding guidelines
|
@openshift-bot: The following tests failed, say
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-87707 to this PR, but found it is currently hooked up to ['OCPBUGS-87453']. Please consult with #forum-ocp-art if it is not clear what there is to do. |
Updating ose-cluster-kube-controller-manager-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-kube-controller-manager-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.