Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPNODE-1580: Add --print-mirror-instructions to oc adm release mirror to allow idms instructions #1341

Merged
merged 1 commit into from Jun 16, 2023

Conversation

QiWang19
Copy link
Member

@QiWang19 QiWang19 commented Feb 15, 2023

story: https://issues.redhat.com/browse/OCPNODE-1580

Add --print-mirror-instructions flag to command oc adm release.
The printout instructions of the command will keep it as is if the flag is unset or set to icsp.
If set to idms, update the instruction output of oc adm release mirror to ImageDigestMirrorSet example.
The new ImageDigestMirrorSet examples are:

  • use imageDigestSources field in install-config.yaml[1] that will creates ImageDigestMirrorSet manifests,
  • manifest example of ImageDigestMirrorSet CRD

[1] Add imageDigestSources to install-config: openshift/installer#6235

result of this patch:

LOCAL_REGISTRY=localhost:5000
LOCAL_REPOSITORY=ocp4/openshift4
LOCAL_SECRET_JSON=/home/qiwan/cluster/mysecret
sudo podman run -d -p 5000:5000 docker.io/registry

$ oc adm release mirror -a ${LOCAL_SECRET_JSON} --from=registry.ci.openshift.org/ocp/release:4.14.0-0.ci-2023-04-04-023533 --to=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY} --print-mirror-instructions=idms --dry-run

phase 0:
  localhost:5000 ocp4/openshift4 blobs=597 mounts=0 manifests=189 shared=6

info: Planning completed in 36.98s
info: Dry run complete

Success
Update image:  localhost:5000/ocp4/openshift4:4.14.0-0.ci-2023-04-04-023533-x86_64
Mirror prefix: localhost:5000/ocp4/openshift4

To use the new mirrored repository to install, add the following section to the install-config.yaml:

imageDigestSources:
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: registry.ci.openshift.org/ocp/4.14-2023-04-04-023533
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: registry.ci.openshift.org/ocp/release


To use the new mirrored repository for upgrades, use the following to create an ImageDigestMirrorSet:

apiVersion: config.openshift.io/v1
kind: ImageDigestMirrorSet
metadata:
  name: example
spec:
  imageDigestMirrors:
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: registry.ci.openshift.org/ocp/4.14-2023-04-04-023533
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: registry.ci.openshift.org/ocp/release

If specify --print-mirror-instructions=icsp print out deprecated message to direct users to use idms.

$ ./oc adm release mirror --print-mirror-instructions=icsp ....
Flag --print-mirror-instructions's value 'icsp' has been deprecated. Use 'idms' instead to allow the printing of instructions for ImageDigestSources and ImageDigestMirrorSet.

@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 15, 2023
@QiWang19 QiWang19 changed the title [WIP] update oc amd release mirror output using idms [OCPNODE-1580] update oc amd release mirror output using idms Mar 28, 2023
@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 Mar 28, 2023
@QiWang19
Copy link
Member Author

QiWang19 commented Mar 31, 2023

/hold
openshift/installer#6235 installer PR for imageDigestSources is under review.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 31, 2023
@QiWang19
Copy link
Member Author

/retest-required

@QiWang19
Copy link
Member Author

QiWang19 commented Apr 6, 2023

@ardaguclu PTAL. update the printout instruction using versions, the example output for 4.5.4 and 4.14:

// quay.io/openshift-release-dev/ocp-release:4.5.4-x86_64

Success
Update image:  localhost:5000/ocp4/openshift4:4.5.4-x86_64
Mirror prefix: localhost:5000/ocp4/openshift4

To use the new mirrored repository to install, add the following section to the install-config.yaml:

imageContentSources:
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: quay.io/openshift-release-dev/ocp-release
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: quay.io/openshift-release-dev/ocp-v4.0-art-dev


To use the new mirrored repository for upgrades, use the following to create an ImageContentSourcePolicy:

apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
  name: example
spec:
  repositoryDigestMirrors:
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: quay.io/openshift-release-dev/ocp-release
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: quay.io/openshift-release-dev/ocp-v4.0-art-dev
// 4.14 registry.ci.openshift.org/ocp/release:4.14.0-0.ci-2023-04-04-023533
phase 0:
  localhost:5000 ocp4/openshift4 blobs=597 mounts=0 manifests=189 shared=6

info: Planning completed in 36.98s
info: Dry run complete

Success
Update image:  localhost:5000/ocp4/openshift4:4.14.0-0.ci-2023-04-04-023533-x86_64
Mirror prefix: localhost:5000/ocp4/openshift4

To use the new mirrored repository to install, add the following section to the install-config.yaml:

imageDigestSources:
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: registry.ci.openshift.org/ocp/4.14-2023-04-04-023533
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: registry.ci.openshift.org/ocp/release


To use the new mirrored repository for upgrades, use the following to create an ImageDigestMirrorSet:

apiVersion: config.openshift.io/v1
kind: ImageDigestMirrorSet
metadata:
  name: example
spec:
  imageDigestMirrors:
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: registry.ci.openshift.org/ocp/4.14-2023-04-04-023533
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: registry.ci.openshift.org/ocp/release
status: {}

@QiWang19
Copy link
Member Author

QiWang19 commented Apr 7, 2023

/hold cancel

openshift/installer#6235 allows imageDigestMirrors in install-config.yaml merged.
so this pr oc adm release mirror can point user to use that field in install-config.

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 7, 2023
@QiWang19
Copy link
Member Author

QiWang19 commented Apr 7, 2023

/retest-required

pkg/cli/admin/release/mirror.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/mirror.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/mirror_test.go Show resolved Hide resolved
@QiWang19
Copy link
Member Author

/retest-required

@QiWang19
Copy link
Member Author

@ardaguclu PTAL

@ardaguclu
Copy link
Member

/test e2e-metal-ipi-ovn-ipv6

@ardaguclu
Copy link
Member

This PR looks good to me but I think we need pre-merge testing to move forward.
@zhouying7780 could you please take a look at this PR?

/lgtm
/hold
until pre-merge testing is completed.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 12, 2023
@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 12, 2023
@ardaguclu
Copy link
Member

Although e2e-metal-ipi-ovn-ipv6 job is not required, for this PR I think it should be green because as far as I know, it also uses release mirror command.

@QiWang19
Copy link
Member Author

/retest-required

@QiWang19
Copy link
Member Author

/test e2e-metal-ipi-ovn-ipv6

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 25, 2023
@QiWang19
Copy link
Member Author

/test e2e-metal-ipi-ovn-ipv6

@ardaguclu
Copy link
Member

Sounds like a good plan. But I don't think we would need this hacky version check in here https://github.com/openshift/oc/pull/1341/files#diff-5cff67bbeb34fe73a26ed00f0b2099417027140a1907d25a7d3ac3f0e2c9d982R905. Because user can specify whichever output format they want.

What about we propose a new flag as you said, namely --print-mirror-instructions whose default value is ICSP(without passing this, we'll also set it to ICSP) and basically we'll bind it to

o.PrintImageContentInstructions = true

In the future, we can change default to idms?

@QiWang19
Copy link
Member Author

Sounds good to me. I would rework this.

Copy link
Member

@ardaguclu ardaguclu left a comment

Choose a reason for hiding this comment

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

I'll finish detailed review but left a minor comment now.

@@ -162,6 +169,7 @@ func NewMirror(f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C
flags.BoolVar(&o.ApplyReleaseImageSignature, "apply-release-image-signature", o.ApplyReleaseImageSignature, "Apply release image signature to connected cluster.")
flags.StringVar(&o.ReleaseImageSignatureToDir, "release-image-signature-to-dir", o.ReleaseImageSignatureToDir, "A directory to export release image signature to.")

flags.StringVar(&o.PrintImageSourceInstructions, "print-mirror-instructions", o.PrintImageSourceInstructions, "Print instructions of ImageContentSourcePolicy or ImageDigestMirrorSet for using images from mirror registries. Allowed value is 'icsp' or 'idms'. Default value is icsp.")
Copy link
Member

Choose a reason for hiding this comment

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

I know, it wasn't supported before but can we also add none to not print anything?

@ardaguclu
Copy link
Member

ardaguclu commented Jun 2, 2023

@QiWang19 What is the plan changing the default from icsp to idms?

Maybe we should a warning about "use idms instead icsp" when icsp is printed. But that fully depends on the calendar of migration from icsp to idms.

@QiWang19 QiWang19 changed the title [OCPNODE-1580] update oc amd release mirror output using idms [OCPNODE-1580] Add --print-mirror-instructions to oc amd release mirror to allow idms instructions Jun 5, 2023
pkg/cli/admin/release/mirror.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/mirror.go Outdated Show resolved Hide resolved
pkg/cli/admin/release/mirror.go Outdated Show resolved Hide resolved

var sources []operatorv1alpha1.RepositoryDigestMirrors
var (
Copy link
Member

Choose a reason for hiding this comment

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

I think, there is no shortcut return if printImageSourceInstructions is none.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

Add --print-mirror-instructions flag to command oc adm release.
The print out instructions of the command will keep it as is if the flag is unset or set to `icsp`.
If set to 'idms', update instruction output of `oc adm release mirror` to ImageDigestMirrorSet example.
The new ImageDigestMirrorSet examples are:
- use `imageDigestSources` field in install-config.yaml[1] that will creates ImageDigestMirrorSet manifests,
- manifest example of ImageDigestMirrorSet CRD

[1] Add `imageDigestSources` to install-config: openshift/installer#6235

result of this patch:
```
$ oc adm release mirror --print-mirror-instructions=idms  -a /home/qiwan/cluster/mysecret --from=quay.io/openshift-release-dev/ocp-release:4.13.2-x86_64 --to=localhost:5000/ocp4/openshift4 --to-release-image=localhost:5000/ocp4/openshift4:4.13-x86_64 --dry-run

To use the new mirrored repository to install, add the following section to the install-config.yaml:

imageDigestSources:
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: quay.io/openshift-release-dev/ocp-release
- mirrors:
  - localhost:5000/ocp4/openshift4
  source: quay.io/openshift-release-dev/ocp-v4.0-art-dev

To use the new mirrored repository for upgrades, use the following to create an ImageDigestMirrorSet:

apiVersion: config.openshift.io/v1
kind: ImageDigestMirrorSet
metadata:
  name: example
spec:
  imageDigestMirrors:
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: quay.io/openshift-release-dev/ocp-release
  - mirrors:
    - localhost:5000/ocp4/openshift4
    source: quay.io/openshift-release-dev/ocp-v4.0-art-dev

```

Signed-off-by: Qi Wang <qiwan@redhat.com>
@QiWang19
Copy link
Member Author

QiWang19 commented Jun 6, 2023

@ardaguclu PTAL

@ardaguclu
Copy link
Member

/lgtm
/hold cancel

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 6, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, QiWang19

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

The pull request process is described here

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

@ardaguclu
Copy link
Member

ardaguclu commented Jun 6, 2023

/retitle OCPNODE-1580: Add --print-mirror-instructions to oc adm release mirror to allow idms instructions

@openshift-ci openshift-ci bot changed the title [OCPNODE-1580] Add --print-mirror-instructions to oc amd release mirror to allow idms instructions OCPNODE-1580: Add --print-mirror-instructions to oc adm release mirror to allow idms instructions Jun 6, 2023
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 6, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jun 6, 2023

@QiWang19: This pull request references OCPNODE-1580 which is a valid jira issue.

In response to this:

story: https://issues.redhat.com/browse/OCPNODE-1580

Add --print-mirror-instructions flag to command oc adm release.
The printout instructions of the command will keep it as is if the flag is unset or set to icsp.
If set to idms, update the instruction output of oc adm release mirror to ImageDigestMirrorSet example.
The new ImageDigestMirrorSet examples are:

  • use imageDigestSources field in install-config.yaml[1] that will creates ImageDigestMirrorSet manifests,
  • manifest example of ImageDigestMirrorSet CRD

[1] Add imageDigestSources to install-config: openshift/installer#6235

result of this patch:

LOCAL_REGISTRY=localhost:5000
LOCAL_REPOSITORY=ocp4/openshift4
LOCAL_SECRET_JSON=/home/qiwan/cluster/mysecret
sudo podman run -d -p 5000:5000 docker.io/registry

$ oc adm release mirror -a ${LOCAL_SECRET_JSON} --from=registry.ci.openshift.org/ocp/release:4.14.0-0.ci-2023-04-04-023533 --to=${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}

phase 0:
 localhost:5000 ocp4/openshift4 blobs=597 mounts=0 manifests=189 shared=6

info: Planning completed in 36.98s
info: Dry run complete

Success
Update image:  localhost:5000/ocp4/openshift4:4.14.0-0.ci-2023-04-04-023533-x86_64
Mirror prefix: localhost:5000/ocp4/openshift4

To use the new mirrored repository to install, add the following section to the install-config.yaml:

imageDigestSources:
- mirrors:
 - localhost:5000/ocp4/openshift4
 source: registry.ci.openshift.org/ocp/4.14-2023-04-04-023533
- mirrors:
 - localhost:5000/ocp4/openshift4
 source: registry.ci.openshift.org/ocp/release


To use the new mirrored repository for upgrades, use the following to create an ImageDigestMirrorSet:

apiVersion: config.openshift.io/v1
kind: ImageDigestMirrorSet
metadata:
 name: example
spec:
 imageDigestMirrors:
 - mirrors:
   - localhost:5000/ocp4/openshift4
   source: registry.ci.openshift.org/ocp/4.14-2023-04-04-023533
 - mirrors:
   - localhost:5000/ocp4/openshift4
   source: registry.ci.openshift.org/ocp/release

If specify --print-mirror-instructions=icsp print out deprecated message to direct users to use idms.

$ ./oc adm release mirror --print-mirror-instructions=icsp ....
Flag --print-mirror-instructions's value 'icsp' has been deprecated. Use 'idms' instead to allow the printing of instructions for ImageDigestSources and ImageDigestMirrorSet.

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/test-infra repository.

@QiWang19
Copy link
Member Author

QiWang19 commented Jun 6, 2023

/test e2e-aws-ovn-upgrade

@QiWang19
Copy link
Member Author

QiWang19 commented Jun 6, 2023

Do we need to tag jira/valid-bug label?

@ardaguclu
Copy link
Member

Do we need to tag jira/valid-bug label?

This is a feature and only TRT can add this label. I think, you should add this PR into TRT's queue.

@neisw
Copy link

neisw commented Jun 15, 2023

/label jira/valid-bug

@openshift-ci openshift-ci bot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Jun 15, 2023
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD bdc5bb5 and 2 for PR HEAD dc8de09 in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 16, 2023

@QiWang19: all tests passed!

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit 488a8de into openshift:master Jun 16, 2023
12 checks passed
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants