Skip to content

HYPERFLEET-568- ci: Fix linting errors caused by the OpenAPI schema update#16

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift-hyperfleet:mainfrom
yingzhanredhat:ying-test
Feb 2, 2026
Merged

HYPERFLEET-568- ci: Fix linting errors caused by the OpenAPI schema update#16
openshift-merge-bot[bot] merged 1 commit intoopenshift-hyperfleet:mainfrom
yingzhanredhat:ying-test

Conversation

@yingzhanredhat
Copy link
Contributor

@yingzhanredhat yingzhanredhat commented Jan 29, 2026

Summary by CodeRabbit

  • Refactor

    • Switched readiness checks from phase-based to condition-based across clusters, nodepools and adapters for more precise status handling.
  • Tests

    • Updated end-to-end tests to assert condition-based readiness; some prior phase assertions deferred to TODOs.
  • New Features

    • Added a "Ready" condition type for cluster-level resources to standardize readiness checks.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

This PR replaces phase-based readiness checks with condition-based checks across helpers and e2e tests. New waiter functions were added: WaitForClusterCondition, WaitForAdapterCondition, WaitForAllAdapterConditions, and WaitForNodePoolCondition; they inspect resource Status.Conditions (and adapter-specific conditions) for matching (Type, Status) pairs. Tests were updated to use the new condition-based waiters; an initial cluster phase assertion was deferred inside a TODO block and an unused openapi import removed. A new exported constant ConditionTypeReady was added.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Test as rgba(6,86,147,0.5) Test
    participant Helper as rgba(0,153,68,0.5) Helper
    participant API as rgba(153,51,255,0.5) API Server
    participant Resource as rgba(204,102,0,0.5) Cluster/NodePool
    participant Adapter as rgba(220,20,60,0.5) Adapter Status

    Test->>Helper: WaitForClusterCondition(clusterID, "Ready", expectedStatus, timeout)
    Helper->>API: GET /clusters/{clusterID}
    API-->>Helper: cluster.Status (Conditions[])
    alt matching condition found
        Helper-->>Test: return nil
    else no match
        loop until timeout
            Helper->>API: GET /clusters/{clusterID}
            API-->>Helper: cluster.Status (Conditions[])
        end
        Helper-->>Test: timeout error
    end

    Test->>Helper: WaitForAllAdapterConditions(clusterID, "Applied", expectedStatus, timeout)
    Helper->>API: GET /clusters/{clusterID}/statuses
    API-->>Helper: [adapterStatuses]
    Helper->>Adapter: inspect each adapter.Status.Conditions for (Type, Status)
    alt all adapters match
        Helper-->>Test: return nil
    else
        Helper-->>Test: timeout/error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

lgtm

Suggested reviewers

  • crizzo71
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes fixing linting errors from an OpenAPI schema update, but the actual changes involve refactoring code to use condition-based checks instead of phase-based checks across multiple files. Update the title to reflect the main change: something like 'Refactor from phase-based to condition-based readiness checks' would better represent the substantive code changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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

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

@yingzhanredhat yingzhanredhat changed the title Fix linting errors caused by the OpenAPI schema update HYPERFLEET-568- ci: Fix linting errors caused by the OpenAPI schema update Jan 29, 2026
@yingzhanredhat yingzhanredhat force-pushed the ying-test branch 2 times, most recently from 94b54a6 to aa54863 Compare January 30, 2026 03:37
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

Caution

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

⚠️ Outside diff range comments (1)
pkg/helper/wait.go (1)

41-74: ⚠️ Potential issue | 🔴 Critical

Replace non-existent HasCondition calls with HasAdapterCondition.
The code calls h.HasCondition() which does not exist as a method on Helper. Only HasAdapterCondition(conditions []openapi.AdapterCondition, condType string, status openapi.AdapterConditionStatus) bool is defined. This causes compile-time errors.

🔧 Required changes
-               hasCondition := h.HasCondition(status.Conditions, condType, expectedStatus)
+               hasCondition := h.HasAdapterCondition(status.Conditions, condType, expectedStatus)
-           hasCondition := h.HasCondition(adapterStatus.Conditions, condType, expectedStatus)
+           hasCondition := h.HasAdapterCondition(adapterStatus.Conditions, condType, expectedStatus)
🧹 Nitpick comments (2)
e2e/nodepool/creation.go (1)

35-52: Use client.ConditionTypeReady instead of "Ready" literals.
Keeps condition types centralized and avoids drift.

♻️ Suggested refactor
- err = h.WaitForClusterCondition(ctx, clusterID, "Ready", openapi.ResourceConditionStatusTrue, h.Cfg.Timeouts.Cluster.Ready)
+ err = h.WaitForClusterCondition(ctx, clusterID, client.ConditionTypeReady, openapi.ResourceConditionStatusTrue, h.Cfg.Timeouts.Cluster.Ready)
- err = h.WaitForNodePoolCondition(ctx, clusterID, nodepoolID, "Ready", openapi.ResourceConditionStatusTrue, h.Cfg.Timeouts.NodePool.Ready)
+ err = h.WaitForNodePoolCondition(ctx, clusterID, nodepoolID, client.ConditionTypeReady, openapi.ResourceConditionStatusTrue, h.Cfg.Timeouts.NodePool.Ready)
- hasReady := h.HasResourceCondition(finalNodePool.Status.Conditions, client.ConditionTypeReady, openapi.ResourceConditionStatusTrue)
+ hasReady := h.HasResourceCondition(finalNodePool.Status.Conditions, client.ConditionTypeReady, openapi.ResourceConditionStatusTrue)

Also applies to: 81-83

e2e/cluster/creation.go (1)

36-73: Replace the commented-out phase checks with condition-based readiness.
The TODO block disables readiness assertions, so this test can pass even if the cluster never becomes Ready. Consider using the new condition-based helpers to restore coverage.

✅ Suggested replacement (condition-based)
-           /** <TODO>
-           Expect(cluster.Status.Phase).To(Equal(openapi.NotReady), "cluster should be in NotReady phase initially")
-
-                        Cluster final status depends on all deployed adapter result, this is still in progress.
-                        Will update this part once adapter scope is finalized.
-                       ginkgo.By("monitoring cluster status - waiting for phase transition to Ready")
-                       err = h.WaitForClusterPhase(ctx, clusterID, openapi.Ready, h.Cfg.Timeouts.Cluster.Ready)
-                       Expect(err).NotTo(HaveOccurred(), "cluster should reach Ready phase")
-
-                       ginkgo.By("verifying all adapter conditions via /clusters/{id}/statuses endpoint")
-                       const expectedAdapterCount = 1 // GCP cluster expects 1 adapter
-                       Eventually(func(g Gomega) {
-                           statuses, err := h.Client.GetClusterStatuses(ctx, clusterID)
-                           g.Expect(err).NotTo(HaveOccurred(), "failed to get cluster statuses")
-                           g.Expect(statuses.Items).To(HaveLen(expectedAdapterCount),
-                               "expected %d adapter(s), got %d", expectedAdapterCount, len(statuses.Items))
-
-                           for _, adapter := range statuses.Items {
-                               hasApplied := h.HasCondition(adapter.Conditions, client.ConditionTypeApplied, openapi.True)
-                               g.Expect(hasApplied).To(BeTrue(),
-                                   "adapter %s should have Applied=True", adapter.Adapter)
-
-                               hasAvailable := h.HasCondition(adapter.Conditions, client.ConditionTypeAvailable, openapi.True)
-                               g.Expect(hasAvailable).To(BeTrue(),
-                                   "adapter %s should have Available=True", adapter.Adapter)
-
-                               hasHealth := h.HasCondition(adapter.Conditions, client.ConditionTypeHealth, openapi.True)
-                               g.Expect(hasHealth).To(BeTrue(),
-                                   "adapter %s should have Health=True", adapter.Adapter)
-                           }
-                       }, h.Cfg.Timeouts.Adapter.Processing, h.Cfg.Polling.Interval).Should(Succeed())
-
-                       ginkgo.By("verifying final cluster state")
-                       finalCluster, err := h.Client.GetCluster(ctx, clusterID)
-                       Expect(err).NotTo(HaveOccurred(), "failed to get final cluster state")
-                       Expect(finalCluster.Status).NotTo(BeNil(), "cluster status should be present")
-                       Expect(finalCluster.Status.Phase).To(Equal(openapi.Ready), "cluster phase should be Ready")
-                       **/
+           ginkgo.By("waiting for cluster to become Ready")
+           err = h.WaitForClusterCondition(ctx, clusterID, client.ConditionTypeReady, openapi.ResourceConditionStatusTrue, h.Cfg.Timeouts.Cluster.Ready)
+           Expect(err).NotTo(HaveOccurred(), "cluster should have Ready condition set to True")
📦 Import updates needed
 import (
     "context"

     "github.com/onsi/ginkgo/v2"
     . "github.com/onsi/gomega" //nolint:staticcheck // dot import for test readability

+    "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/api/openapi"
+    "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/client"
     "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/helper"
     "github.com/openshift-hyperfleet/hyperfleet-e2e/pkg/labels"
 )

If you want, I can draft a fuller condition-based adapter check block (matching the new adapter condition helpers).

@yingzhanredhat
Copy link
Contributor Author

@yasun1 Would you help review it?Thanks

@yasun1
Copy link
Contributor

yasun1 commented Feb 2, 2026

/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Feb 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yasun1

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

@openshift-ci openshift-ci bot added the approved label Feb 2, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit fa76284 into openshift-hyperfleet:main Feb 2, 2026
5 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