From bfad7f22a4dc52868f28b968551b758307481139 Mon Sep 17 00:00:00 2001 From: yunbo Date: Mon, 23 Dec 2024 19:39:25 +0800 Subject: [PATCH] improve some log information Signed-off-by: yunbo --- api/v1beta1/rollout_types.go | 2 ++ config/rbac/role.yaml | 2 -- pkg/controller/batchrelease/batchrelease_controller.go | 2 +- .../control/bluegreenstyle/cloneset/control.go | 7 +++---- .../control/bluegreenstyle/deployment/control.go | 4 ++-- pkg/controller/rollout/rollout_bluegreen.go | 7 ++++--- pkg/controller/rollout/rollout_canary.go | 1 - 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/api/v1beta1/rollout_types.go b/api/v1beta1/rollout_types.go index 47051987..5b1ded6f 100644 --- a/api/v1beta1/rollout_types.go +++ b/api/v1beta1/rollout_types.go @@ -579,6 +579,8 @@ const ( FinalisingStepReleaseWorkloadControl FinalisingStepType = "ReleaseWorkloadControl" // All needed work done FinalisingStepTypeEnd FinalisingStepType = "END" + // Only for debugging use + FinalisingStepWaitEndless FinalisingStepType = "WaitEndless" ) // +genclient diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index dbe28b37..343d31ca 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -166,8 +166,6 @@ rules: resources: - horizontalpodautoscalers verbs: - - create - - delete - get - list - patch diff --git a/pkg/controller/batchrelease/batchrelease_controller.go b/pkg/controller/batchrelease/batchrelease_controller.go index 1cfcdbbb..709c2707 100644 --- a/pkg/controller/batchrelease/batchrelease_controller.go +++ b/pkg/controller/batchrelease/batchrelease_controller.go @@ -148,7 +148,7 @@ type BatchReleaseReconciler struct { // +kubebuilder:rbac:groups=apps.kruise.io,resources=statefulsets/status,verbs=get;update;patch // +kubebuilder:rbac:groups=apps.kruise.io,resources=daemonsets,verbs=get;list;watch;update;patch // +kubebuilder:rbac:groups=apps.kruise.io,resources=daemonsets/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;update;patch // Reconcile reads that state of the cluster for a Rollout object and makes changes based on the state read // and what is in the Rollout.Spec diff --git a/pkg/controller/batchrelease/control/bluegreenstyle/cloneset/control.go b/pkg/controller/batchrelease/control/bluegreenstyle/cloneset/control.go index 1dadad0a..5d6ae2d6 100644 --- a/pkg/controller/batchrelease/control/bluegreenstyle/cloneset/control.go +++ b/pkg/controller/batchrelease/control/bluegreenstyle/cloneset/control.go @@ -80,7 +80,6 @@ func (rc *realController) ListOwnedPods() ([]*corev1.Pod, error) { } func (rc *realController) Initialize(release *v1beta1.BatchRelease) error { - klog.Info("Initialize cloneset controller") if rc.object == nil || control.IsControlledByBatchRelease(release, rc.object) { return nil } @@ -120,10 +119,10 @@ func (rc *realController) UpgradeBatch(ctx *batchcontext.BatchContext) error { desired, _ := intstr.GetScaledValueFromIntOrPercent(&ctx.DesiredSurge, int(ctx.Replicas), true) current, _ := intstr.GetScaledValueFromIntOrPercent(&ctx.CurrentSurge, int(ctx.Replicas), true) if current >= desired { - klog.Infof("No need to upgrade batch for cloneset %v: because current %d >= desired %d", klog.KObj(rc.object), current, desired) + klog.InfoS("No need to upgrade batch, because current >= desired", "cloneset", klog.KObj(rc.object), "current", current, "desired", desired) return nil } else { - klog.Infof("Will update batch for cloneset %v: current %d < desired %d", klog.KObj(rc.object), current, desired) + klog.InfoS("Will update batch for cloneset, because current < desired", "cloneset", klog.KObj(rc.object), "current", current, "desired", desired) } patchData := patch.NewClonesetPatch() // avoid interference from partition @@ -168,7 +167,7 @@ func (rc *realController) Finalize(release *v1beta1.BatchRelease) error { return errors.NewRetryError(fmt.Errorf("cloneset %v finalize not done, readyReplicas %d != updatedReadyReplicas %d, current policy %s", klog.KObj(rc.object), rc.object.Status.ReadyReplicas, rc.object.Status.UpdatedReadyReplicas, release.Spec.ReleasePlan.FinalizingPolicy)) } - klog.InfoS("Finalize: cloneset bluegreen release: all pods updated and ready") + klog.InfoS("Finalize: cloneset bluegreen release: all pods updated and ready", "cloneset", klog.KObj(rc.object)) // restore the hpa return hpa.RestoreHPA(rc.client, rc.object) diff --git a/pkg/controller/batchrelease/control/bluegreenstyle/deployment/control.go b/pkg/controller/batchrelease/control/bluegreenstyle/deployment/control.go index 9e073b3b..9c693725 100644 --- a/pkg/controller/batchrelease/control/bluegreenstyle/deployment/control.go +++ b/pkg/controller/batchrelease/control/bluegreenstyle/deployment/control.go @@ -171,14 +171,14 @@ func (rc *realController) Finalize(release *v1beta1.BatchRelease) error { if err := rc.client.Patch(context.TODO(), d, patchData); err != nil { return err } - klog.InfoS("Finalize: deployment bluegreen release: wait all pods updated and ready", "cloneset", klog.KObj(rc.object)) + klog.InfoS("Finalize: deployment bluegreen release: wait all pods updated and ready", "Deployment", klog.KObj(rc.object)) } // wait all pods updated and ready if err := waitAllUpdatedAndReady(d.(*apps.Deployment)); err != nil { return errors.NewRetryError(err) } - klog.InfoS("Finalize: deployment is ready to resume, restore the original setting", "deployment", klog.KObj(rc.object)) + klog.InfoS("Finalize: All pods updated and ready, then restore hpa", "Deployment", klog.KObj(rc.object)) // restore hpa return hpa.RestoreHPA(rc.client, rc.object) diff --git a/pkg/controller/rollout/rollout_bluegreen.go b/pkg/controller/rollout/rollout_bluegreen.go index 7cfeaa82..4ececbe5 100644 --- a/pkg/controller/rollout/rollout_bluegreen.go +++ b/pkg/controller/rollout/rollout_bluegreen.go @@ -62,7 +62,6 @@ func (m *blueGreenReleaseManager) runCanary(c *RolloutContext) error { } if m.doCanaryJump(c) { - klog.Infof("rollout(%s/%s) canary step jumped", c.Rollout.Namespace, c.Rollout.Name) return nil } // When the first batch is trafficRouting rolling and the next steps are rolling release, @@ -323,6 +322,9 @@ func (m *blueGreenReleaseManager) doCanaryFinalising(c *RolloutContext) (bool, e // route all traffic to new version case v1beta1.FinalisingStepRouteTrafficToNew: retry, err = m.trafficRoutingManager.RouteAllTrafficToNewVersion(tr) + // dangerous, wait endlessly, only for debugging use + case v1beta1.FinalisingStepWaitEndless: + retry, err = true, fmt.Errorf("only for debugging, just wait endlessly") default: nextStep = nextBlueGreenTask(c.FinalizeReason, "") klog.Warningf("unexpected finalising step, current step(%s), start from the first step(%s)", blueGreenStatus.FinalisingStep, nextStep) @@ -453,10 +455,9 @@ func nextBlueGreenTask(reason string, currentTask v1beta1.FinalisingStepType) v1 default: // others: disabled/deleting rollout taskSequence = []v1beta1.FinalisingStepType{ v1beta1.FinalisingStepRestoreStableService, - v1beta1.FinalisingStepResumeWorkload, // scale up new, scale down old v1beta1.FinalisingStepRouteTrafficToStable, - v1beta1.FinalisingStepRemoveCanaryService, + v1beta1.FinalisingStepResumeWorkload, // scale up new, scale down old v1beta1.FinalisingStepReleaseWorkloadControl, } } diff --git a/pkg/controller/rollout/rollout_canary.go b/pkg/controller/rollout/rollout_canary.go index cc64c0ef..6bdc1d6c 100644 --- a/pkg/controller/rollout/rollout_canary.go +++ b/pkg/controller/rollout/rollout_canary.go @@ -71,7 +71,6 @@ func (m *canaryReleaseManager) runCanary(c *RolloutContext) error { } if m.doCanaryJump(c) { - klog.Infof("rollout(%s/%s) canary step jumped", c.Rollout.Namespace, c.Rollout.Name) return nil } // When the first batch is trafficRouting rolling and the next steps are rolling release,