Skip to content

feat(cluster-handler): integrate resolver and enforce v1alpha1 compliance#105

Merged
fernando-villalba merged 2 commits intomainfrom
fix/cluster-handler-images-and-resolver
Jan 5, 2026
Merged

feat(cluster-handler): integrate resolver and enforce v1alpha1 compliance#105
fernando-villalba merged 2 commits intomainfrom
fix/cluster-handler-images-and-resolver

Conversation

@fernando-villalba
Copy link
Collaborator

MUST merge PR #104 first!

This commit refactors the MultigresCluster controller to fully integrate the
new granular resolver logic and ensure strict compliance with the v1alpha1 API.

Changes:

  • Integrated resolver package to handle the 4-level override chain for
    GlobalTopo, MultiAdmin, Cells, and Shards directly in the reconciler.
  • Added in-memory execution of PopulateClusterDefaults at the start of
    reconciliation. This guarantees the "System Catalog" (postgres/default/shard-0)
    is injected even if the mutating webhook is disabled or fails.
  • Updated child resource creation (Cells, TableGroups) to use the new nested
    Images struct, ensuring ImagePullPolicy and ImagePullSecrets are
    correctly propagated.
  • Updated integration tests to respect strict v1alpha1 validation rules
    (Database must be "postgres", TableGroup must be "default").

@github-actions

This comment has been minimized.

@rytswd
Copy link
Member

rytswd commented Jan 5, 2026

If there is a merge order requirements, please update the merge target branch to be feat/granular-resolver-logic. That way, when the target branch gets merged to main, this PR automatically gets updated to target main branch as the target branch.

@fernando-villalba fernando-villalba force-pushed the fix/cluster-handler-images-and-resolver branch from 1efaacf to ab1081b Compare January 5, 2026 06:12
@fernando-villalba fernando-villalba changed the base branch from main to feat/granular-resolver-logic January 5, 2026 06:15
@github-actions

This comment has been minimized.

@fernando-villalba
Copy link
Collaborator Author

If there is a merge order requirements, please update the merge target branch to be feat/granular-resolver-logic. That way, when the target branch gets merged to main, this PR automatically gets updated to target main branch as the target branch.

Excellent suggestion - done!

@github-actions

This comment has been minimized.

…ance

This commit refactors the MultigresCluster controller to fully integrate the
new granular resolver logic and ensure strict compliance with the v1alpha1 API.

Changes:
- Integrated `resolver` package to handle the 4-level override chain for
  GlobalTopo, MultiAdmin, Cells, and Shards directly in the reconciler.
- Added in-memory execution of `PopulateClusterDefaults` at the start of
  reconciliation. This guarantees the "System Catalog" (postgres/default/shard-0)
  is injected even if the mutating webhook is disabled or fails.
- Updated child resource creation (Cells, TableGroups) to use the new nested
  `Images` struct, ensuring `ImagePullPolicy` and `ImagePullSecrets` are
  correctly propagated.
- Updated integration tests to respect strict v1alpha1 validation rules
  (Database must be "postgres", TableGroup must be "default").
…troller

This commit introduces a comprehensive unit test suite for the MultigresCluster
controller to close the coverage gap left by integration tests, bringing the
package to 100% statement coverage.

Changes:
- Added `pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller_test.go`:
  - Implements a test suite using a fake client with interceptors to simulate API errors.
  - Covers critical error paths and edge cases, including:
    - Connection errors on Get/List operations.
    - Status update failures.
    - Pruning of orphaned child resources (Cells, TableGroups).
    - Implicit cell sorting and deduplication logic during Shard resolution.
    - Validation of "clean exit" on resource deletion.
- Updated `pkg/cluster-handler/controller/multigrescluster/doc.go`:
  - Clarified that the Global TopoServer is only managed in "Managed" (Etcd) mode.
  - Documented the explicit in-memory defaulting step (`PopulateClusterDefaults`) used for robustness.
@fernando-villalba fernando-villalba force-pushed the fix/cluster-handler-images-and-resolver branch from 0364db2 to 32486b2 Compare January 5, 2026 06:56
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

🔬 Go Test Coverage Report

Summary

Coverage Type Result
Threshold 0%
Previous Test Coverage Unknown%
New Test Coverage 100.0%

Status

✅ PASS

Detail

Show New Coverage
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:44:	Reconcile			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:100:	handleDelete			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:116:	checkChildrenDeleted		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:147:	reconcileGlobalComponents	100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:161:	reconcileGlobalTopoServer	100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:198:	reconcileMultiAdmin		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:250:	reconcileCells			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:330:	reconcileDatabases		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:444:	getGlobalTopoRef		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:469:	updateStatus			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:549:	SetupWithManager		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/tablegroup/tablegroup_controller.go:32:			Reconcile			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/tablegroup/tablegroup_controller.go:152:			SetupWithManager		100.0%
github.com/numtide/multigres-operator/pkg/resolver/cell.go:16:									ResolveCell			100.0%
github.com/numtide/multigres-operator/pkg/resolver/cell.go:47:									ResolveCellTemplate		100.0%
github.com/numtide/multigres-operator/pkg/resolver/cell.go:78:									mergeCellConfig			100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:17:								PopulateClusterDefaults		100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:91:								ResolveGlobalTopo		100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:131:								ResolveMultiAdmin		100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:162:								ResolveCoreTemplate		100.0%
github.com/numtide/multigres-operator/pkg/resolver/defaults.go:57:								DefaultResourcesAdmin		100.0%
github.com/numtide/multigres-operator/pkg/resolver/defaults.go:71:								DefaultResourcesEtcd		100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:22:								NewResolver			100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:38:								mergeStatelessSpec		100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:73:								isResourcesZero			100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:82:								defaultEtcdSpec			100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:101:								defaultStatelessSpec		100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:16:									ResolveShard			100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:42:									ResolveShardTemplate		100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:73:									mergeShardConfig		100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:117:								mergeMultiOrchSpec		100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:127:								mergePoolSpec			100.0%
total:																(statements)			100.0%

Base automatically changed from feat/granular-resolver-logic to main January 5, 2026 14:47
@fernando-villalba fernando-villalba merged commit e2b8632 into main Jan 5, 2026
3 checks passed
@fernando-villalba fernando-villalba deleted the fix/cluster-handler-images-and-resolver branch January 5, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants