Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improved prompt message for configuration reconcile #5323

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions controllers/apps/configuration/configuration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +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 @@ -164,8 +162,6 @@ func (r *ConfigurationReconciler) runTasks(taskCtx TaskContext, tasks []Task) (e
for _, task := range tasks {
task.Status.UpdateRevision = revision
if err := task.Do(taskCtx.fetcher, synthesizedComp, revision); err != nil {
task.Status.Phase = appsv1alpha1.CMergeFailedPhase
task.Status.Message = cfgutil.ToPointer(err.Error())
errs = append(errs, err)
continue
}
Expand Down Expand Up @@ -194,22 +190,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
3 changes: 3 additions & 0 deletions controllers/apps/configuration/reconcile_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

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"
"github.com/apecloud/kubeblocks/internal/controller/configuration"
intctrlutil "github.com/apecloud/kubeblocks/internal/controllerutil"
Expand Down Expand Up @@ -95,8 +96,10 @@ func syncImpl(fetcher *Task,
Sync().
Complete()
if err != nil {
status.Message = cfgutil.ToPointer(err.Error())
status.Phase = appsv1alpha1.CMergeFailedPhase
} else {
status.Message = nil
status.Phase = appsv1alpha1.CMergedPhase
}
return
Expand Down