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

MGMT-18561: MGMT-18562: Add kube api support for adding per cluster mirror registry in AgentClusterInstall #6965

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

eliorerz
Copy link
Contributor

@eliorerz eliorerz commented Nov 3, 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 Nov 3, 2024

@eliorerz: This pull request references MGMT-18561 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.18.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 Nov 3, 2024
Copy link

openshift-ci bot commented Nov 3, 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. api-review Categorizes an issue or PR as actively needing an API review. labels Nov 3, 2024
Copy link

openshift-ci bot commented Nov 3, 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2024
Copy link

codecov bot commented Nov 3, 2024

Codecov Report

Attention: Patch coverage is 58.26446% with 101 lines in your changes missing coverage. Please review.

Project coverage is 68.73%. Comparing base (7a08e50) to head (015f338).

Files with missing lines Patch % Lines
internal/common/db.go 0.00% 39 Missing ⚠️
internal/installcfg/builder/builder.go 62.71% 15 Missing and 7 partials ⚠️
internal/bminventory/inventory.go 57.14% 7 Missing and 5 partials ⚠️
internal/ignition/discovery.go 62.96% 6 Missing and 4 partials ⚠️
...rnal/controller/controllers/infraenv_controller.go 52.94% 4 Missing and 4 partials ⚠️
pkg/mirrorregistries/parser.go 82.92% 5 Missing and 2 partials ⚠️
...oller/controllers/clusterdeployments_controller.go 90.90% 1 Missing and 1 partial ⚠️
pkg/mirrorregistries/generator.go 83.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6965      +/-   ##
==========================================
- Coverage   68.80%   68.73%   -0.08%     
==========================================
  Files         251      252       +1     
  Lines       37635    37795     +160     
==========================================
+ Hits        25896    25977      +81     
- Misses       9420     9485      +65     
- Partials     2319     2333      +14     
Files with missing lines Coverage Δ
internal/bminventory/inventory_v2_handlers.go 56.60% <100.00%> (ø)
...ler/controllers/preprovisioningimage_controller.go 81.81% <100.00%> (ø)
internal/oc/release.go 73.78% <100.00%> (ø)
pkg/mirrorregistries/generator.go 67.64% <83.33%> (+3.06%) ⬆️
...oller/controllers/clusterdeployments_controller.go 71.68% <90.90%> (+0.15%) ⬆️
pkg/mirrorregistries/parser.go 82.92% <82.92%> (ø)
...rnal/controller/controllers/infraenv_controller.go 63.44% <52.94%> (-0.46%) ⬇️
internal/ignition/discovery.go 69.51% <62.96%> (+0.22%) ⬆️
internal/bminventory/inventory.go 70.53% <57.14%> (-0.18%) ⬇️
internal/installcfg/builder/builder.go 79.59% <62.71%> (-3.34%) ⬇️
... and 1 more

... and 1 file with indirect coverage changes

@eliorerz
Copy link
Contributor Author

eliorerz commented Nov 3, 2024

/retest

@eliorerz eliorerz force-pushed the MGMT-18561-MGMT-18562-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall-db branch from 67b98f8 to fd90bbd Compare November 3, 2024 12:54
@eliorerz
Copy link
Contributor Author

eliorerz commented Nov 3, 2024

/cc @carbonin @CrystalChun
I moved the previous PR to here and added the mirror registry to the database

@CrystalChun
Copy link
Contributor

Retested and verified it's pulling from the mirror registry 👍

  Warning  Failed          1s (x2 over 15s)   kubelet            Failed to pull image "quay.io/cchun/testing@sha256:e1f8ac471c4cd63333590309829aa8f1210a62571179d39fc6989ab6a9c09e2e": (Mirrors also failed: [10.1.178.25:5000/cchun/testing@sha256:e1f8ac471c4cd63333590309829aa8f1210a62571179d39fc6989ab6a9c09e2e: pinging container registry 10.1.178.25:5000: Get "https://10.1.178.25:5000/v2/": http: server gave HTTP response to HTTPS client]): quay.io/cchun/testing@sha256:e1f8ac471c4cd63333590309829aa8f1210a62571179d39fc6989ab6a9c09e2e: reading manifest sha256:e1f8ac471c4cd63333590309829aa8f1210a62571179d39fc6989ab6a9c09e2e in quay.io/cchun/testing: unauthorized: access to the requested resource is not authorized

internal/bminventory/inventory.go Outdated Show resolved Hide resolved
internal/bminventory/inventory.go Outdated Show resolved Hide resolved
internal/bminventory/inventory_test.go Show resolved Hide resolved
internal/bminventory/inventory_test.go Show resolved Hide resolved
internal/bminventory/inventory.go Outdated Show resolved Hide resolved
internal/ignition/discovery.go Outdated Show resolved Hide resolved
internal/ignition/discovery_test.go Outdated Show resolved Hide resolved
internal/installcfg/builder/builder.go Outdated Show resolved Hide resolved
internal/installcfg/builder/builder.go Outdated Show resolved Hide resolved
pkg/mirrorregistries/mirror_registry.go Outdated Show resolved Hide resolved
@eliorerz eliorerz force-pushed the MGMT-18561-MGMT-18562-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall-db branch from a1af42c to 8ec7bc2 Compare November 7, 2024 13:54
@eliorerz
Copy link
Contributor Author

eliorerz commented Nov 8, 2024

/retest

1 similar comment
@eliorerz
Copy link
Contributor Author

/retest

@eliorerz eliorerz force-pushed the MGMT-18561-MGMT-18562-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall-db branch from 8ec7bc2 to cc43d9f Compare November 11, 2024 09:14
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 12, 2024
@eliorerz eliorerz force-pushed the MGMT-18561-MGMT-18562-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall-db branch from cc43d9f to eddba1a Compare November 12, 2024 17:38
@eliorerz eliorerz force-pushed the MGMT-18561-MGMT-18562-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall-db branch from eddba1a to 98c1f6e Compare November 12, 2024 17:48
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 12, 2024
@eliorerz eliorerz force-pushed the MGMT-18561-MGMT-18562-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall-db branch from 98c1f6e to b97b322 Compare November 12, 2024 17:49
@eliorerz eliorerz force-pushed the MGMT-18561-MGMT-18562-Add-KubeAPI-support-for-adding-mirror-registry-in-AgentClusterInstall-db branch from b97b322 to 015f338 Compare November 12, 2024 18:13
Copy link

openshift-ci bot commented Nov 12, 2024

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

@@ -16,3 +18,12 @@ type ValidationsStatus map[string]ValidationResults

// +kubebuilder:object:generate=true
type ValidationResults []ValidationResult

// MirrorRegistryConfiguration holds the given mirror registry configuration
type MirrorRegistryConfiguration struct {
Copy link
Member

Choose a reason for hiding this comment

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

I still think this doesn't belong in the api module.

It's not a user-facing API. Let's put it in internal/common/db.go with the functions that manage it's representation in the db.

@@ -0,0 +1,102 @@
package mirror_registry
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 generally the convention is to avoid underscores in package names. I think this one would be fine without it.

@@ -548,7 +548,7 @@ func (r *PreprovisioningImageReconciler) AddIronicAgentToInfraEnv(ctx context.Co

updated := false
if string(conf) != infraEnvInternal.InternalIgnitionConfigOverride {
_, err = r.Installer.UpdateInfraEnvInternal(ctx, installer.UpdateInfraEnvParams{InfraEnvID: *infraEnvInternal.ID, InfraEnvUpdateParams: &models.InfraEnvUpdateParams{}}, swag.String(string(conf)))
_, err = r.Installer.UpdateInfraEnvInternal(ctx, installer.UpdateInfraEnvParams{InfraEnvID: *infraEnvInternal.ID, InfraEnvUpdateParams: &models.InfraEnvUpdateParams{}}, swag.String(string(conf)), nil)
Copy link
Member

Choose a reason for hiding this comment

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

Won't this unset the mirror registries?

clusterPkg "github.com/openshift/assisted-service/internal/cluster"
"github.com/openshift/assisted-service/internal/common"
"github.com/openshift/assisted-service/internal/constants"
"github.com/openshift/assisted-service/internal/controller/controllers/mirror_registry"
Copy link
Member

Choose a reason for hiding this comment

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

Can we use an alias for these to differentiate between pkg/mirrorregistries and controllers/mirror_registry (or whatever it ends up being called)

Comment on lines +232 to +233
mirrorRegistriesConfigKey := "MirrorRegistriesConfig"
mirrorRegistriesCAConfigKey := "MirrorRegistriesCAConfig"
Copy link
Member

Choose a reason for hiding this comment

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

Should these be constants?

Comment on lines +237 to +238
(ignitionParams)[mirrorRegistriesConfigKey] = base64.StdEncoding.EncodeToString([]byte(configuration.RegistriesConf))
(ignitionParams)[mirrorRegistriesCAConfigKey] = base64.StdEncoding.EncodeToString([]byte(configuration.CaBundleCrt))
Copy link
Member

Choose a reason for hiding this comment

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

Why parens here?

mirrorRegistriesConfigKey := "MirrorRegistriesConfig"
mirrorRegistriesCAConfigKey := "MirrorRegistriesCAConfig"

if mirror_registry.IsMirrorConfigurationSet(configuration) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a comment here that this is the config from the infraenv, vs the following one which is defined in the environment.

Comment on lines +253 to +254
(ignitionParams)[mirrorRegistriesConfigKey] = base64.StdEncoding.EncodeToString(registriesContents)
(ignitionParams)[mirrorRegistriesCAConfigKey] = base64.StdEncoding.EncodeToString(caContents)
Copy link
Member

Choose a reason for hiding this comment

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

Same here, not sure why this needs parens

func (i *installConfigBuilder) setImageDigestMirrorSet(cfg *installcfg.InstallerConfigBaremetal, configuration *common_api.MirrorRegistryConfiguration) error {
var imageDigestSourceList []installcfg.ImageDigestSource

if mirror_registry.IsMirrorConfigurationSet(configuration) {
Copy link
Member

Choose a reason for hiding this comment

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

Same in here, can we have a comment in these functions saying which block is the cluster config and which is the environmental one?

}
registriesConfList[i] = RegistriesConf{Location: location, Mirror: mirrors}
for _, i := range idmsMirrors {
mirrors := *(*[]string)(unsafe.Pointer(&i.Mirrors))
Copy link
Member

Choose a reason for hiding this comment

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

What is going on here? Feels like this shouldn't be necessary. If it is please add a comment of some sort.

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