From 2675841bfb579495b7d062c359350ef75ee28dc8 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 12 Jan 2024 21:58:22 +0200 Subject: [PATCH 1/8] feat: release-1.6 logs for priceline --- controller/controller.go | 2 +- rollout/controller.go | 8 +++++++- rollout/sync.go | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/controller/controller.go b/controller/controller.go index afe4bc769b..4a83e7341a 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -85,7 +85,7 @@ const ( DefaultIngressThreads = 10 // DefaultLeaderElect is the default true leader election should be enabled - DefaultLeaderElect = true + DefaultLeaderElect = false // DefaultLeaderElectionLeaseDuration is the default time in seconds that non-leader candidates will wait to force acquire leadership DefaultLeaderElectionLeaseDuration = 15 * time.Second diff --git a/rollout/controller.go b/rollout/controller.go index 75601661ca..95dbe87437 100644 --- a/rollout/controller.go +++ b/rollout/controller.go @@ -234,6 +234,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, @@ -258,12 +260,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 diff --git a/rollout/sync.go b/rollout/sync.go index 2baeac1698..100f318cf6 100644 --- a/rollout/sync.go +++ b/rollout/sync.go @@ -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.Info("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) From 82d80382bd402454d2b211dfe64ecd543e58d22f Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 12 Jan 2024 22:06:36 +0200 Subject: [PATCH 2/8] feat: release-1.6 logs for priceline --- rollout/sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollout/sync.go b/rollout/sync.go index 100f318cf6..5d07958dc1 100644 --- a/rollout/sync.go +++ b/rollout/sync.go @@ -834,7 +834,7 @@ func (c *rolloutContext) requeueStuckRollout(newStatus v1alpha1.RolloutStatus) t return time.Duration(0) } logCtx := logutil.WithRollout(c.rollout) - logCtx.Info("Queueing up rollout for a progress after %ds", int(after.Seconds())) + 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) From 511f4342b719a7759af9adba2660b4c091b46182 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 12 Jan 2024 22:29:32 +0200 Subject: [PATCH 3/8] feat: release-1.6 logs for priceline --- rollout/context.go | 3 +++ rollout/pause.go | 5 +++++ rollout/replicaset.go | 7 +++++++ rollout/service.go | 2 ++ rollout/trafficrouting.go | 3 +++ 5 files changed, 20 insertions(+) diff --git a/rollout/context.go b/rollout/context.go index f8fa5b5f03..1f1005e76f 100644 --- a/rollout/context.go +++ b/rollout/context.go @@ -1,6 +1,7 @@ package rollout import ( + logutil "github.com/argoproj/argo-rollouts/utils/log" "time" log "github.com/sirupsen/logrus" @@ -56,6 +57,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) diff --git a/rollout/pause.go b/rollout/pause.go index 25ae24c3ba..3f1c4a2570 100644 --- a/rollout/pause.go +++ b/rollout/pause.go @@ -1,6 +1,7 @@ package rollout import ( + logutil "github.com/argoproj/argo-rollouts/utils/log" "time" log "github.com/sirupsen/logrus" @@ -209,6 +210,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) } } diff --git a/rollout/replicaset.go b/rollout/replicaset.go index 401e1b579d..70a190d5c8 100644 --- a/rollout/replicaset.go +++ b/rollout/replicaset.go @@ -3,6 +3,7 @@ package rollout import ( "context" "fmt" + logutil "github.com/argoproj/argo-rollouts/utils/log" "sort" "time" @@ -150,6 +151,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 } @@ -284,6 +287,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) { @@ -297,6 +302,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 diff --git a/rollout/service.go b/rollout/service.go index 69739b9315..097f4160bf 100644 --- a/rollout/service.go +++ b/rollout/service.go @@ -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 } diff --git a/rollout/trafficrouting.go b/rollout/trafficrouting.go index a87e31a9e8..cc1e552d7c 100644 --- a/rollout/trafficrouting.go +++ b/rollout/trafficrouting.go @@ -2,6 +2,7 @@ package rollout import ( "fmt" + logutil "github.com/argoproj/argo-rollouts/utils/log" "reflect" "strconv" "strings" @@ -283,6 +284,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()) } } From 502be54592e249e70a312ba0df6a4c2bf7b8406c Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 12 Jan 2024 22:36:04 +0200 Subject: [PATCH 4/8] feat: release-1.6 logs for priceline --- rollout/controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rollout/controller.go b/rollout/controller.go index 95dbe87437..e73115d6c8 100644 --- a/rollout/controller.go +++ b/rollout/controller.go @@ -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) }, } From ceda83dd5d24504f4904e52bcd7808f1d60f43d7 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Tue, 6 Feb 2024 11:25:47 +0200 Subject: [PATCH 5/8] revert --- controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/controller.go b/controller/controller.go index 4a83e7341a..afe4bc769b 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -85,7 +85,7 @@ const ( DefaultIngressThreads = 10 // DefaultLeaderElect is the default true leader election should be enabled - DefaultLeaderElect = false + DefaultLeaderElect = true // DefaultLeaderElectionLeaseDuration is the default time in seconds that non-leader candidates will wait to force acquire leadership DefaultLeaderElectionLeaseDuration = 15 * time.Second From 4a8f58f5b613057cdce022cb24b33adf5e784bf2 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Tue, 6 Feb 2024 11:37:19 +0200 Subject: [PATCH 6/8] fix linters --- rollout/context.go | 3 ++- rollout/pause.go | 3 ++- rollout/replicaset.go | 3 ++- rollout/trafficrouting.go | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/rollout/context.go b/rollout/context.go index 1f1005e76f..b9b5848e2f 100644 --- a/rollout/context.go +++ b/rollout/context.go @@ -1,9 +1,10 @@ package rollout import ( - logutil "github.com/argoproj/argo-rollouts/utils/log" "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" diff --git a/rollout/pause.go b/rollout/pause.go index 3f1c4a2570..c714636362 100644 --- a/rollout/pause.go +++ b/rollout/pause.go @@ -1,9 +1,10 @@ package rollout import ( - logutil "github.com/argoproj/argo-rollouts/utils/log" "time" + logutil "github.com/argoproj/argo-rollouts/utils/log" + log "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/rollout/replicaset.go b/rollout/replicaset.go index 70a190d5c8..5eac105807 100644 --- a/rollout/replicaset.go +++ b/rollout/replicaset.go @@ -3,10 +3,11 @@ package rollout import ( "context" "fmt" - logutil "github.com/argoproj/argo-rollouts/utils/log" "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" diff --git a/rollout/trafficrouting.go b/rollout/trafficrouting.go index cc1e552d7c..bf03d95ef1 100644 --- a/rollout/trafficrouting.go +++ b/rollout/trafficrouting.go @@ -2,11 +2,12 @@ package rollout import ( "fmt" - logutil "github.com/argoproj/argo-rollouts/utils/log" "reflect" "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" From f8628d25fdfc8b2165debe3a857f52a5c01f46bf Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Tue, 6 Feb 2024 11:46:34 +0200 Subject: [PATCH 7/8] regenerate protofiles --- pkg/apis/rollouts/v1alpha1/generated.pb.go | 2 +- pkg/apis/rollouts/v1alpha1/generated.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apis/rollouts/v1alpha1/generated.pb.go b/pkg/apis/rollouts/v1alpha1/generated.pb.go index 7a0c3ccf23..26c7e722a0 100644 --- a/pkg/apis/rollouts/v1alpha1/generated.pb.go +++ b/pkg/apis/rollouts/v1alpha1/generated.pb.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Kubernetes sample-controller Authors. +Copyright 2024 The Kubernetes sample-controller Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/rollouts/v1alpha1/generated.proto b/pkg/apis/rollouts/v1alpha1/generated.proto index ea7c60a531..1b3135874c 100644 --- a/pkg/apis/rollouts/v1alpha1/generated.proto +++ b/pkg/apis/rollouts/v1alpha1/generated.proto @@ -1,5 +1,5 @@ /* -Copyright 2023 The Kubernetes sample-controller Authors. +Copyright 2024 The Kubernetes sample-controller Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 855b76e0e49cb0ca34b38d50d8e4a87db9252461 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Tue, 6 Feb 2024 11:55:34 +0200 Subject: [PATCH 8/8] regenerate protofiles --- pkg/apis/rollouts/v1alpha1/openapi_generated.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/rollouts/v1alpha1/openapi_generated.go b/pkg/apis/rollouts/v1alpha1/openapi_generated.go index f91a313c76..ebd6ce7786 100644 --- a/pkg/apis/rollouts/v1alpha1/openapi_generated.go +++ b/pkg/apis/rollouts/v1alpha1/openapi_generated.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2023 The Kubernetes sample-controller Authors. +Copyright 2024 The Kubernetes sample-controller Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.