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

[WIP] MGMT-18013: Add kube api support for adding mirror registry in agent cluster install #6646

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

eliorerz
Copy link
Contributor

@eliorerz eliorerz commented Aug 5, 2024

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

/cc @eliorerz

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 5, 2024

@eliorerz: This pull request references MGMT-18013 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 story to target the "4.17.0" version, but no target version was set.

In response to this:

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

/cc @eliorerz

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 openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 5, 2024
@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 Aug 5, 2024
Copy link

openshift-ci bot commented Aug 5, 2024

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

Copy link

openshift-ci bot commented Aug 5, 2024

@eliorerz: GitHub didn't allow me to request PR reviews from the following users: eliorerz.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

/cc @eliorerz

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.

@openshift-ci openshift-ci bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 5, 2024
Copy link

openshift-ci bot commented Aug 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eliorerz

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 openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. api-review Categorizes an issue or PR as actively needing an API review. labels Aug 5, 2024
@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 6, 2024

/test ?

Copy link

openshift-ci bot commented Aug 6, 2024

@eliorerz: The following commands are available to trigger required jobs:

  • /test e2e-agent-compact-ipv4
  • /test edge-assisted-operator-catalog-publish-verify
  • /test edge-ci-index
  • /test edge-e2e-ai-operator-ztp
  • /test edge-e2e-ai-operator-ztp-sno-day2-workers
  • /test edge-e2e-ai-operator-ztp-sno-day2-workers-late-binding
  • /test edge-e2e-metal-assisted
  • /test edge-e2e-metal-assisted-4-12
  • /test edge-e2e-metal-assisted-cnv-4-16
  • /test edge-e2e-metal-assisted-lvm
  • /test edge-e2e-metal-assisted-odf-4-16
  • /test edge-images
  • /test edge-lint
  • /test edge-subsystem-aws
  • /test edge-subsystem-kubeapi-aws
  • /test edge-unit-test
  • /test edge-verify-generated-code
  • /test images
  • /test mce-images

The following commands are available to trigger optional jobs:

  • /test e2e-agent-ha-dualstack
  • /test e2e-agent-sno-ipv6
  • /test edge-e2e-ai-operator-disconnected-capi
  • /test edge-e2e-ai-operator-ztp-3masters
  • /test edge-e2e-ai-operator-ztp-capi
  • /test edge-e2e-ai-operator-ztp-compact-day2-masters
  • /test edge-e2e-ai-operator-ztp-compact-day2-workers
  • /test edge-e2e-ai-operator-ztp-disconnected
  • /test edge-e2e-ai-operator-ztp-hypershift-zero-nodes
  • /test edge-e2e-ai-operator-ztp-multiarch-3masters-ocp
  • /test edge-e2e-ai-operator-ztp-multiarch-sno-ocp
  • /test edge-e2e-ai-operator-ztp-node-labels
  • /test edge-e2e-ai-operator-ztp-sno-day2-masters
  • /test edge-e2e-ai-operator-ztp-sno-day2-workers-ignitionoverride
  • /test edge-e2e-metal-assisted-4-13
  • /test edge-e2e-metal-assisted-4-14
  • /test edge-e2e-metal-assisted-4-15
  • /test edge-e2e-metal-assisted-4-16
  • /test edge-e2e-metal-assisted-bond
  • /test edge-e2e-metal-assisted-bond-4-14
  • /test edge-e2e-metal-assisted-day2
  • /test edge-e2e-metal-assisted-day2-arm-workers
  • /test edge-e2e-metal-assisted-day2-single-node
  • /test edge-e2e-metal-assisted-external
  • /test edge-e2e-metal-assisted-external-4-14
  • /test edge-e2e-metal-assisted-ipv4v6
  • /test edge-e2e-metal-assisted-ipv6
  • /test edge-e2e-metal-assisted-kube-api-late-binding-single-node
  • /test edge-e2e-metal-assisted-kube-api-late-unbinding-ipv4-single-node
  • /test edge-e2e-metal-assisted-kube-api-net-suite
  • /test edge-e2e-metal-assisted-mce-4-16
  • /test edge-e2e-metal-assisted-mce-sno-4-16
  • /test edge-e2e-metal-assisted-metallb
  • /test edge-e2e-metal-assisted-none
  • /test edge-e2e-metal-assisted-onprem
  • /test edge-e2e-metal-assisted-single-node
  • /test edge-e2e-metal-assisted-static-ip-suite
  • /test edge-e2e-metal-assisted-static-ip-suite-4-14
  • /test edge-e2e-metal-assisted-tang
  • /test edge-e2e-metal-assisted-tpmv2
  • /test edge-e2e-metal-assisted-upgrade-agent
  • /test edge-e2e-nutanix-assisted
  • /test edge-e2e-nutanix-assisted-2workers
  • /test edge-e2e-nutanix-assisted-4-14
  • /test edge-e2e-oci-assisted
  • /test edge-e2e-oci-assisted-4-14
  • /test edge-e2e-oci-assisted-iscsi
  • /test edge-e2e-vsphere-assisted
  • /test edge-e2e-vsphere-assisted-4-14
  • /test edge-e2e-vsphere-assisted-4-15
  • /test edge-e2e-vsphere-assisted-4-16
  • /test edge-e2e-vsphere-assisted-umn
  • /test okd-scos-images
  • /test push-pr-image

Use /test all to run the following jobs that were automatically triggered:

  • pull-ci-openshift-assisted-service-master-e2e-agent-compact-ipv4
  • pull-ci-openshift-assisted-service-master-edge-assisted-operator-catalog-publish-verify
  • pull-ci-openshift-assisted-service-master-edge-ci-index
  • pull-ci-openshift-assisted-service-master-edge-e2e-ai-operator-disconnected-capi
  • pull-ci-openshift-assisted-service-master-edge-e2e-ai-operator-ztp
  • pull-ci-openshift-assisted-service-master-edge-e2e-ai-operator-ztp-capi
  • pull-ci-openshift-assisted-service-master-edge-e2e-metal-assisted
  • pull-ci-openshift-assisted-service-master-edge-images
  • pull-ci-openshift-assisted-service-master-edge-lint
  • pull-ci-openshift-assisted-service-master-edge-subsystem-aws
  • pull-ci-openshift-assisted-service-master-edge-subsystem-kubeapi-aws
  • pull-ci-openshift-assisted-service-master-edge-unit-test
  • pull-ci-openshift-assisted-service-master-edge-verify-generated-code
  • pull-ci-openshift-assisted-service-master-images
  • pull-ci-openshift-assisted-service-master-mce-images

In response to this:

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

@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 6, 2024

/test edge-subsystem-kubeapi-aws

2 similar comments
@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 6, 2024

/test edge-subsystem-kubeapi-aws

@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 6, 2024

/test edge-subsystem-kubeapi-aws

@eliorerz eliorerz force-pushed the MGMT-18013-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall branch 2 times, most recently from dda73a0 to 64ac54d Compare August 7, 2024 10:45
@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 7, 2024

/test edge-subsystem-kubeapi-aws

@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 7, 2024

/test edge-subsystem-aws

@eliorerz eliorerz force-pushed the MGMT-18013-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall branch from 64ac54d to 588df6b Compare August 7, 2024 14:43
@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 7, 2024

/test edge-subsystem-aws edge-subsystem-kubeapi-aws edge-unit-test

@eliorerz
Copy link
Contributor Author

eliorerz commented Aug 7, 2024

/test edge-lint

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 60.65574% with 72 lines in your changes missing coverage. Please review.

Project coverage is 66.76%. Comparing base (63e8b0d) to head (c296dbc).
Report is 8 commits behind head on master.

Current head c296dbc differs from pull request most recent head 109fc2a

Please upload reports for the commit 109fc2a to get more accurate results.

Files with missing lines Patch % Lines
pkg/mirrorregistries/cluster_image_registry.go 41.97% 45 Missing and 2 partials ⚠️
internal/installcfg/builder/builder.go 67.79% 13 Missing and 6 partials ⚠️
pkg/mirrorregistries/generator.go 66.66% 4 Missing ⚠️
internal/bminventory/inventory.go 92.30% 0 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6646      +/-   ##
==========================================
- Coverage   68.69%   66.76%   -1.94%     
==========================================
  Files         249      220      -29     
  Lines       37313    27406    -9907     
==========================================
- Hits        25633    18298    -7335     
+ Misses       9387     7519    -1868     
+ Partials     2293     1589     -704     
Flag Coverage Δ
66.76% <60.65%> (-1.94%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/bminventory/inventory_v2_handlers.go 56.60% <100.00%> (ø)
internal/oc/release.go 71.48% <100.00%> (ø)
internal/bminventory/inventory.go 70.72% <92.30%> (+0.01%) ⬆️
pkg/mirrorregistries/generator.go 62.50% <66.66%> (-2.09%) ⬇️
internal/installcfg/builder/builder.go 80.10% <67.79%> (-2.82%) ⬇️
pkg/mirrorregistries/cluster_image_registry.go 41.97% <41.97%> (ø)

... and 34 files with indirect coverage changes

// data
// Set per cluster mirror registry
// +optional
MirrorRegistryRef *v1beta1.MirrorRegistryConfigMapReference `json:"mirrorRegistryRef,omitempty"`
Copy link
Contributor

@CrystalChun CrystalChun Aug 7, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I though so too but after reading corev1.ObjectReference documentation I decided to create a new reference type. LMK if still you think we should use corev1.ObjectReference

// Instead of using this type, create a locally provided and used type that is well-focused on your reference.
// For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 .

Copy link
Contributor

@danielerez danielerez left a comment

Choose a reason for hiding this comment

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

Just a partial review.
A general suggestion - we probably need to document the new API (e.g. in /docs). Mainly to explain the support for both ACI and InfraEnv.

@@ -144,12 +145,12 @@ type OCPClusterAPI interface {

//go:generate mockgen --build_flags=--mod=mod -package bminventory -destination mock_installer_internal.go . InstallerInternals
type InstallerInternals interface {
RegisterClusterInternal(ctx context.Context, kubeKey *types.NamespacedName, params installer.V2RegisterClusterParams) (*common.Cluster, error)
RegisterClusterInternal(ctx context.Context, kubeKey *types.NamespacedName, mirrorRegistryConfiguration *v1beta1.MirrorRegistryConfiguration, params installer.V2RegisterClusterParams) (*common.Cluster, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered adding it to the params? This way we can avoid changing the APIs here, which seems like an overkill...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, One of the definitions in this task is to not affect the REST API. Updating the ClusterCreateParams can only be done with adding it to the swagger definition which will affect the REST API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like that implementation also, from my perspective there are few solution for passing the mirrorRegistryConfiguration:

  • Change the internal API (as done here) and pass mirrorRegistryConfiguration if needed
  • Change ClusterCreateParams and include mirrorRegistryConfiguration which affect the REST API
  • Create a new structs that holds kubeapi parameters (e.g. kubeKey, mirrorRegistryConfiguration ), this struct will replace kubeKey and will prevent us from adding new parameters to the function declaration in the future. The main problem with this method is that it will require us to refactor the code and it a bit out of this PR scope

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. But I don't really think it's an issue to change the API for this. I mean, it won't add any mandatory properties the the parameters, so there's no risk for breaking backwards compatibility, etc.
It should be fine to simply add it as an optional property in the swagger, as we do for many properties - it would only affect the swagger model as we won't require it in the API. So seems like it makes sense to move forward with this direction(?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You basically right, but the moment we expose the mirror registry configuration on swagger we will need to support some logic on the REST side (even if this is just to raise an error when the user supplying mirror registry configuration on non kube api mode).
@avishayt WDYT?

GetClusterInternal(ctx context.Context, params installer.V2GetClusterParams) (*common.Cluster, error)
UpdateClusterNonInteractive(ctx context.Context, params installer.V2UpdateClusterParams) (*common.Cluster, error)
GetClusterByKubeKey(key types.NamespacedName) (*common.Cluster, error)
GetHostByKubeKey(key types.NamespacedName) (*common.Host, error)
InstallClusterInternal(ctx context.Context, params installer.V2InstallClusterParams) (*common.Cluster, error)
InstallClusterInternal(ctx context.Context, params installer.V2InstallClusterParams, mirrorRegistryConfiguration *v1beta1.MirrorRegistryConfiguration) (*common.Cluster, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for all APIs here

if clusterInstall.Spec.MirrorRegistryRef != nil {
mirrorRegistryConfiguration, err = r.processMirrorRegistryConfig(ctx, log, clusterInstall)
if err != nil {
return r.updateStatus(ctx, log, clusterInstall, clusterDeployment, nil, newInputError(err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe worth adding some log here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The log is printed inside processMirrorRegistryConfig

userTomlConfigMap := &corev1.ConfigMap{}
err := c.Get(ctx, types.NamespacedName{Name: ref.Name, Namespace: ref.Namespace}, userTomlConfigMap)
if err != nil {
log.Error(err, "Failed to get ConfigMap", "ConfigMapName", ref.Name, "ConfigMapNamespace", ref.Namespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have a validation for a missing CM? probably need some condition error in status for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We update the status here. Is that enough?

@@ -499,7 +505,12 @@ func (r *InfraEnvReconciler) createInfraEnv(ctx context.Context, log logrus.Fiel
createParams.InfraenvCreateParams.StaticNetworkConfig = staticNetworkConfig
}

return r.Installer.RegisterInfraEnvInternal(ctx, key, createParams)
mirrorRegistryConfiguration, err := mirrorregistries.ProcessMirrorRegistryConfig(ctx, log, r.Client, infraEnv.Spec.MirrorRegistryRef)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to handle somewhere a conflict between ACI and InfraEnv? I.e. do we want to settle a potential mismatch in config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, by @avishayt definition the user is able to set different mirror registry for InfraEnv and ACI

Copy link
Contributor

Choose a reason for hiding this comment

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

I forgot to click submit on my comment yesterday 😆 but I had the same thought!

Do we handle if user sets different mirror registry for both? Do we merge the mirror registries when they start install?

Copy link
Contributor

Choose a reason for hiding this comment

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

So maybe worth adding some warning/info logs? I mean in case the user did it by mistake - as I suppose the common use-case would be to set smilier registries.

Copy link
Contributor Author

@eliorerz eliorerz Aug 11, 2024

Choose a reason for hiding this comment

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

Basically, We don't want to check if the mirror registries are different, as long as they are exists. On failure the user will see the status update.

@CrystalChun
Copy link
Contributor

Just a head's up that Nick is putting in a change for the operator to always include the hub's OCP cluster's CA certificate bundle #6649

Another consideration is if the user supplies an overall Hub Cluster mirror registry CA certificate (that will now be merged with the Hub Cluster's CA bundle from the above PR). We should handle the case where they provide both a per spoke cluster mirror registry CA and a mirror registry CA in the hub cluster.

@eliorerz eliorerz force-pushed the MGMT-18013-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall branch from 588df6b to c296dbc Compare September 30, 2024 09:30
@eliorerz
Copy link
Contributor Author

/test edge-subsystem-aws edge-subsystem-kubeapi-aws edge-unit-test

@eliorerz eliorerz force-pushed the MGMT-18013-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall branch from c296dbc to 109fc2a Compare October 6, 2024 08:00
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2024
@openshift-merge-robot
Copy link

PR needs rebase.

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.

Copy link

openshift-ci bot commented Oct 28, 2024

@eliorerz: 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/edge-e2e-metal-assisted-odf-4-16 b8b6761 link true /test edge-e2e-metal-assisted-odf-4-16
ci/prow/edge-e2e-metal-assisted-cnv-4-16 b8b6761 link true /test edge-e2e-metal-assisted-cnv-4-16
ci/prow/edge-subsystem-kubeapi-aws c296dbc link true /test edge-subsystem-kubeapi-aws
ci/prow/edge-unit-test c296dbc link true /test edge-unit-test
ci/prow/edge-e2e-metal-assisted-odf-4-17 109fc2a link true /test edge-e2e-metal-assisted-odf-4-17
ci/prow/edge-e2e-metal-assisted-cnv-4-17 109fc2a link true /test edge-e2e-metal-assisted-cnv-4-17
ci/prow/edge-e2e-metal-assisted-mtv-4-17 109fc2a link true /test edge-e2e-metal-assisted-mtv-4-17

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants