refactor: extract dereference/validate pipeline from reconcile_hive#707
refactor: extract dereference/validate pipeline from reconcile_hive#707adwk67 wants to merge 15 commits into
Conversation
Move external resource resolution (product image, S3 connection, metadata database, OPA config) into controller::dereference module with its own error enum. Extract config validation and merging into validate_cluster(), which produces a ValidatedHiveCluster proving all product-config validation succeeded before any Kubernetes resources are created. The validated struct owns the resolved product image and per-role/ per-rolegroup merged configs. Existing build functions are unchanged and receive their parameters from the validated structs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Jenkins: 🟢 (one failure on NS teardown) https://testing.stackable.tech/view/02%20Operator%20Tests%20(custom)/job/hive-operator-it-custom/52/ |
Rename FailedToResolveResourceConfig to FailedToResolveConfig and fix OPA error display string to match the convention used across all three dereference/validate extraction PRs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Image resolution is a pure computation, not an I/O dereference, so it belongs in validate_cluster alongside the other config validation. This aligns with the pattern used by the trino and airflow operators. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
The smoke test of the opensearch-operator has an assertion that covers all generated resources (https://github.com/stackabletech/opensearch-operator/blob/26.3.0/tests/templates/kuttl/smoke/10-assert.yaml.j2). The other integration tests only add assertions for the resources specific to the test case (https://github.com/stackabletech/opensearch-operator/blob/26.3.0/tests/templates/kuttl/security-config/11-assert.yaml#L29-L41). That leads to relatively high test coverage.
The pull requests for stackabletech/issues#850 should only perform internal changes. If we also add an assertion to the smoke test with the resources produced before this change, then we could be more confident that no unwanted changes are introduced.
There was a problem hiding this comment.
Added here: fe53e9c. Tested across most smoke tests in main and in this branch to check there are no discrepancies before/after this PR.
Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>
…move derives where they do not exist on the upstream type
…pendency for subsequent steps
Summary
Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrdonHiveRoleso it can be used as aBTreeMapkey and in validated structscontroller::dereferencemodule with its own Snafu error enumvalidate_cluster(), producing aValidatedHiveClusterstruct that proves all validation succeeded before any Kubernetes resources are createdValidatedHiveClusterowns the resolved product image and per-role/per-rolegroup merged configs; existing build functions are unchanged and receive parameters from the validated structsReviewer notes
dereference()andvalidate_cluster()contain no new logic — they are pure extractions of code that was previously inline inreconcile_hive()ValidatedHiveClusterstruct intentionally has fewer fields than a full ownership model would (noname/namespace/uid/metadatavalidated types). This is a "construct but decompose" fail-fast gate: built early in reconcile to prove validation passes, then its fields feed the existing unchanged build functionscontroller/directory coexists withcontroller.rs— Rust treatscontroller.rsas the module root and looks for submodules incontroller/. Currently justdereference, withvalidateand further stages to follow in later PRsDereferencewrapper variant in the controller'sErrorenum replaces 3 individual error variants (ResolveProductImage,InvalidOpaConfig,InvalidMetadataDatabaseConnection) that moved into the new module's own error enum.ConfigureS3ConnectionandObjectHasNoNamespaceremain in the controller because they are still used by build functionsTest plan
🤖 Generated with Claude Code