Skip to content

Commit

Permalink
chore: improved prompt message for configuration reconcile (#5224)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Sep 21, 2023
1 parent 865e47e commit 4ad6e4b
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions controllers/apps/configuration/configuration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package configuration

import (
"context"
"fmt"
"strconv"
"time"

Expand All @@ -33,7 +34,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"

appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
"github.com/apecloud/kubeblocks/internal/configuration/core"
cfgutil "github.com/apecloud/kubeblocks/internal/configuration/util"
"github.com/apecloud/kubeblocks/internal/controller/component"
intctrlutil "github.com/apecloud/kubeblocks/internal/controllerutil"
Expand Down Expand Up @@ -176,22 +176,19 @@ func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error {

func fromItemStatus(ctx intctrlutil.RequestCtx, status *appsv1alpha1.ConfigurationStatus, item appsv1alpha1.ConfigurationItemDetail) *appsv1alpha1.ConfigurationItemDetailStatus {
if item.ConfigSpec == nil {
ctx.Log.WithName(item.Name).Error(core.MakeError("configSpec phase is not ready and pass: %v", item), "")
ctx.Log.V(1).WithName(item.Name).Info(fmt.Sprintf("configuration is creating and pass: %s", item.Name))
return nil
}
for i := range status.ConfigurationItemStatus {
itemStatus := &status.ConfigurationItemStatus[i]
switch {
case itemStatus.Name != item.Name:
case isReconcileStatus(itemStatus.Phase):
return itemStatus
default:
ctx.Log.WithName(item.Name).Error(core.MakeError("configSpec phase is not ready and pass: %v", itemStatus), "")
return nil
}
itemStatus := status.GetItemStatus(item.Name)
if itemStatus == nil || itemStatus.Phase == "" {
ctx.Log.V(1).WithName(item.Name).Info(fmt.Sprintf("configuration cr is creating and pass: %v", item))
return nil
}
if !isReconcileStatus(itemStatus.Phase) {
ctx.Log.V(1).WithName(item.Name).Info(fmt.Sprintf("configuration cr is creating or deleting and pass: %v", itemStatus))
return nil
}
ctx.Log.WithName(item.Name).Error(core.MakeError("configSpec phase is not ready and pass: %v", item), "")
return nil
return itemStatus
}

func isReconcileStatus(phase appsv1alpha1.ConfigurationPhase) bool {
Expand Down

0 comments on commit 4ad6e4b

Please sign in to comment.