Skip to content

OCPBUGS-59569: Disable create button until CRD is available#16633

Open
rhamilto wants to merge 1 commit into
openshift:mainfrom
rhamilto:OCPBUGS-59569
Open

OCPBUGS-59569: Disable create button until CRD is available#16633
rhamilto wants to merge 1 commit into
openshift:mainfrom
rhamilto:OCPBUGS-59569

Conversation

@rhamilto

@rhamilto rhamilto commented Jun 16, 2026

Copy link
Copy Markdown
Member

Analysis / Root cause:
After an operator installs, the install success page immediately shows a "Create " button linked to the initialization resource. However, the CRD may not yet be registered on the cluster (API discovery polls every 60 seconds), so clicking the button leads to a 404 error.

Solution description:
The CreateInitializationResourceButton component now uses useK8sModel to check whether the CRD model has been discovered. The button is disabled until the model is available. Additionally, a useEffect triggers an immediate API discovery refresh (getResources()) when the model is missing, so the user doesn't have to wait for the next 60-second poll cycle. This follows the existing pattern used in ProvidedAPIsPage.

Screenshots / screen recording:

Test setup:
Install an operator that declares an initialization resource (e.g. Network Observability with FlowCollector).

Test cases:

  1. Install the operator and verify the "Create" button is disabled immediately after install succeeds
  2. Verify the button enables once the CRD is registered on the cluster
  3. Verify the button still works correctly when the CRD is already available

Unit tests:
Added operator-install-page.spec.tsx covering:

  • Returns null when no initialization resource is provided
  • Dispatches getResources when the CRD model is missing
  • Does not dispatch when the model is already available
  • Button is disabled when the model is missing
  • Button is disabled when the disabled prop is true
  • Button is enabled and wrapped in a link when the model is available

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:
https://redhat.atlassian.net/browse/OCPBUGS-59569

Reviewers and assignees:

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved initialization resource creation behavior on the operator installation page when the Kubernetes model isn’t available yet, including an automatic refresh and more accurate create button enablement and accessibility state.
  • Tests

    • Added Jest + React Testing Library coverage for the create initialization resource button to verify rendering, refresh dispatching, button enabled/disabled behavior, and the generated details link.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 00df4aa6-3395-4db3-9fc3-2d9bd2a501fc

📥 Commits

Reviewing files that changed from the base of the PR and between b8050d2 and 4d18c43.

📒 Files selected for processing (2)
  • frontend/packages/operator-lifecycle-manager/src/components/__tests__/operator-install-page.spec.tsx
  • frontend/packages/operator-lifecycle-manager/src/components/operator-install-page.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/packages/operator-lifecycle-manager/src/components/tests/operator-install-page.spec.tsx
  • frontend/packages/operator-lifecycle-manager/src/components/operator-install-page.tsx

Walkthrough

CreateInitializationResourceButton is updated to use useK8sModel to check whether the initialization resource model is loaded, and useEffect to dispatch getResources() once when the model is absent. The button's disabled and ARIA state now combines the existing disabled prop with a model-availability check. Tests cover all render states and dispatch conditions.

Changes

Model availability and refresh trigger

Layer / File(s) Summary
Component implementation with model availability check
frontend/packages/operator-lifecycle-manager/src/components/operator-install-page.tsx
Imports expanded to include useEffect, useState, useConsoleDispatch, useK8sModel, and getResources. Component derives reference from initializationResource, checks model availability via useK8sModel, dispatches getResources() once via useEffect when model is missing and refresh has not occurred, and gates the button's disabled/ARIA state on both the incoming disabled prop and model loading state. Props typing updated to make initializationResource optional.
Component test suite
frontend/packages/operator-lifecycle-manager/src/components/__tests__/operator-install-page.spec.tsx
Test suite verifies component renders nothing when initialization resource is absent, dispatches getResources() when model is missing, skips dispatch when model is available, disables button when model is missing or disabled prop is true, and enables button with correct CSV-details link when model is present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

verified

Suggested reviewers

  • fsgreco
  • TheRealJon
🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Test Structure And Quality ❓ Inconclusive The custom check specifies Ginkgo test requirements, but the PR contains Jest/React Testing Library tests. Ginkgo is a Go testing framework, while this PR only modifies TypeScript/React components... Clarify whether the check should apply to all test frameworks (including Jest) or only to Ginkgo tests. The PR does not contain any Ginkgo tests to review.
✅ Passed checks (14 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: disabling a create button until a CRD is available, with a Jira issue reference as required.
Description check ✅ Passed The description covers all required sections including analysis, solution, test setup, test cases, unit tests, and browser conformance with the Jira issue link.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed This PR is for a frontend TypeScript/React component, not a Go project using Ginkgo. The custom check for Ginkgo test names is not applicable to this codebase.
Microshift Test Compatibility ✅ Passed PR adds Jest/React Testing Library unit tests, not Ginkgo e2e tests. Custom check applies only to Ginkgo e2e tests, which are not present in this PR.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No Ginkgo e2e tests added in this PR. The test file (operator-install-page.spec.tsx) is a Jest/React unit test that does not interact with cluster infrastructure or make any multi-node assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only frontend UI code (React components/tests) with no deployment manifests, operator controllers, or scheduling constraints. Not applicable to topology-aware scheduling check.
Ote Binary Stdout Contract ✅ Passed PR modifies only frontend TypeScript/React code with no OTE binaries, Go code, or process-level stdout writes. The custom check is not applicable to this frontend component and test changes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR contains only Jest/React unit tests in TypeScript, not Ginkgo e2e tests. Custom check targets Ginkgo e2e tests only, making it not applicable.
No-Weak-Crypto ✅ Passed No weak crypto algorithms, custom crypto implementations, or insecure secret comparisons detected. PR modifies UI components for Kubernetes operator installation, involving no cryptographic operati...
Container-Privileges ✅ Passed PR contains only frontend React/TypeScript code with no container or K8s manifests; container-privileges check does not apply.
No-Sensitive-Data-In-Logs ✅ Passed No logging statements or sensitive data exposure found in the changes. The PR adds state management and API discovery logic without any code that logs, displays, or transmits sensitive information.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@rhamilto

Copy link
Copy Markdown
Member Author

/assign @TheRealJon

@rhamilto

Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 16, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-59569, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Analysis / Root cause:
After an operator installs, the install success page immediately shows a "Create " button linked to the initialization resource. However, the CRD may not yet be registered on the cluster (API discovery polls every 60 seconds), so clicking the button leads to a 404 error.

Solution description:
The CreateInitializationResourceButton component now uses useK8sModel to check whether the CRD model has been discovered. The button is disabled until the model is available. Additionally, a useEffect triggers an immediate API discovery refresh (getResources()) when the model is missing, so the user doesn't have to wait for the next 60-second poll cycle. This follows the existing pattern used in ProvidedAPIsPage.

Screenshots / screen recording:

Test setup:
Install an operator that declares an initialization resource (e.g. Network Observability with FlowCollector).

Test cases:

  1. Install the operator and verify the "Create" button is disabled immediately after install succeeds
  2. Verify the button enables once the CRD is registered on the cluster
  3. Verify the button still works correctly when the CRD is already available

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:
https://redhat.atlassian.net/browse/OCPBUGS-59569

Reviewers and assignees:

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Improvements
  • Enhanced initialization resource button to better detect resource availability and automatically trigger resource discovery when needed, ensuring the button state accurately reflects whether required resources are loaded and ready.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-59569, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested review from cajieh and fsgreco June 16, 2026 16:40
@openshift-ci openshift-ci Bot added the component/olm Related to OLM label Jun 16, 2026
@openshift-ci

openshift-ci Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto

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 Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 16, 2026
@rhamilto

Copy link
Copy Markdown
Member Author

/retest

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/packages/operator-lifecycle-manager/src/components/__tests__/operator-install-page.spec.tsx (1)

37-41: ⚡ Quick win

Add afterEach(() => jest.restoreAllMocks()) for test isolation consistency.

The suite clears call history but does not restore mocks after each test.

As per coding guidelines, “Clean up mocks in unit tests by calling jest.restoreAllMocks() in afterEach() blocks.”

Suggested update
 describe('CreateInitializationResourceButton', () => {
   beforeEach(() => {
     jest.clearAllMocks();
     mockModel = undefined;
     mockInFlight = false;
   });
+
+  afterEach(() => {
+    jest.restoreAllMocks();
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@frontend/packages/operator-lifecycle-manager/src/components/__tests__/operator-install-page.spec.tsx`
around lines 37 - 41, Add an afterEach hook in the
operator-install-page.spec.tsx test file to properly restore all mocks after
each test completes, ensuring consistent test isolation. Place the afterEach
hook immediately after the existing beforeEach hook and call
jest.restoreAllMocks() within it to fully clean up mock state between tests.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@frontend/packages/operator-lifecycle-manager/src/components/__tests__/operator-install-page.spec.tsx`:
- Around line 50-53: The test for "dispatches getResources when the model is
missing" in the CreateInitializationResourceButton component only asserts that
mockDispatch was called once, but does not verify that it was called with the
specific getResources action. Add an additional expectation to assert that
mockDispatch was invoked with the getResources action as its argument, so the
test validates the actual contract described by its name rather than just any
dispatch call.

---

Nitpick comments:
In
`@frontend/packages/operator-lifecycle-manager/src/components/__tests__/operator-install-page.spec.tsx`:
- Around line 37-41: Add an afterEach hook in the operator-install-page.spec.tsx
test file to properly restore all mocks after each test completes, ensuring
consistent test isolation. Place the afterEach hook immediately after the
existing beforeEach hook and call jest.restoreAllMocks() within it to fully
clean up mock state between tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: eae86129-87a6-4d4d-a53d-5191bf94de9d

📥 Commits

Reviewing files that changed from the base of the PR and between c2f00c7 and 8c65ded.

📒 Files selected for processing (2)
  • frontend/packages/operator-lifecycle-manager/src/components/__tests__/operator-install-page.spec.tsx
  • frontend/packages/operator-lifecycle-manager/src/components/operator-install-page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/packages/operator-lifecycle-manager/src/components/operator-install-page.tsx

@rhamilto

Copy link
Copy Markdown
Member Author

/retest

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@rhamilto: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/olm Related to OLM jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants