Skip to content

Conversation

@elgnay
Copy link
Contributor

@elgnay elgnay commented Dec 31, 2025

Summary

Related issue(s)

Fixes #

Summary by CodeRabbit

  • Chores
    • Migrated addon API usage from v1alpha1 → v1beta1 across the codebase (clients, informers, controllers, agents, helpers, tests).
    • Updated addon resource handling to use DesiredConfig/LastAppliedConfig for config lookup and removed InstallNamespace reliance; updated related signatures and behaviors.
    • Added lifecycle-related annotation constants and adjusted hosting/registration/health-check flows to align with the v1beta1 API.

✏️ Tip: You can customize this high-level summary in your review settings.

@openshift-ci openshift-ci bot requested review from deads2k and qiujian16 December 31, 2025 02:30
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 31, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: elgnay

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 31, 2025

Walkthrough

Migrates addon API usage across the repository from open-cluster-management.io/api/addon/v1alpha1 to v1beta1, updating imports, client constructors (NewForConfig), informers (V1alpha1 → V1beta1), type references, function signatures, constants, and tests; adapts logic where Spec.InstallNamespace was removed (agentInstallNamespace/default behavior).

Changes

Cohort / File(s) Change Summary
Examples: helloworld & helm & agent
cmd/example/helloworld/main.go, cmd/example/helloworld_helm/main.go, examples/helloworld/helloworld.go, examples/helloworld/helloworld_test.go, examples/helloworld_agent/agent.go, examples/helloworld_helm/helloworld_helm.go, examples/helloworld_helm/helloworld_helm_test.go, examples/rbac/rbac.go
Replaced addon v1alpha1 imports/usages with v1beta1; updated GetDefaultValues/GetImageValues and agent client calls to beta1 types; tests and fixtures switched to beta1 types.
Addon factory & helpers
pkg/addonfactory/*, pkg/addonfactory/*_test.go, pkg/addonfactory/test_helper.go
All GetValuesFunc/GetDefaultValues/GetAgentImageValues and related factory signatures now use addon/v1beta1; InstallNamespace removal handled (defaults/agentInstallNamespace hook); tests adjusted.
Addon manager core & constants
pkg/addonmanager/manager.go, pkg/addonmanager/base_manager.go, pkg/addonmanager/cloudevents/manager.go, pkg/addonmanager/constants/constants.go, pkg/addonmanager/addontesting/helpers.go
Switched clientset/imports to v1beta1, NewForConfig usage updated, informer accessors changed to V1beta1; added lifecycle annotation constants and updated hosted-mode helpers to use beta1 types.
Agent deploy controllers & syncers
pkg/addonmanager/controllers/agentdeploy/*.go, pkg/addonmanager/controllers/agentdeploy/*_test.go
Replaced alpha→beta types across controllers, syncers, patchers and listers; updated method signatures, finalizers, condition/reason constants, and config retrieval to v1beta1 semantics.
Config, registration, CMA controllers
pkg/addonmanager/controllers/{addonconfig,registration,cmaconfig,cmamanagedby,certificate}/*.go, *_test.go
Constructor parameters, fields, patcher generics and informer/lister types migrated to v1beta1; config spec/hash handling adapted to v1beta1 DesiredConfig/LastAppliedConfig fields; tests updated.
Utilities, agent interfaces & index
pkg/agent/inteface.go, pkg/index/index.go, pkg/utils/*, pkg/utils/*_test.go
Public interfaces, helper functions, RBAC builders, probe helpers, CSR helpers and indexers updated to accept/return v1beta1 types and constants; RegistrationConfig/KubeClient shape updated where applicable.
Manifest/work helpers
pkg/addonmanager/controllers/*/utils.go, pkg/addonmanager/controllers/*/util_test.go
BuildManifest/ManifestWork helpers, finalizer helpers, owner refs and annotation keys updated to beta1 constants/types; deprecated finalizer handling centralized.
Integration, E2E and test suites
test/**/*, test/integration/**/*, test/e2e/**/*, many pkg/*_test.go
All tests updated from v1alpha1 → v1beta1: imports, object literals, client calls (AddonV1alpha1() → AddonV1beta1()), status/condition expectations, and fixture helpers adjusted across suites.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • qiujian16
  • deads2k
  • zhiweiyin318

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template boilerplate with empty Summary and Related issue(s) sections. No actual implementation details, motivation, or issue references are provided. Fill in the Summary section with details about why the API upgrade is needed, what changed, and any breaking changes. Link related issues using 'Fixes #' or 'Relates to #'.
Docstring Coverage ⚠️ Warning Docstring coverage is 18.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change—upgrading add-on APIs to v1beta1. It is concise, specific, and accurately reflects the primary objective of the changeset.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@elgnay
Copy link
Contributor Author

elgnay commented Dec 31, 2025

/hold

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (7)
test/integration/cloudevents/agent_deploy_test.go (2)

219-227: Critical: InstallNamespace field causes pipeline failure.

The pipeline failure confirms this: unknown field InstallNamespace in struct literal of type "open-cluster-management.io/api/addon/v1beta1".ManagedClusterAddOnSpec.

In v1beta1, ManagedClusterAddOnSpec no longer contains the InstallNamespace field. The install namespace should be handled differently in v1beta1 (typically via status or callback mechanisms).

🔎 Proposed fix

Remove the InstallNamespace field from the spec. If install namespace configuration is required, check the v1beta1 API documentation for the correct approach:

 addon := &addonapiv1beta1.ManagedClusterAddOn{
     ObjectMeta: metav1.ObjectMeta{
         Name: testAddonImpl.name,
     },
-    Spec: addonapiv1beta1.ManagedClusterAddOnSpec{
-        InstallNamespace: "default",
-    },
+    Spec: addonapiv1beta1.ManagedClusterAddOnSpec{},
 }

338-346: Critical: Same InstallNamespace field issue.

This test case also uses the non-existent InstallNamespace field and needs the same fix.

test/integration/kube/agent_deploy_test.go (1)

208-216: Critical: InstallNamespace field doesn't exist in v1beta1 ManagedClusterAddOnSpec.

This file has multiple occurrences of this issue (lines 208-215, 302-309, 461-468, 673-680, 834-841, 1028-1035, 1093-1100). All instances need to be updated to remove the InstallNamespace field from the spec.

pkg/utils/addon_config.go (1)

16-33: Interface returns v1alpha1 while test implementation returns v1beta1.

The AddOnDeploymentConfigGetter interface and defaultAddOnDeploymentConfigGetter.Get() correctly return *addonapiv1alpha1.AddOnDeploymentConfig (lines 18, 31-32), keeping AddOnDeploymentConfig on v1alpha1 while migrating ManagedClusterAddOn to v1beta1. However, the test file addon_config_test.go has testadcGetter.Get() returning *addonapiv1beta1.AddOnDeploymentConfig, which will fail to compile.

pkg/addonmanager/controllers/agentdeploy/default_hook_sync_test.go (1)

44-53: Update OwnerReference APIVersion to v1beta1.

The OwnerReference.APIVersion is set to "addon.open-cluster-management.io/v1alpha1" but should be v1beta1 to match the rest of the file's v1beta1 migration. Update this at lines 46, 168, and 235 in the OwnerReference definitions. The same issue exists in default_sync_test.go at line 189.

pkg/addonfactory/helm_agentaddon_test.go (1)

196-207: Update ToAddOnResourceRequirementsValues to accept addonapiv1beta1.AddOnDeploymentConfig.

The function currently accepts addonapiv1alpha1.AddOnDeploymentConfig but the test is passing addonapiv1beta1.AddOnDeploymentConfig, which will cause a compilation error. The function signature in pkg/addonfactory/addondeploymentconfig.go must be migrated to the beta1 type to match the API migration.

test/integration/kube/suite_test.go (1)

67-68: Add addon/v1beta1 CRD directory path to match API usage.

The test code uses addonapiv1beta1 API throughout, but the CRD directory configuration only includes addon/v1alpha1. Following the pattern established for cluster resources (which include both v1 and v1beta1 paths), add addon/v1beta1 to the CRD paths:

filepath.Join(".", "vendor", "open-cluster-management.io", "api", "addon", "v1beta1"),

This should be added alongside the existing v1alpha1 path to ensure all required CRDs are loaded for the test environment.

🧹 Nitpick comments (5)
pkg/addonmanager/cloudevents/manager.go (1)

15-16: Misleading import alias: addonv1alpha1 imports v1beta1 package.

The alias addonv1alpha1 now imports open-cluster-management.io/api/addon/v1beta1, which is confusing and could lead to maintenance issues. Consider renaming the alias to match the actual API version being imported.

🔎 Proposed fix
-	addonv1alpha1 "open-cluster-management.io/api/addon/v1beta1"
-	addonv1beta1client "open-cluster-management.io/api/client/addon/clientset/versioned"
+	addonv1beta1 "open-cluster-management.io/api/addon/v1beta1"
+	addonv1beta1client "open-cluster-management.io/api/client/addon/clientset/versioned"

Then update references from addonv1alpha1.AddonLabelKey to addonv1beta1.AddonLabelKey throughout the file.

pkg/addonmanager/controllers/certificate/csrapprove.go (1)

22-24: Same misleading alias pattern as other files.

The alias addonv1alpha1 imports v1beta1. For consistency and clarity, consider renaming to addonv1beta1 across the codebase. This would make the code self-documenting about which API version is actually in use.

pkg/addonmanager/manager.go (1)

14-15: Misleading import alias persists across files.

Same issue as noted in other files - addonv1alpha1 imports the v1beta1 package. This creates a maintenance burden and potential confusion for future contributors.

pkg/addonfactory/test_helper.go (1)

19-31: Remove the unused installNamespace parameter from NewFakeManagedClusterAddon.

The installNamespace parameter is accepted but never used since InstallNamespace was removed from the v1beta1 ManagedClusterAddOnSpec. All three call sites in the test suite—template_agentaddon_test.go, helm_agentaddon_test.go, and helper_test.go—pass values that are silently ignored. Remove the parameter and update the three call sites accordingly.

pkg/addonmanager/controllers/addonconfig/controller.go (1)

192-206: Consider handling the case where both DesiredConfig and LastAppliedConfig are nil.

The current logic extracts namespace and name from DesiredConfig or LastAppliedConfig. If both are nil, name will be an empty string, and the subsequent lister.Get("") or lister.Namespace(namespace).Get("") call would likely fail or return unexpected results.

🔎 Suggested defensive check
 		if configReference.DesiredConfig != nil {
 			namespace = configReference.DesiredConfig.Namespace
 			name = configReference.DesiredConfig.Name
 		} else if configReference.LastAppliedConfig != nil {
 			namespace = configReference.LastAppliedConfig.Namespace
 			name = configReference.LastAppliedConfig.Name
 		}
+
+		if name == "" {
+			// Skip if no config reference name is available
+			continue
+		}

 		if namespace == "" {
 			config, err = lister.Get(name)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5846d7 and 74ae87e.

📒 Files selected for processing (79)
  • cmd/example/helloworld/main.go
  • cmd/example/helloworld_helm/main.go
  • examples/helloworld/helloworld.go
  • examples/helloworld/helloworld_test.go
  • examples/helloworld_agent/agent.go
  • examples/helloworld_helm/helloworld_helm.go
  • examples/helloworld_helm/helloworld_helm_test.go
  • examples/rbac/rbac.go
  • pkg/addonfactory/addondeploymentconfig.go
  • pkg/addonfactory/addondeploymentconfig_test.go
  • pkg/addonfactory/addonfactory.go
  • pkg/addonfactory/helm_agentaddon.go
  • pkg/addonfactory/helm_agentaddon_test.go
  • pkg/addonfactory/helper.go
  • pkg/addonfactory/template_agentaddon.go
  • pkg/addonfactory/template_agentaddon_test.go
  • pkg/addonfactory/test_helper.go
  • pkg/addonmanager/addontesting/helpers.go
  • pkg/addonmanager/base_manager.go
  • pkg/addonmanager/cloudevents/manager.go
  • pkg/addonmanager/constants/constants.go
  • pkg/addonmanager/controllers/addonconfig/controller.go
  • pkg/addonmanager/controllers/addonconfig/controller_test.go
  • pkg/addonmanager/controllers/agentdeploy/controller.go
  • pkg/addonmanager/controllers/agentdeploy/default_hook_sync.go
  • pkg/addonmanager/controllers/agentdeploy/default_hook_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/default_sync.go
  • pkg/addonmanager/controllers/agentdeploy/default_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_hook_sync.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_hook_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_sync.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/util_test.go
  • pkg/addonmanager/controllers/agentdeploy/utils.go
  • pkg/addonmanager/controllers/certificate/csrapprove.go
  • pkg/addonmanager/controllers/certificate/csrapprove_test.go
  • pkg/addonmanager/controllers/certificate/csrsign.go
  • pkg/addonmanager/controllers/certificate/csrsign_test.go
  • pkg/addonmanager/controllers/cmaconfig/controller.go
  • pkg/addonmanager/controllers/cmaconfig/controller_test.go
  • pkg/addonmanager/controllers/cmamanagedby/controller.go
  • pkg/addonmanager/controllers/cmamanagedby/controller_test.go
  • pkg/addonmanager/controllers/registration/controller.go
  • pkg/addonmanager/controllers/registration/controller_test.go
  • pkg/addonmanager/manager.go
  • pkg/agent/inteface.go
  • pkg/index/index.go
  • pkg/utils/addon.go
  • pkg/utils/addon_config.go
  • pkg/utils/addon_config_test.go
  • pkg/utils/addon_test.go
  • pkg/utils/csr_helper_test.go
  • pkg/utils/csr_helpers.go
  • pkg/utils/helpers.go
  • pkg/utils/helpers_test.go
  • pkg/utils/permission.go
  • pkg/utils/permission_test.go
  • pkg/utils/probe_helper.go
  • test/e2e/helloworld_helm_test.go
  • test/e2e/helloworld_test.go
  • test/e2ehosted/helloworld_hosted_test.go
  • test/integration/cloudevents/agent_deploy_test.go
  • test/integration/cloudevents/agent_hook_deploy_test.go
  • test/integration/cloudevents/agent_hosting_deploy_test.go
  • test/integration/cloudevents/agent_hosting_hook_deploy_test.go
  • test/integration/cloudevents/suite_test.go
  • test/integration/kube/agent_deploy_test.go
  • test/integration/kube/agent_hook_deploy_test.go
  • test/integration/kube/agent_hosting_deploy_test.go
  • test/integration/kube/agent_hosting_hook_deploy_test.go
  • test/integration/kube/assertion_test.go
  • test/integration/kube/cluster_management_addon_test.go
  • test/integration/kube/csr_test.go
  • test/integration/kube/deleted_managed_cluster_create_addon_test.go
  • test/integration/kube/multiworks_test.go
  • test/integration/kube/registration_test.go
  • test/integration/kube/suite_test.go
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-15T09:30:55.917Z
Learnt from: zhujian7
Repo: open-cluster-management-io/addon-framework PR: 334
File: pkg/addonmanager/base_manager.go:107-111
Timestamp: 2025-09-15T09:30:55.917Z
Learning: BaseAddonManagerImpl instances are designed to operate in a single mode: either templateBasedAddOn=true (handles only template-based addons) or templateBasedAddOn=false (handles all addons). A single manager instance does not handle mixed addon types - this architectural separation ensures clean lifecycle management.

Applied to files:

  • pkg/addonmanager/base_manager.go
📚 Learning: 2025-09-15T08:14:41.882Z
Learnt from: zhujian7
Repo: open-cluster-management-io/addon-framework PR: 334
File: pkg/addonmanager/base_manager.go:83-87
Timestamp: 2025-09-15T08:14:41.882Z
Learning: In template-based addon mode (templateBasedAddOn=true), the FilterTemplateBasedAddOns function intentionally returns false for template-based addons whose Status.ConfigReferences are not yet populated with the proper AddOnTemplate reference and SpecHash. This ensures controllers retry and wait for template configuration to be fully established before processing, preventing premature processing of incompletely configured template addons.

Applied to files:

  • pkg/utils/addon_test.go
  • test/integration/cloudevents/agent_deploy_test.go
  • pkg/utils/addon.go
  • pkg/addonmanager/controllers/addonconfig/controller_test.go
  • pkg/utils/addon_config.go
  • test/integration/kube/agent_hosting_hook_deploy_test.go
  • pkg/addonmanager/controllers/agentdeploy/utils.go
  • test/integration/cloudevents/agent_hosting_hook_deploy_test.go
🧬 Code graph analysis (28)
examples/helloworld/helloworld.go (1)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
pkg/addonmanager/base_manager.go (3)
pkg/utils/helpers.go (1)
  • FilterByAddonName (311-317)
pkg/addonmanager/controllers/cmaconfig/controller.go (1)
  • NewCMAConfigController (47-79)
pkg/addonmanager/controllers/certificate/csrsign.go (1)
  • NewCSRSignController (40-81)
pkg/utils/probe_helper.go (1)
pkg/agent/inteface.go (1)
  • FieldResult (205-211)
pkg/addonfactory/helper.go (1)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
examples/rbac/rbac.go (1)
pkg/agent/inteface.go (1)
  • PermissionConfigFunc (110-110)
pkg/utils/helpers.go (1)
pkg/addonmanager/constants/constants.go (2)
  • AddonLifecycleAnnotationKey (20-20)
  • AddonLifecycleAddonManagerAnnotationValue (24-24)
examples/helloworld_helm/helloworld_helm_test.go (1)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewAddon (81-89)
pkg/addonfactory/addondeploymentconfig.go (1)
pkg/utils/addon_config.go (2)
  • NewAddOnDeploymentConfigGetter (26-28)
  • AddOnDeploymentConfigGetter (17-19)
test/integration/cloudevents/agent_deploy_test.go (1)
pkg/utils/helpers.go (1)
  • MergeOwnerRefs (189-225)
examples/helloworld/helloworld_test.go (1)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewAddon (81-89)
pkg/addonmanager/controllers/agentdeploy/default_hook_sync.go (1)
pkg/agent/inteface.go (1)
  • AgentAddon (19-36)
examples/helloworld_helm/helloworld_helm.go (1)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
pkg/addonmanager/controllers/addonconfig/controller_test.go (1)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewAddon (81-89)
pkg/addonmanager/controllers/registration/controller.go (2)
pkg/agent/inteface.go (1)
  • AgentAddon (19-36)
pkg/utils/addon.go (1)
  • ManagedClusterAddOnFilterFunc (10-10)
pkg/addonfactory/template_agentaddon.go (1)
pkg/addonfactory/addonfactory.go (2)
  • Values (25-25)
  • AddonDefaultInstallNamespace (20-20)
pkg/addonmanager/controllers/certificate/csrapprove_test.go (1)
pkg/agent/inteface.go (2)
  • AgentAddonOptions (39-99)
  • RegistrationOption (119-162)
pkg/addonfactory/template_agentaddon_test.go (1)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
test/integration/kube/agent_hosting_deploy_test.go (1)
pkg/addonmanager/constants/constants.go (1)
  • InstallModeHosted (14-14)
pkg/utils/addon_config.go (1)
pkg/addonfactory/addondeploymentconfig.go (1)
  • NewAddOnDeploymentConfigGetter (195-197)
pkg/addonmanager/controllers/cmamanagedby/controller_test.go (3)
pkg/addonmanager/constants/constants.go (2)
  • AddonLifecycleAnnotationKey (20-20)
  • AddonLifecycleSelfManageAnnotationValue (28-28)
pkg/addonmanager/addontesting/helpers.go (1)
  • AssertActions (297-306)
pkg/utils/helpers.go (1)
  • FilterByAddonName (311-317)
test/integration/cloudevents/suite_test.go (1)
pkg/addonmanager/constants/constants.go (1)
  • GetHostedModeInfo (52-62)
pkg/addonmanager/controllers/agentdeploy/utils.go (1)
pkg/agent/inteface.go (1)
  • AgentAddon (19-36)
pkg/utils/addon_config_test.go (1)
pkg/utils/addon_config.go (1)
  • AddOnDeploymentConfigGetter (17-19)
test/integration/kube/assertion_test.go (2)
pkg/addonmanager/constants/constants.go (2)
  • AddonLifecycleAnnotationKey (20-20)
  • AddonLifecycleAddonManagerAnnotationValue (24-24)
pkg/utils/helpers.go (1)
  • MergeOwnerRefs (189-225)
pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go (1)
pkg/agent/inteface.go (3)
  • HealthProberTypeLease (223-223)
  • HealthProber (172-176)
  • HealthProberTypeWork (229-229)
pkg/addonmanager/controllers/certificate/csrsign_test.go (1)
pkg/agent/inteface.go (2)
  • AgentAddonOptions (39-99)
  • RegistrationOption (119-162)
pkg/addonmanager/controllers/cmaconfig/controller_test.go (1)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewClusterManagementAddon (139-154)
pkg/addonfactory/helm_agentaddon_test.go (2)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
pkg/addonfactory/addondeploymentconfig.go (1)
  • ToAddOnResourceRequirementsValues (141-169)
🪛 GitHub Actions: CloudEventsIntegration
test/integration/cloudevents/agent_deploy_test.go

[error] 224-224: unknown field InstallNamespace in struct literal of type "open-cluster-management.io/api/addon/v1beta1".ManagedClusterAddOnSpec. See failure during 'go test -c ./test/integration/cloudevents -o ./cloudevents-integration.test'.

🪛 GitHub Check: integration
test/integration/kube/assertion_test.go

[failure] 41-41:
undefined: addonapiv1beta1.CustomizedVariable


[failure] 40-40:
undefined: addonapiv1beta1.AddOnDeploymentConfigSpec


[failure] 33-33:
undefined: addonapiv1beta1.CustomizedVariable


[failure] 32-32:
undefined: addonapiv1beta1.AddOnDeploymentConfigSpec


[failure] 25-25:
undefined: addonapiv1beta1.CustomizedVariable


[failure] 24-24:
undefined: addonapiv1beta1.AddOnDeploymentConfigSpec

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: e2e-cloudevents
  • GitHub Check: unit
  • GitHub Check: e2e-hosted
  • GitHub Check: e2e
  • GitHub Check: build
  • GitHub Check: verify

Comment on lines +156 to 166
func (b *clusterManagementAddonBuilder) WithSupportedConfigs(supportedConfigs ...addonapiv1beta1.ConfigGroupResource) *clusterManagementAddonBuilder {
// In v1beta1, use DefaultConfigs instead of SupportedConfigs
// Convert ConfigGroupResource to AddOnConfig
for _, cfg := range supportedConfigs {
b.clusterManagementAddOn.Spec.DefaultConfigs = append(b.clusterManagementAddOn.Spec.DefaultConfigs,
addonapiv1beta1.AddOnConfig{
ConfigGroupResource: cfg,
})
}
return b
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Find usages of WithSupportedConfigs to verify how it's being used in tests
rg -nP --type=go -C3 'WithSupportedConfigs\('

Repository: open-cluster-management-io/addon-framework

Length of output: 707


🏁 Script executed:

# Also look for the API definitions to understand ConfigGroupResource and AddOnConfig structures
rg -nP --type=go 'type ConfigGroupResource struct|type AddOnConfig struct' -A 5

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Search for DefaultConfigs and SupportedConfigs usage to understand the API change
rg -nP --type=go 'DefaultConfigs|SupportedConfigs' -B 2 -A 2 | head -100

Repository: open-cluster-management-io/addon-framework

Length of output: 2819


🏁 Script executed:

# Search for actual calls to WithSupportedConfigs in test files
rg -nP --type=go '\.WithSupportedConfigs\(' -B 2 -A 2

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Look at the API definitions more carefully - search for the struct definitions
rg -nP --type=go 'type ClusterManagementAddOnSpec|type ManagedClusterAddOnSpec' -A 15 | head -80

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Check if DefaultConfigs and SupportedConfigs are both in the same struct or different ones
rg -nP --type=go 'DefaultConfigs|SupportedConfigs' --type=go | grep -E '^\s*(DefaultConfigs|SupportedConfigs)\s*' | head -20

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Find the API definitions - look in common v1beta1 structure
find . -type f -name "*.go" | xargs rg -l "type.*ConfigGroupResource\|type.*AddOnConfig" | head -10

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Get more context from helpers.go to understand the builder
cat -n pkg/addonmanager/addontesting/helpers.go | sed -n '130,180p'

Repository: open-cluster-management-io/addon-framework

Length of output: 2320


🏁 Script executed:

# Search for test files that might use the builder pattern
rg -l "NewClusterManagementAddon\|clusterManagementAddonBuilder" --type=go

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Look at the imports in helpers.go to understand the API
head -30 pkg/addonmanager/addontesting/helpers.go

Repository: open-cluster-management-io/addon-framework

Length of output: 983


🏁 Script executed:

# Search for the API package definition
find . -path "*/api/*" -name "*.go" -type f | head -20

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Search for AddOnConfig and DefaultConfigs definitions
rg "type AddOnConfig|DefaultConfigs \[\]" --type=go -A 3 | head -50

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Search for how DefaultConfigs is used in the codebase
rg "DefaultConfigs" --type=go -B 2 -A 2 | head -60

Repository: open-cluster-management-io/addon-framework

Length of output: 1342


🏁 Script executed:

# Search for ConfigReferent to understand what it does
rg "ConfigReferent" --type=go -B 2 -A 2

Repository: open-cluster-management-io/addon-framework

Length of output: 28078


🏁 Script executed:

# Check if there are any recent changes or comments about the API migration
rg "v1beta1|v1alpha1|DefaultConfigs|SupportedConfigs" --type=go pkg/addonmanager/addontesting/helpers.go -C 1

Repository: open-cluster-management-io/addon-framework

Length of output: 5270


🏁 Script executed:

# Search for AddOnConfig structure definition to understand required fields
rg "type AddOnConfig struct" -A 10 --type=go

Repository: open-cluster-management-io/addon-framework

Length of output: 68


🏁 Script executed:

# Look at how DefaultConfigs is actually used in controllers
rg "\.DefaultConfigs\s*=" --type=go -B 2 -A 3

Repository: open-cluster-management-io/addon-framework

Length of output: 588


The WithSupportedConfigs transformation is incomplete and non-functional.

The method creates AddOnConfig objects with only ConfigGroupResource populated but leaves ConfigReferent empty. Since ConfigReferent (containing Name and Namespace) is required to actually reference a configuration resource—as shown in all test usages across the codebase—the generated configs will not function correctly. This builder method is also currently unused in any tests. Either populate ConfigReferent properly or reconsider the approach for this helper.

🤖 Prompt for AI Agents
In pkg/addonmanager/addontesting/helpers.go around lines 156-166, the
WithSupportedConfigs builder currently creates AddOnConfig entries with only
ConfigGroupResource set leaving ConfigReferent empty; update the builder to
populate ConfigReferent so configs actually reference a resource—set
ConfigReferent.Name to a deterministic value (e.g., cfg.Resource or
cfg.Resource+"-config") and ConfigReferent.Namespace to the addon's namespace
(use b.clusterManagementAddOn.Namespace and fall back to "default" if empty),
ensuring each appended AddOnConfig includes both ConfigGroupResource and a valid
ConfigReferent (unique name if multiple entries) so tests can find the
referenced config objects.

Comment on lines 74 to 93
addon := &addonapiv1beta1.ManagedClusterAddOn{
ObjectMeta: metav1.ObjectMeta{
Name: testAddonImpl.name,
},
Spec: addonapiv1alpha1.ManagedClusterAddOnSpec{
Spec: addonapiv1beta1.ManagedClusterAddOnSpec{
InstallNamespace: "test",
},
}
createManagedClusterAddOnwithOwnerRefs(managedClusterName, addon, cma)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: InstallNamespace field doesn't exist in v1beta1.

Same issue as other test files - the InstallNamespace field in ManagedClusterAddOnSpec doesn't exist in v1beta1.

🤖 Prompt for AI Agents
In test/integration/kube/cluster_management_addon_test.go around lines 74-82,
the ManagedClusterAddOnSpec uses the non-existent InstallNamespace field for
v1beta1; remove the InstallNamespace assignment from Spec and instead set the
object's namespace via ObjectMeta.Namespace = "test" (or use the correct v1beta1
field if your API version exposes it), and ensure
createManagedClusterAddOnwithOwnerRefs call still receives the addon with the
namespace populated.

@elgnay elgnay force-pushed the support-add-v1beta1-api branch from 74ae87e to db39f1b Compare December 31, 2025 06:56
@elgnay elgnay force-pushed the support-add-v1beta1-api branch from db39f1b to 1a75b98 Compare December 31, 2025 06:57
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (7)
pkg/addonmanager/controllers/certificate/csrsign.go (1)

29-37: Minor: stale comment on struct.

Line 29 says "csrApprovingController auto approve..." but this struct is csrSignController. The comment appears to be copy-pasted from csrapprove.go.

🔎 Proposed fix
-// csrApprovingController auto approve the renewal CertificateSigningRequests for an accepted spoke cluster on the hub.
+// csrSignController signs the approved CertificateSigningRequests for an accepted spoke cluster on the hub.
 type csrSignController struct {
pkg/utils/addon_config_test.go (1)

99-133: Inconsistent API version usage in commented-out test case.

The commented-out test case mixes API versions inconsistently:

  • Line 102 references addonapiv1beta1.AddOnDeploymentConfig
  • Line 106 uses addonapiv1alpha1.AddOnDeploymentConfigSpec

If this test case is to be re-enabled in the future, ensure consistent usage of either alpha1 or beta1 throughout the entire test case structure.

🔎 Suggested fix for consistency

If keeping alpha1 for AddOnDeploymentConfig (to match lines 13-25), update line 102:

-// 		&addonapiv1beta1.AddOnDeploymentConfig{
+// 		&addonapiv1alpha1.AddOnDeploymentConfig{

Or, if migrating to beta1, update lines 106 and the getter parameter:

-// 			Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{
+// 			Spec: addonapiv1beta1.AddOnDeploymentConfigSpec{
test/integration/cloudevents/suite_test.go (1)

119-127: Critical: v1beta1 CRDs are not installed in the test environment.

The test environment includes CRDs for addon/v1alpha1 (line 125) but not for addon/v1beta1. This causes the pipeline failure where the server cannot find v1beta1 resources. Since this PR migrates all addon API usage to v1beta1, the test environment must load the v1beta1 CRDs.

🔎 Proposed fix to add v1beta1 CRD path
 	testEnv = &envtest.Environment{
 		ErrorIfCRDPathMissing: true,
 		CRDDirectoryPaths: []string{
 			filepath.Join(".", "vendor", "open-cluster-management.io", "api", "work", "v1", "0000_00_work.open-cluster-management.io_manifestworks.crd.yaml"),
 			filepath.Join(".", "vendor", "open-cluster-management.io", "api", "cluster", "v1"),
 			filepath.Join(".", "vendor", "open-cluster-management.io", "api", "cluster", "v1beta1"),
 			filepath.Join(".", "vendor", "open-cluster-management.io", "api", "addon", "v1alpha1"),
+			filepath.Join(".", "vendor", "open-cluster-management.io", "api", "addon", "v1beta1"),
 		},
 	}
pkg/addonmanager/controllers/agentdeploy/default_hook_sync_test.go (1)

44-53: Update OwnerReference APIVersion to v1beta1.

The test hardcodes APIVersion: "addon.open-cluster-management.io/v1alpha1" while production code uses addonapiv1beta1.GroupVersion.String() (v1beta1). Update to "addon.open-cluster-management.io/v1beta1" to align with the actual API version used throughout the codebase and ensure the test properly reflects production ownership semantics. This affects lines 46, 168, and 235 in this file.

test/integration/kube/suite_test.go (1)

63-69: Add v1beta1 CRD directory path for addon API.

The code uses addonv1beta1client (line 79) and imports addonapiv1beta1 types, but the CRD directory path references only addon/v1alpha1 (line 67). Since ManagedClusterAddOn, ClusterManagementAddOn, and RegistrationConfig are v1beta1 types being used throughout the tests, add a corresponding v1beta1 CRD directory path:

filepath.Join(".", "vendor", "open-cluster-management.io", "api", "addon", "v1beta1"),

Alternatively, verify that the addon/v1alpha1 directory already contains CRDs for both v1alpha1 and v1beta1 versions.

pkg/agent/inteface.go (1)

241-257: Fix critical structural mismatch in RegistrationConfig usage.

The code constructs RegistrationConfig with Type and KubeClient fields, but these do not exist in the actual v1alpha1 API definition (the addon APIs are in v1alpha1, not v1beta1). The v1alpha1 RegistrationConfig only has two fields:

  • signerName (string)
  • subject (Subject, optional)

The Type and KubeClient fields actually belong to RegistrationSpec. The function should return []addonapiv1beta1.RegistrationSpec instead of []addonapiv1beta1.RegistrationConfig, or restructure the return value to use the correct API contract.

pkg/addonmanager/controllers/agentdeploy/default_sync_test.go (1)

187-196: Consider updating the owner reference API version to v1beta1.

The owner reference in the test data still specifies APIVersion: "addon.open-cluster-management.io/v1alpha1". Since this PR migrates to v1beta1, this should likely be updated to "addon.open-cluster-management.io/v1beta1" for consistency.

🔎 Proposed fix
 pTrue := true
 work.SetOwnerReferences([]metav1.OwnerReference{
 	{
-		APIVersion:         "addon.open-cluster-management.io/v1alpha1",
+		APIVersion:         "addon.open-cluster-management.io/v1beta1",
 		Kind:               "ManagedClusterAddOn",
 		Name:               "test",
 		UID:                "",
 		Controller:         &pTrue,
 		BlockOwnerDeletion: &pTrue,
 	},
 })
♻️ Duplicate comments (4)
pkg/addonmanager/addontesting/helpers.go (1)

156-166: The incomplete WithSupportedConfigs implementation persists.

As noted in the previous review, this method creates AddOnConfig objects with only ConfigGroupResource populated while leaving ConfigReferent empty. Since ConfigReferent (containing Name and Namespace) is required to actually reference a configuration resource, these configs remain non-functional. The previous review provided a detailed prompt for properly populating ConfigReferent with deterministic values.

test/integration/cloudevents/agent_hosting_hook_deploy_test.go (1)

132-142: Critical: AddOnDeploymentConfig should use v1beta1 API.

Same issue as in agent_hook_deploy_test.go: this code creates an AddOnDeploymentConfig using addonapiv1alpha1 types and calls hubAddonClient.AddonV1alpha1(), which is inconsistent with the v1beta1 migration.

🔎 Proposed fix to use v1beta1 AddOnDeploymentConfig
-		deployConfig := &addonapiv1alpha1.AddOnDeploymentConfig{
+		deployConfig := &addonapiv1beta1.AddOnDeploymentConfig{
 			ObjectMeta: metav1.ObjectMeta{
 				Name:      "test-deploy-config",
 				Namespace: managedClusterName,
 			},
-			Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{
+			Spec: addonapiv1beta1.AddOnDeploymentConfigSpec{
 				AgentInstallNamespace: "default",
 			},
 		}
-		_, err = hubAddonClient.AddonV1alpha1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
+		_, err = hubAddonClient.AddonV1beta1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
 		gomega.Expect(err).ToNot(gomega.HaveOccurred())
test/integration/cloudevents/agent_hosting_deploy_test.go (1)

127-137: Critical: AddOnDeploymentConfig should use v1beta1 API.

This file has the same inconsistency: AddOnDeploymentConfig is created using v1alpha1 types while the rest of the code uses v1beta1.

🔎 Proposed fix to use v1beta1 AddOnDeploymentConfig
-		deployConfig := &addonapiv1alpha1.AddOnDeploymentConfig{
+		deployConfig := &addonapiv1beta1.AddOnDeploymentConfig{
 			ObjectMeta: metav1.ObjectMeta{
 				Name:      "test-deploy-config",
 				Namespace: managedClusterName,
 			},
-			Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{
+			Spec: addonapiv1beta1.AddOnDeploymentConfigSpec{
 				AgentInstallNamespace: "default",
 			},
 		}
-		_, err = hubAddonClient.AddonV1alpha1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
+		_, err = hubAddonClient.AddonV1beta1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
 		gomega.Expect(err).ToNot(gomega.HaveOccurred())
test/integration/cloudevents/agent_deploy_test.go (1)

183-193: Critical: AddOnDeploymentConfig should use v1beta1 API.

This file also has the same inconsistency with AddOnDeploymentConfig using v1alpha1 types and API calls.

🔎 Proposed fix to use v1beta1 AddOnDeploymentConfig
-		deployConfig := &addonapiv1alpha1.AddOnDeploymentConfig{
+		deployConfig := &addonapiv1beta1.AddOnDeploymentConfig{
 			ObjectMeta: metav1.ObjectMeta{
 				Name:      "test-deploy-config",
 				Namespace: managedClusterName,
 			},
-			Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{
+			Spec: addonapiv1beta1.AddOnDeploymentConfigSpec{
 				AgentInstallNamespace: "default",
 			},
 		}
-		_, err = hubAddonClient.AddonV1alpha1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
+		_, err = hubAddonClient.AddonV1beta1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
 		gomega.Expect(err).ToNot(gomega.HaveOccurred())
🧹 Nitpick comments (6)
pkg/addonmanager/controllers/certificate/csrapprove.go (1)

22-24: Misleading import alias: addonv1alpha1 points to v1beta1 package.

The alias addonv1alpha1 is used for the addon/v1beta1 package, which is confusing and could lead to maintenance issues. Consider renaming to addonv1beta1 for consistency with the other imports on lines 23-24.

🔎 Proposed fix
-	addonv1alpha1 "open-cluster-management.io/api/addon/v1beta1"
+	addonv1beta1 "open-cluster-management.io/api/addon/v1beta1"

Note: This will require updating all references from addonv1alpha1 to addonv1beta1 throughout the file (lines 109, 137, 213).

test/integration/kube/assertion_test.go (2)

96-107: Consider checking Get error before accessing result.

The migration to v1beta1 is correct. However, if Get fails, old will be nil and accessing old.Spec will panic. While gomega.Eventually will retry, explicit error handling would be cleaner.

🔎 Proposed improvement
 func updateClusterManagementAddOn(ctx context.Context, new *addonapiv1beta1.ClusterManagementAddOn) {
 	gomega.Eventually(func() bool {
 		old, err := hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Get(context.Background(), new.Name, metav1.GetOptions{})
+		if err != nil {
+			return false
+		}
 		old.Spec = new.Spec
 		old.Annotations = new.Annotations
-		_, err = hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Update(context.Background(), old, metav1.UpdateOptions{})
-		if err == nil {
-			return true
-		}
-		return false
+		_, err = hubAddonClient.AddonV1beta1().ClusterManagementAddOns().Update(context.Background(), old, metav1.UpdateOptions{})
+		return err == nil
 	}, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue())
 }

130-140: Same pattern as above—consider explicit error handling.

Migration to v1beta1 is correct. Same optional improvement applies: check the Get error before accessing old.Status.

🔎 Proposed improvement
 func updateManagedClusterAddOnStatus(ctx context.Context, new *addonapiv1beta1.ManagedClusterAddOn) {
 	gomega.Eventually(func() bool {
 		old, err := hubAddonClient.AddonV1beta1().ManagedClusterAddOns(new.Namespace).Get(context.Background(), new.Name, metav1.GetOptions{})
+		if err != nil {
+			return false
+		}
 		old.Status = new.Status
-		_, err = hubAddonClient.AddonV1beta1().ManagedClusterAddOns(old.Namespace).UpdateStatus(context.Background(), old, metav1.UpdateOptions{})
-		if err == nil {
-			return true
-		}
-		return false
+		_, err = hubAddonClient.AddonV1beta1().ManagedClusterAddOns(old.Namespace).UpdateStatus(context.Background(), old, metav1.UpdateOptions{})
+		return err == nil
 	}, eventuallyTimeout, eventuallyInterval).Should(gomega.BeTrue())
 }
pkg/addonmanager/addontesting/helpers.go (1)

139-154: Consider removing or documenting unused parameters.

The crd and cr parameters are declared but unused in the function body. These were likely used in v1alpha1 (possibly for AddOnConfiguration or AddOnMeta fields) but are no longer needed in v1beta1. Consider either removing them in a follow-up cleanup or renaming them to _ to signal they're intentionally unused.

🔎 Proposed signature cleanup
-func NewClusterManagementAddon(name, crd, cr string) *clusterManagementAddonBuilder {
+func NewClusterManagementAddon(name string) *clusterManagementAddonBuilder {
 	return &clusterManagementAddonBuilder{
 		&addonapiv1beta1.ClusterManagementAddOn{

Note: This would require updating any test callers of this function.

pkg/addonmanager/constants/constants.go (1)

65-84: Good backward compatibility approach for manifest location.

The fallback to a hardcoded label key ("addon.open-cluster-management.io/hosted-manifest-location") on line 72 provides backward compatibility when the annotation is not set. Consider extracting this hardcoded string to a named constant for clarity and consistency with the other backward-compatibility constants defined above.

🔎 Optional: Extract hardcoded label key to a constant
 const (
 	// ...existing constants...
 
+	// HostedManifestLocationLabelKey is the deprecated label key for hosted manifest location.
+	// This was removed in v1beta1 in favor of annotation only.
+	HostedManifestLocationLabelKey = "addon.open-cluster-management.io/hosted-manifest-location"
 )

 func GetHostedManifestLocation(labels, annotations map[string]string) (string, bool, error) {
 	manifestLocation := annotations[addonv1beta1.HostedManifestLocationAnnotationKey]

 	// In v1beta1, HostedManifestLocationLabelKey was removed in favor of annotation only
 	// For backward compatibility, check labels if annotation is not set
 	if manifestLocation == "" {
-		// Use the hardcoded label key for backward compatibility
-		manifestLocation = labels["addon.open-cluster-management.io/hosted-manifest-location"]
+		manifestLocation = labels[HostedManifestLocationLabelKey]
 	}
pkg/addonmanager/manager.go (1)

14-16: Consider renaming the alias for clarity.

The alias addonv1alpha1 imports open-cluster-management.io/api/addon/v1beta1, which is misleading. Consider renaming to addonv1beta1 or addonapiv1beta1 to match the actual API version being used.

🔎 Proposed fix
-	addonv1alpha1 "open-cluster-management.io/api/addon/v1beta1"
+	addonapiv1beta1 "open-cluster-management.io/api/addon/v1beta1"

Then update the references at lines 70 and 85 to use the new alias.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74ae87e and 1a75b98.

📒 Files selected for processing (79)
  • cmd/example/helloworld/main.go
  • cmd/example/helloworld_helm/main.go
  • examples/helloworld/helloworld.go
  • examples/helloworld/helloworld_test.go
  • examples/helloworld_agent/agent.go
  • examples/helloworld_helm/helloworld_helm.go
  • examples/helloworld_helm/helloworld_helm_test.go
  • examples/rbac/rbac.go
  • pkg/addonfactory/addondeploymentconfig.go
  • pkg/addonfactory/addondeploymentconfig_test.go
  • pkg/addonfactory/addonfactory.go
  • pkg/addonfactory/helm_agentaddon.go
  • pkg/addonfactory/helm_agentaddon_test.go
  • pkg/addonfactory/helper.go
  • pkg/addonfactory/template_agentaddon.go
  • pkg/addonfactory/template_agentaddon_test.go
  • pkg/addonfactory/test_helper.go
  • pkg/addonmanager/addontesting/helpers.go
  • pkg/addonmanager/base_manager.go
  • pkg/addonmanager/cloudevents/manager.go
  • pkg/addonmanager/constants/constants.go
  • pkg/addonmanager/controllers/addonconfig/controller.go
  • pkg/addonmanager/controllers/addonconfig/controller_test.go
  • pkg/addonmanager/controllers/agentdeploy/controller.go
  • pkg/addonmanager/controllers/agentdeploy/default_hook_sync.go
  • pkg/addonmanager/controllers/agentdeploy/default_hook_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/default_sync.go
  • pkg/addonmanager/controllers/agentdeploy/default_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_hook_sync.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_hook_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_sync.go
  • pkg/addonmanager/controllers/agentdeploy/hosted_sync_test.go
  • pkg/addonmanager/controllers/agentdeploy/util_test.go
  • pkg/addonmanager/controllers/agentdeploy/utils.go
  • pkg/addonmanager/controllers/certificate/csrapprove.go
  • pkg/addonmanager/controllers/certificate/csrapprove_test.go
  • pkg/addonmanager/controllers/certificate/csrsign.go
  • pkg/addonmanager/controllers/certificate/csrsign_test.go
  • pkg/addonmanager/controllers/cmaconfig/controller.go
  • pkg/addonmanager/controllers/cmaconfig/controller_test.go
  • pkg/addonmanager/controllers/cmamanagedby/controller.go
  • pkg/addonmanager/controllers/cmamanagedby/controller_test.go
  • pkg/addonmanager/controllers/registration/controller.go
  • pkg/addonmanager/controllers/registration/controller_test.go
  • pkg/addonmanager/manager.go
  • pkg/agent/inteface.go
  • pkg/index/index.go
  • pkg/utils/addon.go
  • pkg/utils/addon_config.go
  • pkg/utils/addon_config_test.go
  • pkg/utils/addon_test.go
  • pkg/utils/csr_helper_test.go
  • pkg/utils/csr_helpers.go
  • pkg/utils/helpers.go
  • pkg/utils/helpers_test.go
  • pkg/utils/permission.go
  • pkg/utils/permission_test.go
  • pkg/utils/probe_helper.go
  • test/e2e/helloworld_helm_test.go
  • test/e2e/helloworld_test.go
  • test/e2ehosted/helloworld_hosted_test.go
  • test/integration/cloudevents/agent_deploy_test.go
  • test/integration/cloudevents/agent_hook_deploy_test.go
  • test/integration/cloudevents/agent_hosting_deploy_test.go
  • test/integration/cloudevents/agent_hosting_hook_deploy_test.go
  • test/integration/cloudevents/suite_test.go
  • test/integration/kube/agent_deploy_test.go
  • test/integration/kube/agent_hook_deploy_test.go
  • test/integration/kube/agent_hosting_deploy_test.go
  • test/integration/kube/agent_hosting_hook_deploy_test.go
  • test/integration/kube/assertion_test.go
  • test/integration/kube/cluster_management_addon_test.go
  • test/integration/kube/csr_test.go
  • test/integration/kube/deleted_managed_cluster_create_addon_test.go
  • test/integration/kube/multiworks_test.go
  • test/integration/kube/registration_test.go
  • test/integration/kube/suite_test.go
🚧 Files skipped from review as they are similar to previous changes (12)
  • pkg/addonmanager/cloudevents/manager.go
  • pkg/addonfactory/template_agentaddon_test.go
  • pkg/utils/csr_helpers.go
  • pkg/addonfactory/test_helper.go
  • cmd/example/helloworld/main.go
  • pkg/utils/addon.go
  • test/integration/kube/registration_test.go
  • examples/rbac/rbac.go
  • cmd/example/helloworld_helm/main.go
  • pkg/utils/permission.go
  • pkg/utils/csr_helper_test.go
  • pkg/addonmanager/controllers/agentdeploy/default_sync.go
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-15T08:14:41.882Z
Learnt from: zhujian7
Repo: open-cluster-management-io/addon-framework PR: 334
File: pkg/addonmanager/base_manager.go:83-87
Timestamp: 2025-09-15T08:14:41.882Z
Learning: In template-based addon mode (templateBasedAddOn=true), the FilterTemplateBasedAddOns function intentionally returns false for template-based addons whose Status.ConfigReferences are not yet populated with the proper AddOnTemplate reference and SpecHash. This ensures controllers retry and wait for template configuration to be fully established before processing, preventing premature processing of incompletely configured template addons.

Applied to files:

  • pkg/addonmanager/controllers/addonconfig/controller_test.go
  • pkg/utils/addon_test.go
  • pkg/addonmanager/controllers/agentdeploy/utils.go
  • test/integration/cloudevents/agent_deploy_test.go
  • pkg/utils/addon_config.go
  • test/integration/kube/agent_hosting_hook_deploy_test.go
  • test/integration/cloudevents/agent_hosting_hook_deploy_test.go
📚 Learning: 2025-09-15T09:30:55.917Z
Learnt from: zhujian7
Repo: open-cluster-management-io/addon-framework PR: 334
File: pkg/addonmanager/base_manager.go:107-111
Timestamp: 2025-09-15T09:30:55.917Z
Learning: BaseAddonManagerImpl instances are designed to operate in a single mode: either templateBasedAddOn=true (handles only template-based addons) or templateBasedAddOn=false (handles all addons). A single manager instance does not handle mixed addon types - this architectural separation ensures clean lifecycle management.

Applied to files:

  • pkg/addonmanager/base_manager.go
🧬 Code graph analysis (19)
test/integration/kube/agent_hosting_deploy_test.go (1)
pkg/addonmanager/constants/constants.go (1)
  • InstallModeHosted (14-14)
examples/helloworld/helloworld.go (1)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
examples/helloworld_helm/helloworld_helm.go (1)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
pkg/addonmanager/base_manager.go (2)
pkg/addonmanager/controllers/cmaconfig/controller.go (1)
  • NewCMAConfigController (47-79)
pkg/addonmanager/controllers/certificate/csrsign.go (1)
  • NewCSRSignController (40-81)
pkg/addonmanager/controllers/registration/controller.go (2)
pkg/agent/inteface.go (1)
  • AgentAddon (19-36)
pkg/utils/addon.go (1)
  • ManagedClusterAddOnFilterFunc (10-10)
pkg/addonfactory/helper.go (1)
pkg/addonfactory/addonfactory.go (1)
  • Values (25-25)
pkg/addonmanager/controllers/agentdeploy/utils.go (1)
pkg/agent/inteface.go (1)
  • AgentAddon (19-36)
test/integration/kube/suite_test.go (2)
pkg/addonmanager/constants/constants.go (1)
  • GetHostedModeInfo (52-62)
pkg/agent/inteface.go (1)
  • HealthProber (172-176)
test/integration/cloudevents/agent_deploy_test.go (1)
pkg/utils/helpers.go (1)
  • MergeOwnerRefs (189-225)
pkg/utils/addon_config.go (1)
pkg/addonfactory/addondeploymentconfig.go (1)
  • NewAddOnDeploymentConfigGetter (195-197)
pkg/addonmanager/controllers/cmamanagedby/controller_test.go (3)
pkg/addonmanager/constants/constants.go (2)
  • AddonLifecycleAnnotationKey (20-20)
  • AddonLifecycleSelfManageAnnotationValue (28-28)
pkg/addonmanager/addontesting/helpers.go (1)
  • AssertActions (297-306)
pkg/utils/helpers.go (1)
  • FilterByAddonName (311-317)
pkg/addonmanager/controllers/certificate/csrsign_test.go (1)
pkg/agent/inteface.go (2)
  • AgentAddonOptions (39-99)
  • RegistrationOption (119-162)
pkg/addonmanager/controllers/registration/controller_test.go (2)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewAddon (81-89)
pkg/agent/inteface.go (1)
  • AgentAddon (19-36)
pkg/addonfactory/addondeploymentconfig_test.go (1)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewAddon (81-89)
pkg/addonmanager/controllers/cmaconfig/controller_test.go (1)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewClusterManagementAddon (139-154)
test/integration/cloudevents/suite_test.go (2)
pkg/addonmanager/constants/constants.go (1)
  • GetHostedModeInfo (52-62)
pkg/agent/inteface.go (1)
  • HealthProber (172-176)
test/integration/kube/assertion_test.go (2)
pkg/addonmanager/constants/constants.go (2)
  • AddonLifecycleAnnotationKey (20-20)
  • AddonLifecycleAddonManagerAnnotationValue (24-24)
pkg/utils/helpers.go (1)
  • MergeOwnerRefs (189-225)
pkg/addonfactory/helm_agentaddon.go (1)
pkg/addonfactory/addonfactory.go (2)
  • Values (25-25)
  • AddonDefaultInstallNamespace (20-20)
examples/helloworld/helloworld_test.go (1)
pkg/addonmanager/addontesting/helpers.go (1)
  • NewAddon (81-89)
🪛 GitHub Actions: CloudEventsIntegration
test/integration/cloudevents/agent_hosting_deploy_test.go

[error] 142-142: the server could not find the requested resource (post clustermanagementaddons.addon.open-cluster-management.io)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: unit
  • GitHub Check: e2e-cloudevents
  • GitHub Check: e2e-hosted
  • GitHub Check: verify
  • GitHub Check: e2e

fakeAddonClient := fakeaddon.NewSimpleClientset(c.cmas...)
addonInformers := addoninformers.NewSharedInformerFactory(fakeAddonClient, 10*time.Minute)
addonInformer := addonInformers.Addon().V1alpha1().ManagedClusterAddOns().Informer()
addonInformer := addonInformers.Addon().V1beta1().ManagedClusterAddOns().Informer()
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Incorrect informer type causes type mismatch.

Line 349 creates an informer for ManagedClusterAddOns, but the test logic expects ClusterManagementAddOns:

  • The field name is clusterManagementAddonIndexer (line 352)
  • The indexer uses index.ClusterManagementAddonByConfig (line 356)
  • The enqueue function is enqueueClusterManagementAddOnsByConfig (line 366)
  • Test cases create and add ClusterManagementAddOn objects to the store (lines 297-363)

This type mismatch will cause the test to fail or behave incorrectly.

🔎 Fix: Use ClusterManagementAddOns informer
-			addonInformer := addonInformers.Addon().V1beta1().ManagedClusterAddOns().Informer()
+			addonInformer := addonInformers.Addon().V1beta1().ClusterManagementAddOns().Informer()
🤖 Prompt for AI Agents
In pkg/addonmanager/controllers/cmaconfig/controller_test.go around line 349,
the test creates an informer for ManagedClusterAddOns but the test logic and
fixtures expect ClusterManagementAddOns; replace the ManagedClusterAddOns
informer with the ClusterManagementAddOns informer (use
addonInformers.Addon().V1beta1().ClusterManagementAddOns().Informer()), update
the variable name if necessary to reflect
clusterManagementAddonInformer/indexer, and ensure any related type
assertions/imports reference ClusterManagementAddOn so the indexer, enqueue
function and test objects match the informer type.

Comment on lines +113 to +123
deployConfig := &addonapiv1alpha1.AddOnDeploymentConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "test-deploy-config",
Namespace: managedClusterName,
},
Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{
AgentInstallNamespace: "default",
},
}
_, err = hubAddonClient.AddonV1alpha1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
gomega.Expect(err).ToNot(gomega.HaveOccurred())
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: AddOnDeploymentConfig should use v1beta1 API.

This code creates an AddOnDeploymentConfig using addonapiv1alpha1 types and calls hubAddonClient.AddonV1alpha1(), which is inconsistent with the v1beta1 migration. All addon resources in this test should use v1beta1 APIs for consistency.

🔎 Proposed fix to use v1beta1 AddOnDeploymentConfig
-		deployConfig := &addonapiv1alpha1.AddOnDeploymentConfig{
+		deployConfig := &addonapiv1beta1.AddOnDeploymentConfig{
 			ObjectMeta: metav1.ObjectMeta{
 				Name:      "test-deploy-config",
 				Namespace: managedClusterName,
 			},
-			Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{
+			Spec: addonapiv1beta1.AddOnDeploymentConfigSpec{
 				AgentInstallNamespace: "default",
 			},
 		}
-		_, err = hubAddonClient.AddonV1alpha1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
+		_, err = hubAddonClient.AddonV1beta1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
 		gomega.Expect(err).ToNot(gomega.HaveOccurred())
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
deployConfig := &addonapiv1alpha1.AddOnDeploymentConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "test-deploy-config",
Namespace: managedClusterName,
},
Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{
AgentInstallNamespace: "default",
},
}
_, err = hubAddonClient.AddonV1alpha1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
gomega.Expect(err).ToNot(gomega.HaveOccurred())
deployConfig := &addonapiv1beta1.AddOnDeploymentConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "test-deploy-config",
Namespace: managedClusterName,
},
Spec: addonapiv1beta1.AddOnDeploymentConfigSpec{
AgentInstallNamespace: "default",
},
}
_, err = hubAddonClient.AddonV1beta1().AddOnDeploymentConfigs(managedClusterName).Create(context.Background(), deployConfig, metav1.CreateOptions{})
gomega.Expect(err).ToNot(gomega.HaveOccurred())
🤖 Prompt for AI Agents
In test/integration/cloudevents/agent_hook_deploy_test.go around lines 113 to
123, the test constructs and creates an AddOnDeploymentConfig using the v1alpha1
types and hubAddonClient.AddonV1alpha1(), but the suite was migrated to v1beta1;
replace usage with the v1beta1 API: change the type to the addonapiv1beta1
AddOnDeploymentConfig, update any import alias to addonapiv1beta1, and call
hubAddonClient.AddonV1beta1().AddOnDeploymentConfigs(managedClusterName).Create(...);
ensure the object fields remain the same and update any compile-time
references/imports accordingly.

@elgnay elgnay closed this Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant