Skip to content

Conversation

@csrwng
Copy link
Contributor

@csrwng csrwng commented Nov 21, 2025

What this PR does / why we need it:

Add unit test to verify that the field
spec.configuration.scheduler.profileCustomizations.dynamicResourceAllocation exists in the generated HostedCluster CRD manifests.

The test validates the field exists in all CRD variants (Default, TechPreviewNoUpgrade, CustomNoUpgrade) by traversing the CRD schema. This ensures that a bump of openshift/api does not accidentally remove this field from HyperShift without proper deprecation.

The test uses schema traversal with cycle detection and depth limits to safely navigate the CRD schema structure.

Add unit test to verify that the field
spec.configuration.scheduler.profileCustomizations.dynamicResourceAllocation
exists in the generated HostedCluster CRD manifests.

The test validates the field exists in all CRD variants (Default,
TechPreviewNoUpgrade, CustomNoUpgrade) by traversing the CRD schema.
This ensures that a bump of openshift/api does not accidentally remove
this field from HyperShift without proper deprecation.

The test uses schema traversal with cycle detection and depth limits
to safely navigate the CRD schema structure.

Signed-off-by: Cesar Wong <[email protected]>
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 21, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

Walkthrough

A new test file introduces validation for a nested field in HostedCluster CRD OpenAPI v3 schemas. The test includes a recursive helper function to traverse JSONSchemaProps structures, checking for the presence of the spec.configuration.scheduler.profileCustomizations.dynamicResourceAllocation field across multiple CRD variants.

Changes

Cohort / File(s) Change Summary
CRD Validation Test
cmd/install/crd_validation_test.go
New file with test function validating nested field existence in HostedCluster CRD schemas via recursive JSONSchemaProps traversal; includes helper function with cycle detection and depth limiting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Recursive traversal logic: Verify the hasFieldInSchema helper function correctly handles all JSONSchemaProps composition types (properties, AllOf, AnyOf, OneOf) without missed cases
  • Cycle detection mechanism: Ensure the visited map and depth limiting prevent infinite recursion and are appropriately scoped for nested paths
  • Test coverage: Confirm all specified CRD variants are tested and assertions properly validate field presence with meaningful error context
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@openshift-ci openshift-ci bot added do-not-merge/needs-area area/cli Indicates the PR includes changes for CLI approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-area labels Nov 21, 2025
@csrwng csrwng marked this pull request as ready for review November 21, 2025 22:28
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 21, 2025
@openshift-ci openshift-ci bot requested review from bryan-cox and enxebre November 21, 2025 22:28
@csrwng csrwng changed the title test(install): validate DynamicResourceAllocation field exists in CRD NO-ISSUE: test(install): validate DynamicResourceAllocation field exists in CRD Nov 21, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 21, 2025
@openshift-ci-robot
Copy link

@csrwng: This pull request explicitly references no jira issue.

In response to this:

What this PR does / why we need it:

Add unit test to verify that the field
spec.configuration.scheduler.profileCustomizations.dynamicResourceAllocation exists in the generated HostedCluster CRD manifests.

The test validates the field exists in all CRD variants (Default, TechPreviewNoUpgrade, CustomNoUpgrade) by traversing the CRD schema. This ensures that a bump of openshift/api does not accidentally remove this field from HyperShift without proper deprecation.

The test uses schema traversal with cycle detection and depth limits to safely navigate the CRD schema structure.

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.

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

🧹 Nitpick comments (1)
cmd/install/crd_validation_test.go (1)

17-68: Schema traversal helper is sound for the intended use

The recursive traversal with depth limiting and cycle detection over Properties + AllOf/AnyOf/OneOf is appropriate for guarding against pathological schemas, and it matches how CRDs typically embed nested objects. Given that the target path is a straight properties chain, this is sufficient and keeps the helper simple without needing to support the full JSON Schema surface (e.g., Items, AdditionalProperties, $ref), which would add complexity without clear benefit here.

If, in the future, you need to guard additional nested fields that live under arrays or maps, consider extending this helper to also walk Items and AdditionalProperties, but it's not necessary for this PR.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 879fcc8 and 0123e30.

📒 Files selected for processing (1)
  • cmd/install/crd_validation_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • cmd/install/crd_validation_test.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). (3)
  • GitHub Check: Red Hat Konflux / hypershift-operator-main-on-pull-request
  • GitHub Check: Red Hat Konflux / hypershift-cli-mce-211-on-pull-request
  • GitHub Check: Red Hat Konflux / hypershift-release-mce-211-on-pull-request
🔇 Additional comments (1)
cmd/install/crd_validation_test.go (1)

70-125: Targeted CRD field-presence test is well-structured

The test cleanly exercises all relevant HostedCluster CRD variants, decodes only the needed files from the embedded assets, and asserts on the v1beta1 OpenAPI v3 schema in a focused way. The failure messages are descriptive (crdPath + fieldPath), which should make regressions easy to diagnose. Hard-coding the CRD paths and version here is acceptable and desirable given the goal of catching accidental field removal during API bumps.

@bryan-cox
Copy link
Member

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, csrwng

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

@bryan-cox
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2025
@JoelSpeed
Copy link
Contributor

@csrwng Can we shift this problem left somehow? I'm concerned that this is protecting a vendor bump and not a merge at the source (o/api). It would be preferable to catch this and prevent the merge at o/api

@csrwng
Copy link
Contributor Author

csrwng commented Nov 24, 2025

sgtm @JoelSpeed. I'll create a test there and close this one.
/close

@openshift-ci openshift-ci bot closed this Nov 24, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 24, 2025

@csrwng: Closed this PR.

In response to this:

sgtm @JoelSpeed. I'll create a test there and close this one.
/close

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.

@csrwng
Copy link
Contributor Author

csrwng commented Nov 24, 2025

/reopen

@openshift-ci openshift-ci bot reopened this Nov 24, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 24, 2025

@csrwng: Reopened this PR.

In response to this:

/reopen

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.

@csrwng
Copy link
Contributor Author

csrwng commented Nov 24, 2025

/retest-required

@bryan-cox
Copy link
Member

/test e2e-aks-4-20

@csrwng
Copy link
Contributor Author

csrwng commented Nov 26, 2025

/verified by unit-test

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Nov 26, 2025
@openshift-ci-robot
Copy link

@csrwng: This PR has been marked as verified by unit-test.

In response to this:

/verified by unit-test

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

/retest-required

Remaining retests: 0 against base HEAD 886e4b5 and 2 for PR HEAD 0123e30 in total

@csrwng
Copy link
Contributor Author

csrwng commented Nov 27, 2025

/test verify

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 50304c0 and 1 for PR HEAD 0123e30 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 3f2c3ad and 0 for PR HEAD 0123e30 in total

@openshift-ci-robot
Copy link

/hold

Revision 0123e30 was retested 3 times: holding

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 28, 2025
@bryan-cox
Copy link
Member

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 28, 2025

@csrwng: all tests passed!

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.

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. area/cli Indicates the PR includes changes for CLI do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants