Skip to content

Commit

Permalink
improve some log information
Browse files Browse the repository at this point in the history
Signed-off-by: yunbo <[email protected]>
  • Loading branch information
Funinu committed Dec 23, 2024
1 parent 6885920 commit bfad7f2
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
2 changes: 2 additions & 0 deletions api/v1beta1/rollout_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ const (
FinalisingStepReleaseWorkloadControl FinalisingStepType = "ReleaseWorkloadControl"
// All needed work done
FinalisingStepTypeEnd FinalisingStepType = "END"
// Only for debugging use
FinalisingStepWaitEndless FinalisingStepType = "WaitEndless"
)

// +genclient
Expand Down
2 changes: 0 additions & 2 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ rules:
resources:
- horizontalpodautoscalers
verbs:
- create
- delete
- get
- list
- patch
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/batchrelease/batchrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions pkg/controller/rollout/rollout_bluegreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
}
}
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/rollout/rollout_canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bfad7f2

Please sign in to comment.