Skip to content

Commit

Permalink
Merge pull request #302 from codefresh-io/release-1.6-priceline
Browse files Browse the repository at this point in the history
feat: additional logs for rollout controller
  • Loading branch information
pasha-codefresh authored Feb 6, 2024
2 parents 7d1dbdc + 855b76e commit 0e79d27
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/rollouts/v1alpha1/generated.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/rollouts/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/rollouts/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rollout/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package rollout
import (
"time"

logutil "github.com/argoproj/argo-rollouts/utils/log"

log "github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
Expand Down Expand Up @@ -56,6 +58,8 @@ func (c *rolloutContext) reconcile() error {
err := c.getRolloutValidationErrors()
if err != nil {
if vErr, ok := err.(*field.Error); ok {
logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue due reconcile error")
// We want to frequently requeue rollouts with InvalidSpec errors, because the error
// condition might be timing related (e.g. the Rollout was applied before the Service).
c.enqueueRolloutAfter(c.rollout, 20*time.Second)
Expand Down
13 changes: 12 additions & 1 deletion rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ func NewController(cfg ControllerConfig) *Controller {
client: cfg.KubeClientSet,
resyncPeriod: cfg.ResyncPeriod,
enqueueAfter: func(obj interface{}, duration time.Duration) {
ro := unstructuredutil.ObjectToRollout(obj)
if ro != nil {
logCtx := logutil.WithRollout(ro)
logCtx.Info("rollout enqueue due to pod restart")
}
controllerutil.EnqueueAfter(obj, duration, cfg.RolloutWorkQueue)
},
}
Expand Down Expand Up @@ -234,6 +239,8 @@ func NewController(cfg ControllerConfig) *Controller {
controller.enqueueRollout(obj)
ro := unstructuredutil.ObjectToRollout(obj)
if ro != nil {
logCtx := logutil.WithRollout(ro)
logCtx.Info("rollout enqueue due to add event")
if cfg.Recorder != nil {
cfg.Recorder.Eventf(ro, record.EventOptions{
EventType: corev1.EventTypeNormal,
Expand All @@ -258,12 +265,16 @@ func NewController(cfg ControllerConfig) *Controller {
controller.IstioController.EnqueueDestinationRule(key)
}
}
if newRollout != nil {
logCtx := logutil.WithRollout(newRollout)
logCtx.Info("rollout enqueue due to update event")
}
controller.enqueueRollout(new)
},
DeleteFunc: func(obj interface{}) {
if ro := unstructuredutil.ObjectToRollout(obj); ro != nil {
logCtx := logutil.WithRollout(ro)
logCtx.Info("rollout deleted")
logCtx.Info("rollout enqueue due to delete event")
controller.metricsServer.Remove(ro.Namespace, ro.Name, logutil.RolloutKey)
// Rollout is deleted, queue up the referenced Service and/or DestinationRules so
// that the rollouts-pod-template-hash can be cleared from each
Expand Down
6 changes: 6 additions & 0 deletions rollout/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package rollout
import (
"time"

logutil "github.com/argoproj/argo-rollouts/utils/log"

log "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -209,6 +211,10 @@ func (c *rolloutContext) checkEnqueueRolloutDuringWait(startTime metav1.Time, du
if nextResync.After(expiredTime) && expiredTime.After(now.Time) {
timeRemaining := expiredTime.Sub(now.Time)
c.log.Infof("Enqueueing Rollout in %s seconds", timeRemaining.String())

logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue during wait")

c.enqueueRolloutAfter(c.rollout, timeRemaining)
}
}
8 changes: 8 additions & 0 deletions rollout/replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"sort"
"time"

logutil "github.com/argoproj/argo-rollouts/utils/log"

appsv1 "k8s.io/api/apps/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -150,6 +152,8 @@ func (c *rolloutContext) reconcileNewReplicaSet() (bool, error) {
c.log.Infof("RS '%s' has not reached the scaleDownTime", c.newRS.Name)
remainingTime := scaleDownAt.Sub(now.Time)
if remainingTime < c.resyncPeriod {
logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue due to scaleDownDelay")
c.enqueueRolloutAfter(c.rollout, remainingTime)
return false, nil
}
Expand Down Expand Up @@ -284,6 +288,8 @@ func (c *rolloutContext) scaleDownDelayHelper(rs *appsv1.ReplicaSet, annotatione
if err != nil {
return annotationedRSs, desiredReplicaCount, err
}
logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue due to scaleDownDelay v2")
c.enqueueRolloutAfter(c.rollout, scaleDownDelaySeconds)
}
} else if replicasetutil.HasScaleDownDeadline(rs) {
Expand All @@ -297,6 +303,8 @@ func (c *rolloutContext) scaleDownDelayHelper(rs *appsv1.ReplicaSet, annotatione
} else if remainingTime != nil {
c.log.Infof("RS '%s' has not reached the scaleDownTime", rs.Name)
if *remainingTime < c.resyncPeriod {
logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue due to scaleDownDelay v3")
c.enqueueRolloutAfter(c.rollout, *remainingTime)
}
desiredReplicaCount = rolloutReplicas
Expand Down
2 changes: 2 additions & 0 deletions rollout/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ func (c *rolloutContext) awsVerifyTargetGroups(svc *corev1.Service) error {
}
if !verifyRes.Verified {
c.recorder.Warnf(c.rollout, record.EventOptions{EventReason: conditions.TargetGroupUnverifiedReason}, conditions.TargetGroupUnverifiedRegistrationMessage, svc.Name, tgb.Spec.TargetGroupARN, verifyRes.EndpointsRegistered, verifyRes.EndpointsTotal)
logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue due to awsVerifyTargetGroups")
c.enqueueRolloutAfter(c.rollout, defaults.GetRolloutVerifyRetryInterval())
return nil
}
Expand Down
6 changes: 4 additions & 2 deletions rollout/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,13 @@ func (c *rolloutContext) requeueStuckRollout(newStatus v1alpha1.RolloutStatus) t
// Make it ratelimited so we stay on the safe side, eventually the Deployment should
// transition either to a Complete or to a TimedOut condition.
if after < time.Second {
c.log.Infof("Queueing up Rollout for a progress check now")
logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue due to stuck event")
c.enqueueRollout(c.rollout)
return time.Duration(0)
}
c.log.Infof("Queueing up rollout for a progress after %ds", int(after.Seconds()))
logCtx := logutil.WithRollout(c.rollout)
logCtx.Infof("Queueing up rollout for a progress after %ds", int(after.Seconds()))
// Add a second to avoid milliseconds skew in AddAfter.
// See https://github.com/kubernetes/kubernetes/issues/39785#issuecomment-279959133 for more info.
c.enqueueRolloutAfter(c.rollout, after+time.Second)
Expand Down
4 changes: 4 additions & 0 deletions rollout/trafficrouting.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strconv"
"strings"

logutil "github.com/argoproj/argo-rollouts/utils/log"

"github.com/argoproj/argo-rollouts/utils/annotations"

"github.com/argoproj/argo-rollouts/rollout/trafficrouting/plugin"
Expand Down Expand Up @@ -283,6 +285,8 @@ func (c *rolloutContext) reconcileTrafficRouting() error {
c.log.Infof("Desired weight (stepIdx: %s) %d verified", indexString, desiredWeight)
} else {
c.log.Infof("Desired weight (stepIdx: %s) %d not yet verified", indexString, desiredWeight)
logCtx := logutil.WithRollout(c.rollout)
logCtx.Info("rollout enqueue due to trafficrouting")
c.enqueueRolloutAfter(c.rollout, defaults.GetRolloutVerifyRetryInterval())
}
}
Expand Down

0 comments on commit 0e79d27

Please sign in to comment.