Draft: HYPERFLEET-732 - feat: add RFC4122 UUID identifiers to Cluster and NodePool resources#92
Draft: HYPERFLEET-732 - feat: add RFC4122 UUID identifiers to Cluster and NodePool resources#9286254860 wants to merge 2 commits intoopenshift-hyperfleet:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
WalkthroughThis PR introduces a dual-identifier system: a persistent, immutable RFC4122 Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant API as API Handler
participant Model as Cluster/NodePool BeforeCreate
participant DB as Database
participant Presenter as API Presenter
Client->>API: POST /clusters or /node_pools
API->>Model: Construct resource struct
Model->>Model: Generate ID (KSUID) if empty
Model->>Model: Generate UUID (RFC4122) if empty
API->>DB: INSERT resource
DB->>DB: Enforce unique indexes (id, uuid)
DB-->>API: Return persisted row
API->>Presenter: Build response
Presenter->>Presenter: Parse string UUID -> openapi UUID type
Presenter-->>API: Return formatted response (id, uuid)
API-->>Client: HTTP 201 + response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pkg/api/cluster_types_test.go (1)
245-271: Test function name is slightly misleading.The test
TestCluster_BeforeCreate_UUIDImmutableactually verifies that UUID is regenerated on repeatedBeforeCreatecalls (lines 263-264). The name suggests immutability, but the test confirms the opposite behavior. Consider renaming to something likeTestCluster_BeforeCreate_UUIDRegeneratedOnRepeatedCallfor clarity.The test logic itself is correct and the inline comment explains the expected behavior well.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/api/cluster_types_test.go` around lines 245 - 271, Rename the misleading test function TestCluster_BeforeCreate_UUIDImmutable to reflect its actual behavior (e.g., TestCluster_BeforeCreate_UUIDRegeneratedOnRepeatedCall); update the function declaration and any references or test-suite calls to that symbol so the test name matches that it verifies UUID/ID are regenerated on a second BeforeCreate invocation (Cluster.BeforeCreate).pkg/api/node_pool_types_test.go (1)
286-312: Misleading test name: test verifies regeneration, not immutability.The test
TestNodePool_BeforeCreate_UUIDImmutableactually tests that UUID is regenerated on eachBeforeCreatecall. The name suggests immutability but the assertions verify the opposite. Consider renaming toTestNodePool_BeforeCreate_UUIDRegenerationto match the actual behavior being tested.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/api/node_pool_types_test.go` around lines 286 - 312, Rename the misnamed test function TestNodePool_BeforeCreate_UUIDImmutable to reflect its actual assertion of regeneration (suggested name: TestNodePool_BeforeCreate_UUIDRegeneration); update the test function declaration and any references to it so the function name and any comments match that it verifies UUID and ID are regenerated on successive BeforeCreate calls (referencing the NodePool struct and its BeforeCreate method to locate the test).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/api/cluster_types_test.go`:
- Around line 245-271: Rename the misleading test function
TestCluster_BeforeCreate_UUIDImmutable to reflect its actual behavior (e.g.,
TestCluster_BeforeCreate_UUIDRegeneratedOnRepeatedCall); update the function
declaration and any references or test-suite calls to that symbol so the test
name matches that it verifies UUID/ID are regenerated on a second BeforeCreate
invocation (Cluster.BeforeCreate).
In `@pkg/api/node_pool_types_test.go`:
- Around line 286-312: Rename the misnamed test function
TestNodePool_BeforeCreate_UUIDImmutable to reflect its actual assertion of
regeneration (suggested name: TestNodePool_BeforeCreate_UUIDRegeneration);
update the test function declaration and any references to it so the function
name and any comments match that it verifies UUID and ID are regenerated on
successive BeforeCreate calls (referencing the NodePool struct and its
BeforeCreate method to locate the test).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0619b736-1b59-470f-8a2d-083b2d534de1
📒 Files selected for processing (13)
docs/api-operator-guide.mdopenapi/openapi.yamlpkg/api/cluster_types.gopkg/api/cluster_types_test.gopkg/api/node_pool_types.gopkg/api/node_pool_types_test.gopkg/api/presenters/cluster.gopkg/api/presenters/node_pool.gopkg/db/migrations/202603230001_add_cluster_uuid.gopkg/db/migrations/202603230002_add_nodepool_uuid.gopkg/db/migrations/migration_structs.gotest/integration/clusters_test.gotest/integration/node_pools_test.go
080aee5 to
390e1c8
Compare
|
/hold This method might be replaced by the method that change the existing ID field to RFC4122. |
Summary:
Add RFC4122 UUID field alongside existing KSUID identifiers to support platform integrations requiring standard UUID format (e.g., Hypershift spec.clusterID).
Changes:
Summary by CodeRabbit
New Features
Documentation
Chores
Tests