read new fields for nodepool storage#5207
Conversation
|
/hold for #5206 to get to prod |
There was a problem hiding this comment.
Pull request overview
This PR is part of the multi-step migration (following #5206) to store NodePool resources in the generic document–compatible “inline” shape (mirroring GenericDocument[api.HCPOpenShiftClusterNodePool]), and to treat CosmosMetadata.ResourceID as the canonical Cosmos identifier for nodepool persistence and reads.
Changes:
- Inline-serialize
api.HCPOpenShiftClusterNodePoolinto the NodePool Cosmos documentpropertiesand update nodepool DB conversions to read/write using that inline shape. - Plumb
CosmosMetadata.ResourceIDthrough nodepool creation/conversion paths (OCM conversion, frontend decode, tests) and update deep-copy/read-only copy behavior accordingly. - Refresh integration/unit test fixtures and comparers to reflect the new stored document shape (adds
id,name,type,systemData, etc. in expected JSON).
Reviewed changes
Copilot reviewed 53 out of 53 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test-integration/utils/databasemutationhelpers/per_resource_comparer.go | Ignore redundant internalState.internalAPI.cosmosMetadata during comparisons. |
| test-integration/frontend/informer_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| test-integration/frontend/artifacts/FrontendCRUD/NodePool/read-old-data/09-cosmosCompare-confirm-update/nodepool-basic-node-pool.json | Update expected Cosmos nodepool document shape with inline fields (id, name, type, etc.). |
| test-integration/frontend/artifacts/FrontendCRUD/NodePool/read-old-data/09-cosmosCompare-confirm-update/nodepool-02.json | Update expected Cosmos nodepool document shape with inline fields (id, name, type, etc.). |
| test-integration/frontend/artifacts/FrontendCRUD/NodePool/read-old-data/01-load-old-data/nodepool-node-pool-02.json | Update stored “old data” fixture to include inline nodepool fields. |
| test-integration/frontend/artifacts/FrontendCRUD/NodePool/read-old-data/01-load-old-data/nodepool-basic-node-pool.json | Update stored “old data” fixture to include inline nodepool fields. |
| test-integration/frontend/artifacts/FrontendCRUD/NodePool/create-current/06-cosmosCompare-confirm-content/nodepool-node-pool-02.json | Update expected Cosmos nodepool document shape for current create flow. |
| test-integration/frontend/artifacts/FrontendCRUD/NodePool/create-current/06-cosmosCompare-confirm-content/nodepool-basic-node-pool.json | Update expected Cosmos nodepool document shape for current create flow. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/read-new-data/18-cosmosCompare-confirm/nodepool-node-pool-02.json | Update expected Cosmos shape for migration “read new data” verification. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/read-new-data/18-cosmosCompare-confirm/nodepool-basic-node-pool.json | Update expected Cosmos shape for migration “read new data” verification. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/read-new-data/01-load-old-data/nodepool-node-pool-02.json | Update migration fixture to include inline nodepool fields. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/read-new-data/01-load-old-data/nodepool-basic-node-pool.json | Update migration fixture to include inline nodepool fields. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/migrate-old-data/99-cosmosCompare-confirm-migration/nodepool-node-pool-02.json | Update expected Cosmos shape for “confirm migration” step. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/migrate-old-data/99-cosmosCompare-confirm-migration/nodepool-basic-node-pool.json | Update expected Cosmos shape for “confirm migration” step. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/migrate-old-data/01-load-old-data/nodepool-node-pool-02.json | Update “migrate old data” fixture to include inline fields. |
| test-integration/frontend/artifacts/FrontendCRUD/Migration/migrate-old-data/01-load-old-data/nodepool-basic-node-pool.json | Update “migrate old data” fixture to include inline fields. |
| test-integration/frontend/artifacts/FrontendCRUD/Cluster/delete-with-pending-nodepool-operation/05-cosmosCompare-final-state/nodepool-test-nodepool.json | Update expected Cosmos nodepool doc shape during delete-with-pending-operation flow. |
| test-integration/backend/controllers/mismatches/artifacts/nodepool/remove_orphaned_nodepool_descendents/00-load-initial-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| test-integration/backend/controllers/mismatches/artifacts/nodepool/present_nodepool/99-cosmosCompare-end-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| test-integration/backend/controllers/mismatches/artifacts/nodepool/present_nodepool/00-load-initial-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| test-integration/backend/controllers/mismatches/artifacts/externalauth/remove_orphaned_externalauth_descendents/99-cosmosCompare-end-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| test-integration/backend/controllers/mismatches/artifacts/externalauth/remove_orphaned_externalauth_descendents/00-load-initial-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| test-integration/backend/controllers/mismatches/artifacts/delete_orphaned_cosmos/all_parents_exist/99-cosmosCompare-end-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| test-integration/backend/controllers/mismatches/artifacts/delete_orphaned_cosmos/all_parents_exist/00-load-initial-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| test-integration/backend/controllers/mismatches/artifacts/cluster/remove_orphaned_cluster_descendents/00-load-initial-state/nodepool-basic.json | Update backend mismatch fixtures to new inline nodepool storage shape. |
| internal/ocm/convert.go | Populate nodepool CosmosMetadata.ResourceID during CS→internal conversion. |
| internal/databasetesting/mock_dbclient_test.go | Update mock nodepool construction to include CosmosMetadata.ResourceID. |
| internal/database/types_nodepool.go | Inline api.HCPOpenShiftClusterNodePool into Cosmos NodePoolProperties for generic-doc compatibility. |
| internal/database/convert_nodepool.go | Use CosmosMetadata.ResourceID as canonical for Cosmos partitioning/indexing; read from inline shape. |
| internal/database/convert_nodepool_test.go | Adjust fuzzing/tests for new CosmosMetadata + ETag preservation path. |
| internal/database/convert_cluster_test.go | Update generic round-trip helper to clear nodepool ExistingCosmosUID from CosmosMetadata. |
| internal/conversion/readonly_nodepool.go | Preserve CosmosMetadata (resourceID/etag) across replace round-trips; remove old CosmosETag copying. |
| internal/api/zz_generated.deepcopy.go | Deep-copy CosmosMetadata for nodepools. |
| internal/api/v20251223preview/zero_value_roundtrip_test.go | Baseline nodepool now includes CosmosMetadata.ResourceID. |
| internal/api/v20251223preview/nodepools_methods.go | Convert-to-external uses ResourceID for id; ConvertToInternal also sets ResourceID. |
| internal/api/v20251223preview/nodepools_methods_test.go | Ensure nodepool tests include CosmosMetadata.ResourceID. |
| internal/api/v20251223preview/conversion_fuzz_test.go | Add fuzzer customization for api.CosmosMetadata and adjust ExistingCosmosUID handling. |
| internal/api/v20240610preview/nodepools_methods.go | Convert-to-external uses ResourceID for id; ConvertToInternal also sets ResourceID. |
| internal/api/v20240610preview/nodepools_methods_test.go | Ensure nodepool tests include CosmosMetadata.ResourceID. |
| internal/api/v20240610preview/conversion_fuzz_test.go | Add fuzzer customization for api.CosmosMetadata and adjust ExistingCosmosUID handling. |
| internal/api/types_nodepool.go | Embed CosmosMetadata into nodepool internal type; remove legacy CosmosETag shim. |
| internal/admission/admit_cluster_test.go | Ensure nodepool test objects include CosmosMetadata.ResourceID. |
| frontend/pkg/frontend/node_pool.go | Set ResourceID on create; validate stored nodepool has CosmosMetadata.ResourceID on read. |
| backend/pkg/listertesting/slice_listers_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/informers/informers_test.go | Ensure informer test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/upgradecontrollers/nodepool_version_controller_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/upgradecontrollers/control_plane_desired_version_controller_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/read_and_persist_nodepool_scoped_maestro_readonly_bundles_content_controller_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/operationcontrollers/test_helpers_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/nodepoolpropertiescontroller/node_pool_properties_sync_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/metricscontrollers/resource_metrics_controller_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/datadumpcontrollers/cs_state_dump_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
| backend/pkg/controllers/create_nodepool_scoped_maestro_readonly_bundles_controller_test.go | Ensure test nodepools include CosmosMetadata.ResourceID. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if internalNodePool.ResourceID == nil { | ||
| return nil, fmt.Errorf("stored nodepool document is missing cosmosMetadata.resourceID") | ||
| } | ||
| if !strings.EqualFold(internalNodePool.ResourceID.String(), resourceID.String()) { | ||
| return nil, fmt.Errorf("unexpected resourceID: %s", internalNodePool.ResourceID.String()) | ||
| } | ||
| internalNodePool.ID = resourceID | ||
|
|
| idString := "" | ||
| if from.ID != nil { | ||
| idString = from.ID.String() | ||
| if from.ResourceID != nil { | ||
| idString = from.ResourceID.String() | ||
| } |
| idString := "" | ||
| if from.ID != nil { | ||
| idString = from.ID.String() | ||
| if from.ResourceID != nil { | ||
| idString = from.ResourceID.String() | ||
| } |
| }, | ||
| } | ||
|
|
||
| cosmosObj.InternalState.InternalAPI.CosmosMetadata = api.CosmosMetadata{} |
There was a problem hiding this comment.
Why are we now unsetting the cosmos obj CosmosMetadata top-level attribute as well as the one in InternalState.InternalAPI?
There was a problem hiding this comment.
Is it because at some point we will stop having both the CosmosMetadata top-level attribute as well as InternalState.InternalAPI?
| }, | ||
| Location: cosmosObj.InternalState.InternalAPI.Location, | ||
| Tags: resourceDoc.Tags, | ||
| internalObj := cosmosObj.DeepCopy() |
There was a problem hiding this comment.
Is it correct/desired that calling DeepCopy of cosmosObj returns the internal api type? I understand this occurs because we now inline the internal api type on the cosmos type and because of that the DeepCopy method is promoted to the cosmos type, but it surprised me as usually when using the DeepCopy method on a type you expect the type itself being deepcopied and not just an inlined attribute of it.
| Location: cosmosObj.InternalState.InternalAPI.Location, | ||
| Tags: resourceDoc.Tags, | ||
| internalObj := cosmosObj.DeepCopy() | ||
| internalObj.ExistingCosmosUID = cosmosObj.ID |
There was a problem hiding this comment.
Do we do this because the one the inlined object that we retrieve from cosmos doesn't have that information? the same question applies to ETag and ResourceID
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/hold cancel |
|
query confirms all data is ready for this |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, stevekuznetsov The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
part of #5206, must merge after #5206 makes it prod