Skip to content

AGENT-1193: Add --mirror-path flag to support pre-mirrored images#634

Open
rwsu wants to merge 1 commit intoopenshift:masterfrom
rwsu:AGENT-1193-v2
Open

AGENT-1193: Add --mirror-path flag to support pre-mirrored images#634
rwsu wants to merge 1 commit intoopenshift:masterfrom
rwsu:AGENT-1193-v2

Conversation

@rwsu
Copy link
Contributor

@rwsu rwsu commented Dec 19, 2025

Adds support for using pre-mirrored OCP release images instead of running
oc-mirror during the build process. This is useful when images have already
been mirrored in a separate step, avoiding redundant mirroring operations.

Changes:

  • Add --mirror-path command-line flag to build command
  • Fix custom registry support with IDMS and image reference parsing
  • Add --registry-config to oc commands for custom registry authentication

When using custom registries instead of official OpenShift release images,
oc commands need authentication credentials to pull images. This adds the
--registry-config flag to all oc commands and --authfile to skopeo.

  • Use singleton asset store to preserve EnvConfig state. By caching the asset
    store instance and reusing it throughout the command execution, we ensure
    EnvConfig is only generated once with the correct values and not overwritten.

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

@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 Dec 19, 2025
@openshift-ci openshift-ci bot requested review from avishayt and oourfali December 19, 2025 23:39
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 25, 2025
@rwsu rwsu force-pushed the AGENT-1193-v2 branch 2 times, most recently from be9a81e to c10ba39 Compare January 14, 2026 23:03
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 14, 2026
@rwsu rwsu changed the title WIP: Add mirror-path support to appliance builder AGENT-1193: Add --mirror-path flag to support pre-mirrored images Jan 14, 2026
@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 Jan 14, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 14, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 14, 2026

@rwsu: This pull request references AGENT-1193 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

  • Add --mirror-path flag to build command
  • Support using pre-mirrored registry data instead of running oc-mirror
  • Add debug logging in genisoimage

🤖 Generated with Claude Code

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

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-robot
Copy link

openshift-ci-robot commented Jan 14, 2026

@rwsu: This pull request references AGENT-1193 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Adds support for using pre-mirrored OCP release images instead of running
oc-mirror during the build process. This is useful when images have already
been mirrored in a separate step, avoiding redundant mirroring operations.

Changes:

  • Add --mirror-path command-line flag to build command
  • Fix custom registry support with IDMS and image reference parsing
  • Add --registry-config to oc commands for custom registry authentication

When using custom registries instead of official OpenShift release images,
oc commands need authentication credentials to pull images. This adds the
--registry-config flag to all oc commands and --authfile to skopeo.

  • Fix EnvConfig persistence to preserve runtime flags

Without persistence, when EnvConfig is loaded as a dependency by other
assets, it creates a new instance with empty values for these runtime
flags. This caused MirrorPath to be lost when DataISO needed EnvConfig,
breaking the --mirror-path functionality.

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

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-robot
Copy link

openshift-ci-robot commented Jan 23, 2026

@rwsu: This pull request references AGENT-1193 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Adds support for using pre-mirrored OCP release images instead of running
oc-mirror during the build process. This is useful when images have already
been mirrored in a separate step, avoiding redundant mirroring operations.

Changes:

  • Add --mirror-path command-line flag to build command
  • Fix custom registry support with IDMS and image reference parsing
  • Add --registry-config to oc commands for custom registry authentication

When using custom registries instead of official OpenShift release images,
oc commands need authentication credentials to pull images. This adds the
--registry-config flag to all oc commands and --authfile to skopeo.

  • Use singleton asset store to preserve EnvConfig state. By caching the asset store instance and reusing it throughout the command execution, we ensure EnvConfig is only generated once with the correct values and not overwritten.

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

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-robot
Copy link

openshift-ci-robot commented Jan 23, 2026

@rwsu: This pull request references AGENT-1193 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Adds support for using pre-mirrored OCP release images instead of running
oc-mirror during the build process. This is useful when images have already
been mirrored in a separate step, avoiding redundant mirroring operations.

Changes:

  • Add --mirror-path command-line flag to build command
  • Fix custom registry support with IDMS and image reference parsing
  • Add --registry-config to oc commands for custom registry authentication

When using custom registries instead of official OpenShift release images,
oc commands need authentication credentials to pull images. This adds the
--registry-config flag to all oc commands and --authfile to skopeo.

  • Use singleton asset store to preserve EnvConfig state. By caching the asset
    store instance and reusing it throughout the command execution, we ensure
    EnvConfig is only generated once with the correct values and not overwritten.

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

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.

@rwsu
Copy link
Contributor Author

rwsu commented Feb 3, 2026

/cc @danielerez

@openshift-ci openshift-ci bot requested a review from danielerez February 3, 2026 16:29
}
releaseVersion = strings.Trim(releaseVersion, "'")
logrus.Debugf("Release version: %s", releaseVersion)
logrus.Debugf("Got release version: '%s'", releaseVersion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not directly to change, and not sure this convention is cleaner:)

}
releaseDigest = strings.Trim(releaseDigest, "'")
releaseImage = fmt.Sprintf("%s@%s", strings.Split(releaseImage, ":")[0], releaseDigest)
releaseImage = fmt.Sprintf("%s@%s", releaseImage, releaseDigest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was to handle this error:
FATAL failed to fetch Appliance live ISO: failed to fetch dependency of "Appliance live ISO": failed to generate asset "Base ISO (CoreOS)": Failed to execute cmd (/usr/local/bin/oc adm release info --image-for=machine-os-images --insecure=true virthost.ostest.test.metalkube.org@sha256:dc120ba1d210d398da3bcd712c9a7bccf0086c1b7fde42fca8b186d7d16f3fa8): error: unable to connect to image repository : invalid reference format
The problem is the custom release image has a url of virthost.ostest.test.metalkube.org:5000/localimages/local-release-image:latest which contains two colons. The original code takes the first part losing the port number.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so maybe do this change only when using a custom release image?
I mean to avoid breaking the flow for other images without port...

@openshift-ci
Copy link

openshift-ci bot commented Feb 10, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rwsu

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:

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

@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
@rwsu rwsu force-pushed the AGENT-1193-v2 branch 2 times, most recently from bcd041f to 9e775e7 Compare February 11, 2026 22:44
Add support for using pre-mirrored images from oc-mirror workspace by
specifying the mirror path in appliance-config.yaml. When mirrorPath is
configured, the appliance skips running oc-mirror and uses the pre-mirrored
registry data directly.

Changes:
- Add MirrorPath field to top level of ApplianceConfig in types
- Update appliance-config.yaml template to document the new field
- Update code to read mirrorPath from ApplianceConfig.Config.MirrorPath
- Add validateMirrorPath() to ApplianceConfig with comprehensive validation
- Use pre-mirrored images when mirrorPath is provided
- Update documentation to describe mirrorPath parameter and usage

The mirror-path can be specified in appliance-config.yaml as:
  mirrorPath: /path/to/oc-mirror/workspace

Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci
Copy link

openshift-ci bot commented Feb 17, 2026

@rwsu: 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.

}
releaseDigest = strings.Trim(releaseDigest, "'")
releaseImage = fmt.Sprintf("%s@%s", strings.Split(releaseImage, ":")[0], releaseDigest)
releaseImage = fmt.Sprintf("%s@%s", releaseImage, releaseDigest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so maybe do this change only when using a custom release image?
I mean to avoid breaking the flow for other images without port...

logrus.Infof("Using pre-mirrored images from: %s", mirrorPath)
tempDir = mirrorPath
} else {
// Normal mirroring flow - run oc-mirror
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you swap the condition? just for keeping convention.
i.e. check mirrorPath == "" (normal flow first)

imageGen := genisoimage.NewGenIsoImage(nil)
if err = imageGen.GenerateImage(envConfig.CacheDir, dataIsoName, filepath.Join(envConfig.TempDir, dataDir), dataVolumeName); err != nil {

// When mirror-path is provided, copy the Docker registry data from mirror-path/data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this Generate func is getting a bit too long:)
can you extract the new logic to another func?

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-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants