Skip to content

fix(gc): replace manual finalizers with native k8s cascading deletion#125

Merged
fernando-villalba merged 1 commit intomainfrom
fix/native-gc-migration-and-coverage
Jan 19, 2026
Merged

fix(gc): replace manual finalizers with native k8s cascading deletion#125
fernando-villalba merged 1 commit intomainfrom
fix/native-gc-migration-and-coverage

Conversation

@fernando-villalba
Copy link
Collaborator

The previous implementation relied on custom finalizers for garbage collection, which created complex dependency chains.

  • Removed manual finalizer logic from MultigresCluster and TableGroup controllers.
  • Updated ChildResourceValidator to exempt the generic-garbage-collector service account.
  • Removed obsolete integration tests checking for finalizer presence.
  • Added comprehensive failure case tests for sub-reconcilers and status updates.

This reduces operator complexity, prevents "stuck" deleting resources, and achieves 100% test coverage for the cluster handler.

The previous implementation relied on custom finalizers for garbage collection, which created complex dependency chains and often blocked resource deletion if the operator was down.

- Removed manual finalizer logic from MultigresCluster and TableGroup controllers.
- Updated ChildResourceValidator to exempt the generic-garbage-collector service account.
- Removed obsolete integration tests checking for finalizer presence.
- Added comprehensive failure case tests for sub-reconcilers and status updates.

This reduces operator complexity, prevents "stuck" deleting resources, and achieves 100% test coverage for the cluster handler.
@github-actions
Copy link

🔬 Go Test Coverage Report

Summary

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

Status

✅ PASS

Detail

Show New Coverage
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/builders_cell.go:14:			BuildCell				100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/builders_global.go:17:			BuildGlobalTopoServer			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/builders_global.go:57:			BuildMultiAdminDeployment		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/builders_tablegroup.go:14:		BuildTableGroup				100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:37:	Reconcile				100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/multigrescluster_controller.go:89:	SetupWithManager			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/reconcile_cells.go:13:			reconcileCells				100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/reconcile_databases.go:14:		reconcileDatabases			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/reconcile_global.go:14:			reconcileGlobalComponents		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/reconcile_global.go:29:			reconcileGlobalTopoServer		100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/reconcile_global.go:74:			reconcileMultiAdmin			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/reconcile_global.go:114:			getGlobalTopoRef			100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/multigrescluster/status.go:14:				updateStatus				100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/tablegroup/builders.go:14:					BuildShard				100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/tablegroup/tablegroup_controller.go:34:			Reconcile				100.0%
github.com/numtide/multigres-operator/pkg/cluster-handler/controller/tablegroup/tablegroup_controller.go:156:			SetupWithManager			100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:17:								IgnoreMetaRuntimeFields			100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:55:								IgnoreServiceRuntimeFields		100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:75:								IgnoreStatefulSetRuntimeFields		100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:97:								IgnoreDeploymentRuntimeFields		100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:116:								IgnorePodSpecDefaults			100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:138:								IgnorePodSpecDefaultsExceptPullPolicy	100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:159:								IgnoreStatefulSetSpecDefaults		100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:171:								IgnoreDeploymentSpecDefaults		100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:183:								filterByFieldName			100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:199:								IgnoreObjectMetaCompletely		100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:207:								IgnoreStatus				100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:213:								CompareOptions				100.0%
github.com/numtide/multigres-operator/pkg/testutil/compare.go:222:								CompareSpecOnly				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:29:								WithKubeconfig				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:36:								WithCRDPaths				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:57:								AddUser					100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:62:								getKubeconfigFromUserAdder		100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:87:								SetUpEnvtest				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:148:								SetUpClient				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:175:								SetUpManager				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:206:								StartManager				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:216:								startManager				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:254:								SetUpEnvtestManager			100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:270:								createEnvtestEnvironment		100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:285:								startEnvtest				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:300:								cleanEnvtest				100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:317:								createEnvtestDir			100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:331:								writeKubeconfigFile			100.0%
github.com/numtide/multigres-operator/pkg/testutil/envtest.go:341:								generateKubeconfigFile			100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:51:								NewFakeClientWithFailures		100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:61:								Get					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:75:								List					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:88:								Create					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:101:								Update					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:114:								Patch					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:128:								Delete					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:141:								DeleteAllOf				100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:154:								Status					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:166:								Update					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:179:								Patch					100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:196:								FailOnObjectName			100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:210:								FailOnKeyName				100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:220:								FailOnNamespacedKeyName			100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:230:								FailOnNamespace				100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:244:								AlwaysFail				100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:252:								FailKeyAfterNCalls			100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:265:								FailObjAfterNCalls			100.0%
github.com/numtide/multigres-operator/pkg/testutil/fake_client.go:278:								FailObjListAfterNCalls			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:38:							Error					100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:88:							WithExtraResource			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:96:							WithTimeout				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:104:							WithCmpOpts				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:112:							NewResourceWatcher			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:150:							SetTimeout				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:156:							ResetTimeout				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:163:							SetCmpOpts				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:169:							ResetCmpOpts				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:179:							Events					100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:192:							EventCh					100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:202:							ForKind					100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:222:							ForName					100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:238:							Count					100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:247:							subscribe				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:261:							unsubscribe				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher.go:282:							extractKind				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_cache.go:16:						findLatestEvent				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_cache.go:34:						findLatestEventFor			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_cache.go:57:						checkLatestEventMatches			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_deletion.go:22:						Obj					100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_deletion.go:51:						WaitForDeletion				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_deletion.go:70:						waitForSingleDeletion			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_listener.go:19:						collectEvents				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_listener.go:55:						sendEvent				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_match.go:46:						WaitForMatch				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_match.go:88:						waitForSingleMatch			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_match.go:182:						waitForEvent				100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_match.go:217:						WaitForEventType			100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_match.go:265:						addEventHandlerToInformer		100.0%
github.com/numtide/multigres-operator/pkg/testutil/resource_watcher_match.go:289:						watchResource				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/generator.go:46:								GenerateCA				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/generator.go:102:							GenerateServerCert			100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/generator.go:163:							ParseCA					100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:54:								NewManager				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:63:								Bootstrap				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:74:								Start					100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:101:								reconcilePKI				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:119:								ensureCA				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:177:								ensureServerCert			100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:265:								waitForKubelet				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:293:								setOwner				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:308:								findOperatorDeployment			100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:338:								patchWebhooks				100.0%
github.com/numtide/multigres-operator/pkg/webhook/cert/manager.go:374:								recorderEvent				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/defaulter.go:24:							NewMultigresClusterDefaulter		100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/defaulter.go:31:							Default					100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:31:							NewMultigresClusterValidator		100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:35:							ValidateCreate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:42:							ValidateUpdate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:49:							ValidateDelete				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:56:							validate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:73:							validateTemplatesExist			100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:134:							NewTemplateValidator			100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:138:							ValidateCreate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:145:							ValidateUpdate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:152:							ValidateDelete				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:181:							isTemplateInUse				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:235:							NewChildResourceValidator		100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:241:							ValidateCreate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:248:							ValidateUpdate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:255:							ValidateDelete				100.0%
github.com/numtide/multigres-operator/pkg/webhook/handlers/validator.go:262:							validate				100.0%
github.com/numtide/multigres-operator/pkg/webhook/setup.go:24:									Setup					100.0%
total:																(statements)				100.0%

@fernando-villalba fernando-villalba merged commit 5de2bf6 into main Jan 19, 2026
3 checks passed
@fernando-villalba fernando-villalba deleted the fix/native-gc-migration-and-coverage branch January 19, 2026 18:08
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.

1 participant