refactor: 按 phase handler 组织状态机
E2E Tests / Run on Ubuntu (pull_request) Failing after 48s
Tests / Run on Ubuntu (pull_request) Successful in 4m1s
Lint / Run on Ubuntu (pull_request) Successful in 4m44s

This commit is contained in:
2026-09-10 08:58:41 +00:00
parent ed564d411f
commit 1c0be43805
5 changed files with 265 additions and 13 deletions
@@ -56,12 +56,10 @@ func (r *PostgreSQLTenantReconciler) Reconcile(ctx context.Context, req ctrl.Req
}
before := tenant.DeepCopy()
if !tenant.DeletionTimestamp.IsZero() {
tenant.Status.Phase = databasev1alpha1.PostgreSQLTenantPhaseDeleting
setReconcilingCondition(&tenant.Status.Conditions, tenant.Generation, "tenant deletion is reconciling")
} else if tenant.Status.Phase == "" {
tenant.Status.Phase = databasev1alpha1.PostgreSQLTenantPhasePending
setReconcilingCondition(&tenant.Status.Conditions, tenant.Generation, "tenant is waiting for its instance")
phaseResult := newTenantStateMachine().reconcile(tenant)
tenant.Status.Phase = phaseResult.phase
if phaseResult.reconcilingMessage != "" {
setReconcilingCondition(&tenant.Status.Conditions, tenant.Generation, phaseResult.reconcilingMessage)
}
if !reflect.DeepEqual(before.Status, tenant.Status) {