Skip to content

🌱 Switch grpc addon client to v1beta1 - #212

Merged
openshift-merge-bot[bot] merged 1 commit into
open-cluster-management-io:mainfrom
qiujian16:ce-addon-client
Mar 12, 2026
Merged

🌱 Switch grpc addon client to v1beta1#212
openshift-merge-bot[bot] merged 1 commit into
open-cluster-management-io:mainfrom
qiujian16:ce-addon-client

Conversation

@qiujian16

@qiujian16 qiujian16 commented Mar 11, 2026

Copy link
Copy Markdown
Member

Summary

Related issue(s)

Fixes #

Summary by CodeRabbit

  • Refactor

    • Upgraded the ManagedClusterAddOn client from alpha to beta API and updated public interfaces to use the beta variant.
    • Updated public error APIs to return the new apierros.StatusError type.
  • Bug Fixes

    • Improved robustness: the AddonV1beta1 accessor no longer panics when uninitialized and now returns safely.

@openshift-ci
openshift-ci Bot requested a review from deads2k March 11, 2026 09:33
@openshift-ci

openshift-ci Bot commented Mar 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16

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

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown

Walkthrough

Replaces v1alpha1 addon client usage with v1beta1 in the cloudevents addon client wrapper; updates imports and ManagedClusterAddOnInterface signature to accept beta options and instantiate a v1beta1 client. Separately, error helper signatures now use apierros.StatusError instead of errors.StatusError.

Changes

Cohort / File(s) Summary
Addon client wrapper
pkg/cloudevents/clients/addon/wrapper.go
Switched imports and runtime wiring from addon/v1alpha1addon/v1beta1; updated ManagedClusterAddOnInterface signature to accept *options.GenericClientOptions[*addonapiv1beta1.ManagedClusterAddOn]; instantiate and return a v1beta1 client wrapper; removed panic in AddonV1beta1() accessor.
Error helpers
pkg/cloudevents/clients/errors/errors.go
Updated function signatures and usages to return and reference apierros.StatusError (replacing errors.StatusError) in ToStatusError and NewPublishError.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • deads2k
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is incomplete and contains only the template structure with empty sections (Summary and Related issue(s) are unfilled), lacking any actual implementation details or context. Complete the Summary section with details about why v1beta1 is being adopted and include any related issues or breaking changes. Fill in the Related issue(s) section with relevant issue numbers.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly indicates the main change: migrating the gRPC addon client from v1alpha1 to v1beta1, which matches the primary modification in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@skeeey

skeeey commented Mar 11, 2026

Copy link
Copy Markdown
Member

LGTM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
pkg/cloudevents/clients/addon/wrapper.go (1)

31-33: ⚠️ Potential issue | 🟡 Minor

AddonV1alpha1() returns nil, risking obscure NPE.

Since ManagedClusterAddOnInterface now only populates betaClient, calls to AddonV1alpha1() will return nil. Any subsequent method call (e.g., .ManagedClusterAddOns(ns).Get(...)) will cause a nil pointer dereference at a confusing call site.

For consistency with other unsupported methods like Discovery() and those in AddonClientWrapper (context snippet 3), consider panicking with a clear message:

Proposed fix
 func (a AddonClientSetWrapper) AddonV1alpha1() addonv1alpha1client.AddonV1alpha1Interface {
+	if a.alphaClient == nil {
+		panic("AddonV1alpha1 is unsupported")
+	}
 	return a.alphaClient
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/cloudevents/clients/addon/wrapper.go` around lines 31 - 33, The
AddonV1alpha1 method currently returns a potentially nil alphaClient which can
cause obscure nil-pointer panics; update AddonClientSetWrapper.AddonV1alpha1 to
instead panic with a clear message stating that v1alpha1 is unsupported
(consistent with how Discovery() and unsupported methods in AddonClientWrapper
behave) so callers get an explicit failure instead of a nil return; reference
AddonClientSetWrapper.AddonV1alpha1, alphaClient, betaClient and the existing
patterns in AddonClientWrapper/Discovery() when implementing the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@pkg/cloudevents/clients/addon/wrapper.go`:
- Around line 31-33: The AddonV1alpha1 method currently returns a potentially
nil alphaClient which can cause obscure nil-pointer panics; update
AddonClientSetWrapper.AddonV1alpha1 to instead panic with a clear message
stating that v1alpha1 is unsupported (consistent with how Discovery() and
unsupported methods in AddonClientWrapper behave) so callers get an explicit
failure instead of a nil return; reference AddonClientSetWrapper.AddonV1alpha1,
alphaClient, betaClient and the existing patterns in
AddonClientWrapper/Discovery() when implementing the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0cd22813-d5ca-4706-9abc-3856449a9458

📥 Commits

Reviewing files that changed from the base of the PR and between 8db061d and 560c4fa.

📒 Files selected for processing (1)
  • pkg/cloudevents/clients/addon/wrapper.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
pkg/cloudevents/clients/addon/wrapper.go (1)

31-33: ⚠️ Potential issue | 🟡 Minor

AddonV1alpha1() will return nil, but no callers in the codebase are affected.

ManagedClusterAddOnInterface() only initializes betaClient (lines 49-51), leaving alphaClient as nil. Calling AddonV1alpha1() on the returned wrapper will return nil. However, a search of the codebase found no calls to AddonV1alpha1(), so no existing code breaks.

That said, this violates the interface contract defined by addonclientset.Interface. Consider either initializing alphaClient or adding a panic with a clear error message (consistent with the Discovery() method) to prevent silent nil-pointer failures if the method is called in the future.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/cloudevents/clients/addon/wrapper.go` around lines 31 - 33, The
AddonV1alpha1 method currently returns a possibly nil alphaClient because
ManagedClusterAddOnInterface initializes only betaClient; update the wrapper
creation to also initialize alphaClient (set AddonClientSetWrapper.alphaClient
alongside betaClient) or, to match Discovery(), change AddonV1alpha1 to check
for nil and panic with a clear error message if alphaClient is nil so callers
fail fast; refer to AddonV1alpha1, ManagedClusterAddOnInterface, alphaClient,
betaClient and Discovery() when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/cloudevents/clients/addon/wrapper.go`:
- Around line 40-51: ManagedClusterAddOnInterface currently constructs an
AddonClientSetWrapper but only sets betaClient leaving alphaClient nil which
will make AddonV1alpha1() crash; fix by also constructing and assigning the
alpha client before returning the wrapper (i.e. call the alpha API client
creation like you do for beta: obtain an alpha AgentClient via the appropriate
GenericClientOptions for the alpha ManagedClusterAddOn, create the alpha
ManagedClusterAddOn client (e.g. v1alpha1.NewManagedClusterAddOnClient(...)) and
set AddonClientSetWrapper.alphaClient), or if an alpha options object isn’t
available then update AddonV1alpha1() on AddonClientSetWrapper to defensively
return a safe no-op/empty client or a clear error instead of returning the nil
pointer.

---

Outside diff comments:
In `@pkg/cloudevents/clients/addon/wrapper.go`:
- Around line 31-33: The AddonV1alpha1 method currently returns a possibly nil
alphaClient because ManagedClusterAddOnInterface initializes only betaClient;
update the wrapper creation to also initialize alphaClient (set
AddonClientSetWrapper.alphaClient alongside betaClient) or, to match
Discovery(), change AddonV1alpha1 to check for nil and panic with a clear error
message if alphaClient is nil so callers fail fast; refer to AddonV1alpha1,
ManagedClusterAddOnInterface, alphaClient, betaClient and Discovery() when
making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e82aedc-bf6d-4b63-b71d-79289948cef1

📥 Commits

Reviewing files that changed from the base of the PR and between 560c4fa and 6ed1ccb.

📒 Files selected for processing (1)
  • pkg/cloudevents/clients/addon/wrapper.go

Comment thread pkg/cloudevents/clients/addon/wrapper.go
Signed-off-by: Jian Qiu <jqiu@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
pkg/cloudevents/clients/addon/wrapper.go (1)

39-50: ⚠️ Potential issue | 🔴 Critical

Beta-only construction still returns a partially initialized addonclientset.Interface.

This factory now populates only betaClient, but AddonClientSetWrapper still exposes AddonV1alpha1() and returns a.alphaClient directly on Lines 30-31. Any caller that treats this as a full clientset and reaches for the alpha accessor will get nil and fail at runtime. Either initialize the alpha side as well, or stop returning the full addonclientset.Interface from this helper.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/cloudevents/clients/addon/wrapper.go` around lines 39 - 50,
ManagedClusterAddOnInterface currently builds only the beta side (betaClient)
and returns an AddonClientSetWrapper that still exposes AddonV1alpha1(), causing
alphaClient to be nil at runtime; fix by either initializing alphaClient in the
AddonClientSetWrapper before returning or change the function signature/return
to not present a full addonclientset.Interface (e.g., return a beta-only type).
Locate ManagedClusterAddOnInterface and AddonClientSetWrapper and ensure
alphaClient is constructed (mirror how betaClient is created) or adjust
callers/signature so AddonV1alpha1() cannot be called on a partially initialized
wrapper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@pkg/cloudevents/clients/addon/wrapper.go`:
- Around line 39-50: ManagedClusterAddOnInterface currently builds only the beta
side (betaClient) and returns an AddonClientSetWrapper that still exposes
AddonV1alpha1(), causing alphaClient to be nil at runtime; fix by either
initializing alphaClient in the AddonClientSetWrapper before returning or change
the function signature/return to not present a full addonclientset.Interface
(e.g., return a beta-only type). Locate ManagedClusterAddOnInterface and
AddonClientSetWrapper and ensure alphaClient is constructed (mirror how
betaClient is created) or adjust callers/signature so AddonV1alpha1() cannot be
called on a partially initialized wrapper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aaae7199-5360-4f84-b50c-e6d5d6733946

📥 Commits

Reviewing files that changed from the base of the PR and between cf2bc1f and 3ee69eb.

📒 Files selected for processing (2)
  • pkg/cloudevents/clients/addon/wrapper.go
  • pkg/cloudevents/clients/errors/errors.go

@skeeey

skeeey commented Mar 12, 2026

Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Mar 12, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit f98f8ca into open-cluster-management-io:main Mar 12, 2026
9 checks passed
openshift-merge-bot Bot pushed a commit that referenced this pull request Mar 16, 2026
* 🌱 Fix non-deterministic golangci-lint results for revive linter

Disable issue count limits (max-issues-per-linter, max-same-issues) to
prevent golangci-lint from randomly dropping issues, which causes flaky
CI results. Also exclude the revive var-naming rule for stdlib package
name conflicts, which is non-deterministic due to concurrent analysis
in golangci-lint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: xuezhaojun <zxue@redhat.com>

* 🌱 Document revive flaky behavior and exclusion rule rationale

Add documentation for the non-deterministic revive linter behavior
discovered during PR #212 review, including upstream references and
the rationale for each customized exclusion rule.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: xuezhaojun <zxue@redhat.com>

---------

Signed-off-by: xuezhaojun <zxue@redhat.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai coderabbitai Bot mentioned this pull request Jul 10, 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.

2 participants