Skip to content

Conversation

@zdtsw
Copy link
Member

@zdtsw zdtsw commented Nov 3, 2025

use .spec.appsDomain if it is set
otherwise fall back to .spec.domain

Description

rework on #1318

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work
  • The developer has run the integration test pipeline and verified that it passed successfully

E2E test suite update requirement

When bringing new changes to the operator code, such changes are by default required to be accompanied by extending and/or updating the E2E test suite accordingly.

To opt-out of this requirement:

  1. Please inspect the opt-out guidelines, to determine if the nature of the PR changes allows for skipping this requirement
  2. If opt-out is applicable, provide justification in the dedicated E2E update requirement opt-out justification section below
  3. Check the checkbox below:
  • Skip requirement to update E2E test suite for this PR
  1. Submit/save these changes to the PR description. This will automatically trigger the check.

E2E update requirement opt-out justification

unit test

Summary by CodeRabbit

  • New Features

    • Domain resolution now prioritizes an explicit apps-domain override when present.
  • Bug Fixes

    • Stricter validation of domain values with clearer, propagated error messages when domain info is missing, empty, or cannot be read.
  • Tests

    • Added unit tests covering apps-domain precedence, fallback to domain, and error scenarios for missing/invalid domain.

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

@openshift-ci
Copy link

openshift-ci bot commented Nov 3, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ajayjagan for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

GetDomain now first attempts to return OpenShift Ingress spec.appsDomain if present and non-empty, propagates errors when reading spec.appsDomain or spec.domain, and falls back to spec.domain, returning "spec.domain not found or empty" when domain is missing or empty.

Changes

Cohort / File(s) Summary
Production Implementation
pkg/cluster/cluster_config.go
Add appsDomain override: read spec.appsDomain and return it if non-empty; propagate errors from reading spec.appsDomain; otherwise read spec.domain, propagate read errors, and return explicit "spec.domain not found or empty" when missing/empty.
Tests
pkg/cluster/cluster_config_test.go
Add TestGetDomain with multiple cases covering appsDomain precedence, fallback to spec.domain, empty-value handling, and client/Get errors; add imports (strings, unstructured, cluster/gvk) and extend fake client error triggering for the "cluster" ingress key.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant GetDomain
    participant Client
    participant Ingress

    Caller->>GetDomain: GetDomain()
    GetDomain->>Client: Get(ingress "cluster")
    alt Client returns error
        Client-->>GetDomain: error
        GetDomain-->>Caller: return wrapped error
    else Client returns ingress
        GetDomain->>Ingress: read spec.appsDomain
        alt appsDomain present & non-empty
            Ingress-->>GetDomain: appsDomain value
            GetDomain-->>Caller: return appsDomain
        else appsDomain missing/empty
            GetDomain->>Ingress: read spec.domain
            alt domain present & non-empty
                Ingress-->>GetDomain: domain value
                GetDomain-->>Caller: return domain
            else domain missing/empty
                GetDomain-->>Caller: return "spec.domain not found or empty"
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus areas:
    • pkg/cluster/cluster_config.go: verify error wrapping/messages, appsDomain early-return logic, and empty-value checks.
    • pkg/cluster/cluster_config_test.go: ensure test coverage exercises all branches and fake client error triggers match real keys.

Poem

🐰 I sniffed the ingress for appsDomain first,
If empty, I hopped to domain unrehearsed.
I wrapped each error with tidy care,
Preferring appsDomain if it was there,
A happy rabbit's check — quick, sure, and fair. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for Ingress .spec.appsDomain, which matches the core functionality added in GetDomain method.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 64286ff and 2c937e7.

📒 Files selected for processing (2)
  • pkg/cluster/cluster_config.go (1 hunks)
  • pkg/cluster/cluster_config_test.go (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/cluster/cluster_config_test.go
🔇 Additional comments (2)
pkg/cluster/cluster_config.go (2)

157-164: appsDomain precedence and error handling look correct

The appsDomain override is implemented cleanly: you read spec.appsDomain, wrap any read error with context, and only override when the field is present and non-empty. This matches expected semantics and keeps failure modes explicit.


166-174: Stricter handling of missing/empty spec.domain — verify all callers handle the error

The logic now treats missing or empty spec.domain as an error, representing a behavioral change from previously succeeding with an empty value. All call sites of GetDomain must be reviewed to ensure they correctly handle the new error path and don't assume a successful return with an empty string.


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.

@zdtsw zdtsw requested review from jctanner and lphiri and removed request for mlassak November 3, 2025 17:41
Copy link
Contributor

@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 dfac1ac and 0d311c0.

📒 Files selected for processing (2)
  • pkg/cluster/cluster_config.go (1 hunks)
  • pkg/cluster/cluster_config_test.go (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/cluster/cluster_config_test.go (2)
pkg/cluster/gvk/gvk.go (2)
  • Group (124-128)
  • OpenshiftIngress (184-188)
pkg/cluster/cluster_config.go (1)
  • GetDomain (97-123)
⏰ 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). (3)
  • GitHub Check: Build/push catalog image
  • GitHub Check: golangci-lint
  • GitHub Check: Run tests and collect coverage on internal and pkg
🔇 Additional comments (2)
pkg/cluster/cluster_config_test.go (2)

31-31: LGTM!

The extension to handle key.Name == "cluster" correctly enables error injection for GetDomain test scenarios.


204-351: LGTM! Comprehensive test coverage.

The test function thoroughly validates the new appsDomain precedence logic with well-structured test cases covering:

  • Precedence of appsDomain over domain
  • Fallback behavior for empty or missing appsDomain
  • Error handling for missing domain and ingress not found scenarios

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.09%. Comparing base (56c2f37) to head (4c39564).
⚠️ Report is 42 commits behind head on main.

Files with missing lines Patch % Lines
pkg/cluster/cluster_config.go 60.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2798      +/-   ##
==========================================
+ Coverage   49.91%   50.09%   +0.17%     
==========================================
  Files         144      144              
  Lines       10413    10420       +7     
==========================================
+ Hits         5198     5220      +22     
+ Misses       4661     4644      -17     
- Partials      554      556       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- if user set appsDomain in default Ingress CR, we will use it as domain
  for ODH
- otherwise fall back to the default domain value
- we could consider even to have componentRoutes in the future

Signed-off-by: Wen Zhou <[email protected]>
(cherry picked from commit 757912c)
@openshift-ci
Copy link

openshift-ci bot commented Dec 1, 2025

@zdtsw: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/opendatahub-operator-e2e-hypershift 2c937e7 link false /test opendatahub-operator-e2e-hypershift

Full PR test history. Your PR dashboard.

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.

@zdtsw
Copy link
Member Author

zdtsw commented Dec 1, 2025

/test opendatahub-operator-rhoai-e2e

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

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant