refactor: 按 phase handler 组织状态机
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user