From 45bb421bc3191135cd38847c7590bfad0ce35bf8 Mon Sep 17 00:00:00 2001 From: mitchell amihod <4623+meeech@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:40:40 -0400 Subject: [PATCH] Re-apply stable to simple canary service on abort when no traffic routing is used fixes #2781 Signed-off-by: mitchell amihod <4623+meeech@users.noreply.github.com> --- rollout/canary_test.go | 9 ++++++++- rollout/service.go | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/rollout/canary_test.go b/rollout/canary_test.go index 56445f3978..85f160c9ca 100644 --- a/rollout/canary_test.go +++ b/rollout/canary_test.go @@ -1236,8 +1236,14 @@ func TestCanarySVCSelectors(t *testing.T) { }, }, } + + pc := pauseContext{ + rollout: rollout, + } + rc := rolloutContext{ - log: logutil.WithRollout(rollout), + log: logutil.WithRollout(rollout), + pauseContext: &pc, reconcilerBase: reconcilerBase{ servicesLister: servicesLister, kubeclientset: kubeclient, @@ -1266,6 +1272,7 @@ func TestCanarySVCSelectors(t *testing.T) { }, }, } + stopchan := make(chan struct{}) defer close(stopchan) informers.Start(stopchan) diff --git a/rollout/service.go b/rollout/service.go index de63f527b3..f808cb55fc 100644 --- a/rollout/service.go +++ b/rollout/service.go @@ -257,6 +257,15 @@ func (c *rolloutContext) reconcileStableAndCanaryService() error { if err != nil { return err } + + if c.pauseContext != nil && c.pauseContext.IsAborted() && c.rollout.Spec.Strategy.Canary.TrafficRouting == nil { + err = c.ensureSVCTargets(c.rollout.Spec.Strategy.Canary.CanaryService, c.stableRS, true) + if err != nil { + return err + } + return nil + } + err = c.ensureSVCTargets(c.rollout.Spec.Strategy.Canary.CanaryService, c.newRS, true) if err != nil { return err