Skip to content

OCPBUGS-76450: reduce MCO image size#5644

Merged
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
cheesesashimi:zzlotnik/remove-dnf-cache
Feb 12, 2026
Merged

OCPBUGS-76450: reduce MCO image size#5644
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
cheesesashimi:zzlotnik/remove-dnf-cache

Conversation

@cheesesashimi
Copy link
Member

@cheesesashimi cheesesashimi commented Feb 10, 2026

- What I did

This ensures that the DNF package cache is clear after installing packages to reduce overall image size. This also reduces the overall image size when layer squashing is not used by eliminating the tarball extraction in the final image in favor of directly copying the files into place. Building the image locally using Podman, this yields a ~500 MB size reduction with the images output by the CI system being reduced by ~1.5 GB.

- How to verify it

To verify that the image size is reduced, one can build the image before and after this PR and compare the sizes. That said, there should not be any effect upon the MCO behavior itself. Therefore, a clean CI run should suffice for verification.

- Description for the changelog
Reduce MCO image size

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 10, 2026
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Feb 10, 2026
@openshift-ci-robot
Copy link
Contributor

@cheesesashimi: This pull request references Jira Issue OCPBUGS-76450, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @sergiordlr

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

- What I did

Adds dnf clean all && rm -rf /var/cache/dnf/* to our Containerfiles to reduce image size.

- How to verify it

This should not affect MCO behavior in any way. However, we should at least verify that the image size is smaller than it was before:

  1. Check out the main branch of this repo and build an image: podman build -t localhost/machine-config-operator:before .
  2. Check out this PR locally and build an image podman build -t localhost/machine-config-operator:after .

- Description for the changelog
Clear dnf cache to reduce image size

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-ci
Copy link
Contributor

openshift-ci bot commented Feb 10, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot requested a review from sergiordlr February 10, 2026 14:56
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 10, 2026
@cheesesashimi
Copy link
Member Author

/test images

@cheesesashimi
Copy link
Member Author

/test images

@cheesesashimi cheesesashimi force-pushed the zzlotnik/remove-dnf-cache branch from 2de5fcd to e7a1728 Compare February 10, 2026 19:18
@cheesesashimi cheesesashimi changed the title OCPBUGS-76450: clear dnf cache to reduce image size OCPBUGS-76450: reduce MCO image size Feb 10, 2026
@openshift-ci-robot
Copy link
Contributor

@cheesesashimi: This pull request references Jira Issue OCPBUGS-76450, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @sergiordlr

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

- What I did

This ensures that the DNF package cache is clear after installing packages to reduce overall image size. This also reduces the overall image size when layer squashing is not used by eliminating the tarball extraction in the final image in favor of directly copying the files into place. Building the image locally using Podman, this yields a ~500 MB size reduction with the images output by the CI system being reduced by ~1.5 GB.

- How to verify it

To verify that the image size is reduced, one can build the image before and after this PR and compare the sizes. That said, there should not be any effect upon the MCO behavior itself. Therefore, a clean CI run should suffice for verification.

- Description for the changelog
Reduce MCO image size

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.

@cheesesashimi cheesesashimi marked this pull request as ready for review February 10, 2026 19:28
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 10, 2026
In lieu of mounting package caches at build-time, we should clear them
after package installation.

Because the DNF wrapper sets the repo configuration differently in local
vs. CI builds, this will only yield a ~44 MB reduction for local builds.
However, it will yield a ~1.2 GB reduction for images built by CI.
Early versions of Buildah and/or OpenShift Image Builder presumably did
not support path globbing for COPY directives, which required us to
create a tarball and copy it into the final image.

Although the tarball is deleted immediately after extraction, it still
persists as an image layer when building an image locally due to the
COPY directive. This unnecessary layer increases overall image size by
~480 MB. This is only the case for local image builds since
OpenShift CI is configured to squash the final image layers, which
makes this a non-issue for release images.
@cheesesashimi cheesesashimi force-pushed the zzlotnik/remove-dnf-cache branch from e7a1728 to 84eedc3 Compare February 11, 2026 14:20
@pablintino
Copy link
Contributor

/lgtm
Makes sense

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 11, 2026
@umohnani8
Copy link
Contributor

Great work!
/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheesesashimi, pablintino, umohnani8

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [cheesesashimi,pablintino,umohnani8]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@umohnani8
Copy link
Contributor

/verified bypass

verified by passing ocl test

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Feb 11, 2026
@openshift-ci-robot
Copy link
Contributor

@umohnani8: The verified label has been added.

Details

In response to this:

/verified bypass

verified by passing ocl test

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.

@pablintino
Copy link
Contributor

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 12, 2026

@cheesesashimi: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 1c680d8 into openshift:main Feb 12, 2026
15 checks passed
@openshift-ci-robot
Copy link
Contributor

@cheesesashimi: Jira Issue Verification Checks: Jira Issue OCPBUGS-76450
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-76450 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

- What I did

This ensures that the DNF package cache is clear after installing packages to reduce overall image size. This also reduces the overall image size when layer squashing is not used by eliminating the tarball extraction in the final image in favor of directly copying the files into place. Building the image locally using Podman, this yields a ~500 MB size reduction with the images output by the CI system being reduced by ~1.5 GB.

- How to verify it

To verify that the image size is reduced, one can build the image before and after this PR and compare the sizes. That said, there should not be any effect upon the MCO behavior itself. Therefore, a clean CI run should suffice for verification.

- Description for the changelog
Reduce MCO image size

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.

@cheesesashimi
Copy link
Member Author

/cherry-pick release-4.21

@openshift-cherrypick-robot

@cheesesashimi: new pull request created: #5657

Details

In response to this:

/cherry-pick release-4.21

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 kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants