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

HOSTEDCP-591: Amend OLM catalog IS according to OpenShiftImageRegistryOverrides #2947

Merged

Conversation

tiraboschi
Copy link
Contributor

@tiraboschi tiraboschi commented Aug 24, 2023

What this PR does / why we need it:
Amend the image address used for the imageStreams
used for the OLM catalog source according to the value
of OpenShiftImageRegistryOverrides as genetically used
in the control plane operator in order to handle the disconnected use case.
This will implicitly assume that the images used for
the 4 default OLM catalogs got mirrored to the internal registry
using the original name and tag.

An annotation based escape mechanism is also defined:
the owner of the hostedcluster will be able to inject custom
addresses (only by digest) for the catalog images.
In that case the imageStream mechanism is completely skipped
and the catalog deployments are directly with the values
in the annotations.
It will be completely up to the user to manually refresh
them when the internal mirror will get refreshed.

Which issue(s) this PR fixes (optional, use fixes #<issue_number>(, fixes #<issue_number>, ...) format, where issue_number might be a GitHub issue, or a Jira story:
Fixes https://issues.redhat.com/browse/HOSTEDCP-591

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-area labels Aug 24, 2023
@openshift-ci openshift-ci bot added area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release and removed do-not-merge/needs-area labels Aug 24, 2023
@openshift-ci openshift-ci bot added the area/documentation Indicates the PR includes changes for documentation label Aug 24, 2023
@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for hypershift-docs ready!

Name Link
🔨 Latest commit 01b4580
🔍 Latest deploy log https://app.netlify.com/sites/hypershift-docs/deploys/64f5f0ed20786d00083eee81
😎 Deploy Preview https://deploy-preview-2947--hypershift-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tiraboschi tiraboschi force-pushed the olm_catalogs_disconnected branch 2 times, most recently from c0aa4fa to d830010 Compare August 25, 2023 13:25
@openshift-ci openshift-ci bot added the area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release label Aug 25, 2023
@tiraboschi tiraboschi changed the title WIP: Amend OLM catalog IS according to OpenShiftImageRegistryOverrides Amend OLM catalog IS according to OpenShiftImageRegistryOverrides Aug 25, 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 Aug 25, 2023
@tiraboschi
Copy link
Contributor Author

/retest

Copy link
Contributor

@csrwng csrwng left a comment

Choose a reason for hiding this comment

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

Some comments, thx!

catalogWithOverride := make(map[string]string)
for name, image := range catalogToImage {
for registrySource, registryDest := range openShiftImageRegistryOverrides {
if strings.Contains(image, registrySource) {
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of doing a string check, I'd rather parse the image ref and match the registry exactly, using reference.Parse() from

func Parse(spec string) (DockerImageReference, error) {

then replace the registry in the reference object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit ambiguous: reference.Parse("registry.redhat.io/redhat/redhat-operator-index:v4.14") will return a DockerImageReference where Registry=registry.redhat.io and Namespace=redhat but (probably) we don't want to replace just the registry forcing the customers to keep using the same namespace in their mirrored registry.

And indeed in the cmd help of the control-plane-operator (see: https://github.com/openshift/hypershift/blob/main/control-plane-operator/main.go#L177 ) we say:
Images before being applied are scanned for the source registry string and if found the string is replaced with the destination registry string.

which is exactly what is done in:

if strings.Contains(image, registrySource) {
for _, registryReplacement := range registryDest {
image = strings.Replace(image, registrySource, registryReplacement, 1)

I'm not directly calling that method since here we lack the pullSecret that is used to validate the replacement upfront, but at least the implementation is coherent.

@csrwng
Copy link
Contributor

csrwng commented Sep 5, 2023

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 5, 2023
Amend the image address used for the imageStreams
used for the OLM catalog source according to the value
of OpenShiftImageRegistryOverrides as genetically used
in the control plane operator in order to handle the disconnected use case.
This will implicitly assume that the images used for
the 4 default OLM catalogs got mirrored to the internal registry
using the original name and tag.

An annotation based escape mechanism is also defined:
the owner of the hostedcluster will be able to inject custom
addresses (only by digest) for the catalog images.
In that case the imageStream mechanism is completely skipped
and the catalog deployments are directly with the values
in the annotations.
It will be completely up to the user to manually refresh
them when the internal mirror will get refreshed.

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
@tiraboschi
Copy link
Contributor Author

/test e2e-aws

@tiraboschi
Copy link
Contributor Author

/test e2e-kubevirt-aws-ovn

@bryan-cox
Copy link
Member

bryan-cox commented Sep 6, 2023

Updating the title so the Jira ticket is linked and the label is added. This is going to be required soon "DPTP will be adding the requirement of PRs having a jira/valid-reference label for a PR to merge. Currently PRs will get this label added automatically by referencing a Jira in their title...".

/retitle HOSTEDCP-591: Amend OLM catalog IS according to OpenShiftImageRegistryOverrides

@openshift-ci openshift-ci bot changed the title Amend OLM catalog IS according to OpenShiftImageRegistryOverrides HOSTEDCP-591: Amend OLM catalog IS according to OpenShiftImageRegistryOverrides Sep 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 Sep 6, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 6, 2023

@tiraboschi: This pull request references HOSTEDCP-591 which is a valid jira issue.

In response to this:

What this PR does / why we need it:
Amend the image address used for the imageStreams
used for the OLM catalog source according to the value
of OpenShiftImageRegistryOverrides as genetically used
in the control plane operator in order to handle the disconnected use case.
This will implicitly assume that the images used for
the 4 default OLM catalogs got mirrored to the internal registry
using the original name and tag.

An annotation based escape mechanism is also defined:
the owner of the hostedcluster will be able to inject custom
addresses (only by digest) for the catalog images.
In that case the imageStream mechanism is completely skipped
and the catalog deployments are directly with the values
in the annotations.
It will be completely up to the user to manually refresh
them when the internal mirror will get refreshed.

Which issue(s) this PR fixes (optional, use fixes #<issue_number>(, fixes #<issue_number>, ...) format, where issue_number might be a GitHub issue, or a Jira story:
Fixes https://issues.redhat.com/browse/HOSTEDCP-591

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

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.

Copy link
Member

@bryan-cox bryan-cox left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 6, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, csrwng, tiraboschi

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

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 32f3ced and 2 for PR HEAD 5af4213 in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 6, 2023

@tiraboschi: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-ibmcloud-iks 5af4213 link false /test e2e-ibmcloud-iks
ci/prow/e2e-ibmcloud-roks 5af4213 link false /test e2e-ibmcloud-roks

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

/retest-required

Remaining retests: 0 against base HEAD 8c24b8c and 1 for PR HEAD 5af4213 in total

@openshift-merge-robot openshift-merge-robot merged commit 9f32daa into openshift:main Sep 7, 2023
13 of 15 checks passed
@tiraboschi tiraboschi deleted the olm_catalogs_disconnected branch September 7, 2023 08:39
tiraboschi added a commit to tiraboschi/hypershift that referenced this pull request Sep 11, 2023
With openshift#2947
we introduced a mechanism to amend the OLM catalog
ImageStream according to OpenShiftImageRegistryOverrides
that are always automatically initializaed according to
any ImageContentSourcePolicy (ICSP) or any ImageDigestMirrorSet (IDMS)
instance from an OpenShift management cluster.

But assuming that the whole default OLM catalogs
got properly mirrored to a different registry
just because an ICSP is there on the management cluster is
overblown.
Let's make this optional introducing an
additional annotation to opt-in only if really needed,
if not let's continue pointing the catalogs imagestream
to the public registry.

Automatically mirror the 5 involved annotations
from the HC CR to the HCO one.

Fixes: https://issues.redhat.com/browse/OCPBUGS-18720

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
tiraboschi added a commit to tiraboschi/hypershift that referenced this pull request Sep 13, 2023
With openshift#2947
we introduced a mechanism to amend the OLM catalog
ImageStream according to OpenShiftImageRegistryOverrides
that are always automatically initializaed according to
any ImageContentSourcePolicy (ICSP) or any ImageDigestMirrorSet (IDMS)
instance from an OpenShift management cluster.

But assuming that the whole default OLM catalogs
got properly mirrored to a different registry
just because an ICSP is there on the management cluster is
overblown and with the imagestream the replacements cannot be
validated ahead ot time.

Let's not do it by default according to ICSP/IDMS
on the management cluster but only according to the
value of a new explicit annotation.

Automatically mirror the 5 involved annotations
from the HC CR to the HCP one.

Fixes: https://issues.redhat.com/browse/OCPBUGS-18720

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
tiraboschi added a commit to tiraboschi/hypershift that referenced this pull request Sep 13, 2023
With openshift#2947
we introduced a mechanism to amend the OLM catalog
ImageStream according to OpenShiftImageRegistryOverrides
that are always automatically initializaed according to
any ImageContentSourcePolicy (ICSP) or any ImageDigestMirrorSet (IDMS)
instance from an OpenShift management cluster.

But assuming that the whole default OLM catalogs
got properly mirrored to a different registry
just because an ICSP is there on the management cluster is
overblown and with the imagestream the replacements cannot be
validated ahead ot time.

Let's not do it by default according to ICSP/IDMS
on the management cluster but only according to the
value of a new explicit annotation.

Automatically mirror the 5 involved annotations
from the HC CR to the HCP one.

Fixes: https://issues.redhat.com/browse/OCPBUGS-18720

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/hypershift that referenced this pull request Sep 15, 2023
With openshift#2947
we introduced a mechanism to amend the OLM catalog
ImageStream according to OpenShiftImageRegistryOverrides
that are always automatically initializaed according to
any ImageContentSourcePolicy (ICSP) or any ImageDigestMirrorSet (IDMS)
instance from an OpenShift management cluster.

But assuming that the whole default OLM catalogs
got properly mirrored to a different registry
just because an ICSP is there on the management cluster is
overblown and with the imagestream the replacements cannot be
validated ahead ot time.

Let's not do it by default according to ICSP/IDMS
on the management cluster but only according to the
value of a new explicit annotation.

Automatically mirror the 5 involved annotations
from the HC CR to the HCP one.

Fixes: https://issues.redhat.com/browse/OCPBUGS-18720

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
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. area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/documentation Indicates the PR includes changes for documentation area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release 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

5 participants