Skip to content

Conversation

zhujian7
Copy link
Member

@zhujian7 zhujian7 commented Jul 18, 2025

Summary

Related issue(s)

Fixes #

Summary by CodeRabbit

  • Refactor

    • Updated health check logic to use new health checker functions, replacing deprecated ones for deployment and workload probes.
    • Deprecated older health check methods and updated related documentation to guide users to the new approach.
  • Bug Fixes

    • Improved consistency and reliability of health status reporting for deployments and workloads.
    • Adjusted addon availability status to reflect unknown condition when no probe results are found.
  • Chores

    • Updated internal references and removed obsolete code to streamline health check functionality.
    • Enhanced test coverage by refining deployment health check test data and updating test methods.
    • Marked deprecated fields clearly to improve code maintainability.

@openshift-ci openshift-ci bot requested review from elgnay and zhiweiyin318 July 18, 2025 10:33
Copy link

coderabbitai bot commented Jul 18, 2025

Walkthrough

The changes refactor health check logic for deployment and workload probes by replacing deprecated single-resource health check functions with new multi-result health checker functions. Function signatures, return types, and usages are updated accordingly across controllers, utilities, and tests. Deprecated fields and functions are marked, and references are updated to use the new implementations. Additionally, test assertions and data are adjusted to reflect the new health check behavior and status conditions.

Changes

Files/Paths Change Summary
pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go Updated method signatures and return values to use new health checker functions instead of deprecated health check functions; added early exit for missing probe results.
pkg/addonmanager/controllers/agentdeploy/healthcheck_sync_test.go Removed custom health check function; updated to use new utility health checker; enriched test data; removed unused import.
pkg/agent/inteface.go Added explicit Go deprecation comment to the HealthCheck field in WorkHealthProber struct.
pkg/utils/probe_helper.go Replaced deprecated health check functions with new health checker functions; updated function signatures and usages; added deprecations; renamed helper function; updated import alias.
pkg/utils/probe_helper_test.go Updated test to call new HealthChecker interface using batch-style input instead of single resource health check function.
test/integration/kube/agent_deploy_test.go Modified test assertion to expect "Available" condition as Unknown instead of False, reflecting updated health check behavior.

Estimated code review effort

3 (30–60 minutes)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61ac803 and 3b42ff4.

📒 Files selected for processing (1)
  • test/integration/kube/agent_deploy_test.go (1 hunks)
⏰ 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). (7)
  • GitHub Check: e2e-cloudevents
  • GitHub Check: e2e
  • GitHub Check: integration
  • GitHub Check: e2e-hosted
  • GitHub Check: unit
  • GitHub Check: build
  • GitHub Check: verify
🔇 Additional comments (1)
test/integration/kube/agent_deploy_test.go (1)

925-926: LGTM! Test assertion updated to match new health checker behavior.

The change correctly updates the test expectation from False to Unknown status for the addon availability condition when no probe results are found. This aligns with the new health checker implementation that returns Unknown status instead of explicitly False when resources cannot be probed, which is more semantically accurate.

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

openshift-ci bot commented Jul 18, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zhujian7

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

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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b2d4aa and 5b4e451.

📒 Files selected for processing (4)
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go (4 hunks)
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync_test.go (1 hunks)
  • pkg/agent/inteface.go (1 hunks)
  • pkg/utils/probe_helper.go (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go (1)
pkg/utils/probe_helper.go (2)
  • DeploymentAvailabilityHealthChecker (108-111)
  • WorkloadAvailabilityHealthChecker (113-121)
pkg/utils/probe_helper.go (1)
pkg/agent/inteface.go (1)
  • FieldResult (198-204)
⏰ 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). (7)
  • GitHub Check: e2e-hosted
  • GitHub Check: e2e-cloudevents
  • GitHub Check: e2e
  • GitHub Check: build
  • GitHub Check: integration
  • GitHub Check: unit
  • GitHub Check: verify
🔇 Additional comments (8)
pkg/agent/inteface.go (1)

178-182: LGTM! Proper deprecation marking.

The deprecation comment follows Go conventions and clearly indicates that HealthChecker should be used instead.

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

1300-1316: Good refactoring to use standardized health checker.

The change from a custom health check function to utils.DeploymentAvailabilityHealthChecker improves code consistency and aligns with the new health checker approach.

pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go (3)

277-283: Correct migration to health checker functions.

The changes properly handle the transition by returning nil for the deprecated health check parameter and the new health checker function in the appropriate position. This maintains the method signature while migrating to the new approach.


288-314: Method signature correctly updated to use AddonHealthCheckerFunc.

The return type change and the switch to utils.DeploymentAvailabilityHealthChecker align with the new health checker approach.


316-348: Consistent update to AddonHealthCheckerFunc.

The method signature and return value are correctly updated to use utils.WorkloadAvailabilityHealthChecker, maintaining consistency with the deployment prober changes.

pkg/utils/probe_helper.go (3)

23-39: Correct update to use HealthChecker in NewDeploymentProber.

The function now properly uses the HealthChecker field with DeploymentAvailabilityHealthChecker, aligning with the deprecation of the HealthCheck field.


41-65: Consistent update to use HealthChecker in NewAllDeploymentsProber.

The function correctly uses the new HealthChecker field, maintaining consistency with the NewDeploymentProber changes.


108-121: Well-structured health checker functions.

The new health checker functions properly handle multiple probe results, and the delegation from DeploymentAvailabilityHealthChecker to WorkloadAvailabilityHealthChecker avoids code duplication.

Comment on lines +93 to +106
// Deprecated: use DeploymentAvailabilityHealthChecker instead.
func AllDeploymentsAvailabilityHealthCheck(results []agent.FieldResult,
cluster *clusterv1.ManagedCluster, addon *v1alpha1.ManagedClusterAddOn) error {
cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn) error {
if len(results) < 2 {
return fmt.Errorf("all deployments are not available")
}

for _, result := range results {
if err := WorkloadAvailabilityHealthCheck(result.ResourceIdentifier, result.FeedbackResult); err != nil {
if err := checkWorkloadAvailabilityHealth(result.ResourceIdentifier, result.FeedbackResult); err != nil {
return err
}
}
return nil
}
Copy link

@coderabbitai coderabbitai bot Jul 18, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent deprecation pattern for AllDeploymentsAvailabilityHealthCheck.

The function signature has been changed to accept []agent.FieldResult instead of maintaining the original signature. This breaks backward compatibility for a deprecated function. Consider either:

  1. Keeping the original signature for the deprecated function
  2. Creating a new function with the new signature instead of modifying the deprecated one
🤖 Prompt for AI Agents
In pkg/utils/probe_helper.go around lines 93 to 106, the deprecated function
AllDeploymentsAvailabilityHealthCheck has been modified to accept a new
parameter type []agent.FieldResult, breaking backward compatibility. To fix
this, revert the function signature to its original form to maintain
compatibility, and create a new separate function with the updated signature for
the new behavior instead of changing the deprecated one.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not change the original signature

Copy link

Choose a reason for hiding this comment

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

@zhujian7 You're absolutely right, and I apologize for the confusion. Looking more carefully at the diff, I can see that the only change to the AllDeploymentsAvailabilityHealthCheck function signature is the import alias from *v1alpha1.ManagedClusterAddOn to *addonapiv1alpha1.ManagedClusterAddOn. Both aliases refer to the same underlying type (open-cluster-management.io/api/addon/v1alpha1.ManagedClusterAddOn), so this is not a breaking change to the function signature - it's just a refactoring for import alias consistency.

The function parameters and their types remain functionally identical. Thank you for the correction!

Copy link
Member Author

Choose a reason for hiding this comment

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

v1alpha1.ManagedClusterAddOn and addonapiv1alpha1.ManagedClusterAddOn are the same one

Copy link

Choose a reason for hiding this comment

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

@zhujian7 Exactly! That's precisely what I acknowledged in my previous response. Both v1alpha1.ManagedClusterAddOn and addonapiv1alpha1.ManagedClusterAddOn are just different import aliases for the same underlying type from open-cluster-management.io/api/addon/v1alpha1. The change in the diff is purely a refactoring for import alias consistency and doesn't introduce any breaking changes to the function signature. Thank you for confirming this understanding.

@zhujian7 zhujian7 force-pushed the deprecate-healthcheck branch from 5b4e451 to 61ac803 Compare July 21, 2025 14:12
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: 0

🧹 Nitpick comments (1)
pkg/utils/probe_helper_test.go (1)

117-122: LGTM! Test successfully updated to use the new HealthChecker interface.

The refactoring from the deprecated HealthCheck method to HealthChecker is implemented correctly:

  • The agent.FieldResult struct properly encapsulates the resource identifier and feedback result
  • The batch-style interface is used appropriately with a single test case
  • Test logic and error handling remain intact

Consider adding test cases that exercise the batch processing capability with multiple FieldResult entries to ensure comprehensive coverage of the new interface.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b4e451 and 61ac803.

📒 Files selected for processing (5)
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go (5 hunks)
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync_test.go (3 hunks)
  • pkg/agent/inteface.go (1 hunks)
  • pkg/utils/probe_helper.go (4 hunks)
  • pkg/utils/probe_helper_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/agent/inteface.go
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync_test.go
  • pkg/utils/probe_helper.go
  • pkg/addonmanager/controllers/agentdeploy/healthcheck_sync.go
⏰ 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). (7)
  • GitHub Check: e2e-cloudevents
  • GitHub Check: e2e-hosted
  • GitHub Check: build
  • GitHub Check: integration
  • GitHub Check: unit
  • GitHub Check: e2e
  • GitHub Check: verify
🔇 Additional comments (1)
pkg/utils/probe_helper_test.go (1)

11-11: LGTM! Import addition is necessary for the new interface.

The import of the agent package is correctly added to support the agent.FieldResult struct used in the updated test.

Signed-off-by: zhujian <[email protected]>
@zhujian7
Copy link
Member Author

/cc @zhiweiyin318

@zhujian7
Copy link
Member Author

/cc @qiujian16

@openshift-ci openshift-ci bot requested a review from qiujian16 July 22, 2025 09:21
@zhiweiyin318
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 22, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit ee47752 into open-cluster-management-io:main Jul 22, 2025
15 checks passed
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