-
Notifications
You must be signed in to change notification settings - Fork 78
feat: Migrate HCO automation from v1beta1 to v1 API #5958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7401e4e
d471c45
e747bb0
23901ff
a23dfb7
0aa6d3c
17f3ae7
4a9499f
d9ad4da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,6 +218,51 @@ When reviewing quarantine PRs, verify the **quarantine mechanism matches the fai | |
| - **Use identity for None** - `if x is None:` NOT `if x == None:` | ||
| - **NEVER compare to True/False** - `if flag:` NOT `if flag == True:` | ||
|
|
||
| ### HCO v1 API Usage (MANDATORY) | ||
|
|
||
| All HCO spec patches and reads MUST use the v1 grouped API structure. Use `HCOv1Spec` builders from `utilities.constants.hco` to construct patches. | ||
|
|
||
| **Available builders:** | ||
| - `HCOv1Spec.virtualization(field=value)` — virtualization fields (live migration, CPU, etc.) | ||
| - `HCOv1Spec.security(field=value)` — security fields (TLS profiles, etc.) | ||
| - `HCOv1Spec.storage(field=value)` — storage fields | ||
| - `HCOv1Spec.deployment(field=value)` — deployment fields | ||
| - `HCOv1Spec.workload_sources(field=value)` — workload source fields | ||
| - `HCOv1Spec.networking(field=value)` — networking fields | ||
| - `HCOv1Spec.node_placements(infra=..., workload=...)` — node placement | ||
| - `HCOv1Spec.vm_options(field=value)` — virtualMachineOptions | ||
| - `HCOv1Spec.aaq_config(field=value)` — applicationAwareConfig | ||
|
|
||
| **Rules:** | ||
|
|
||
| 1. **HCO spec patches MUST use v1 grouped structure** — use `HCOv1Spec` builders, NEVER construct raw nested dicts manually | ||
| 2. **Feature gates MUST use v1 list format** — use `HCOv1Spec.feature_gates(name=True/False)`, NEVER dict format `{"featureGates": {"name": true}}` | ||
| 3. **NEVER use v1beta1 flat spec paths** — `spec.liveMigrationConfig` is wrong, `spec.virtualization.liveMigrationConfig` is correct. See `HCOv1Spec` group builders in `utilities/constants/hco.py` for the complete mapping | ||
| 4. **FG state reads MUST use `HCOv1Spec.is_fg_enabled()`** with the `hco_fg_phases` fixture, not direct list searching. For deprecated FGs, read the dedicated spec field instead | ||
| 5. **`spec.workloads` is renamed to `workload` (singular)** in v1 under `spec.deployment.nodePlacements.workload` | ||
|
|
||
| **Before (v1beta1 -- WRONG):** | ||
| ```python | ||
| # Flat spec path -- WRONG | ||
| patch = {"spec": {"liveMigrationConfig": {"parallelOutboundMigrationsPerNode": 5}}} | ||
| hco_resource.update(resource_dict=patch) | ||
|
|
||
| # Dict feature gate -- WRONG | ||
| fg_patch = {"spec": {"featureGates": {"withHostPassthroughCPU": True}}} | ||
| ``` | ||
|
|
||
| **After (v1 -- CORRECT):** | ||
| ```python | ||
|
Comment on lines
+244
to
+255
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win MEDIUM: Add blank lines around both fenced code blocks.
🧰 Tools🪛 markdownlint-cli2 (0.23.2)[warning] 245-245: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) [warning] 255-255: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| from utilities.constants.hco import HCOv1Spec | ||
|
|
||
| # Grouped spec path | ||
| patch = HCOv1Spec.virtualization(liveMigrationConfig={"parallelOutboundMigrationsPerNode": 5}) | ||
| hco_resource.update(resource_dict=patch) | ||
|
|
||
| # List feature gate | ||
| fg_patch = HCOv1Spec.feature_gates(withHostPassthroughCPU=True) | ||
| ``` | ||
|
|
||
| ### Tests Directory Organization | ||
|
|
||
| - **Feature subdirectories REQUIRED** - each feature MUST have its own subdirectory under component (e.g., `tests/network/ipv6/`) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,6 @@ | |
| @pytest.mark.polarion("CNV-5832") | ||
| def test_hyperconverged_cr_api_version(hyperconverged_resource_scope_function): | ||
| """ | ||
| This test will check the Hyperconverged CR's api_version for v1beta1 | ||
| This test will check the Hyperconverged CR's api_version for v1 | ||
| """ | ||
| assert Resource.ApiVersion.V1BETA1 in hyperconverged_resource_scope_function.instance.apiVersion | ||
| assert hyperconverged_resource_scope_function.instance.apiVersion.endswith(f"/{Resource.ApiVersion.V1}") | ||
|
Comment on lines
8
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win LOW: Add an assertion failure message. If the API version is not v1, this assertion does not show the observed value. Add a message with the actual 🤖 Prompt for AI AgentsSource: Learnings |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
MEDIUM: Allow composition of builder-generated patches.
The absolute prohibition conflicts with multi-group patches. For example,
tests/storage/cbt/conftest.pycombinesHCOv1Spec.feature_gates()andHCOv1Spec.virtualization()results before passing onespecpatch.Require builders for each field group. Permit merging builder-generated payloads when one update changes multiple groups. Do not require developers to hand-write grouped paths.
🤖 Prompt for AI Agents