From c9dc5c5936d887fa9f5f5df58ec15a9d2ff8dbb0 Mon Sep 17 00:00:00 2001 From: Forrest Thomas Date: Fri, 14 Aug 2020 16:35:50 -0700 Subject: [PATCH] fix incorrect primary label value during promotion --- pkg/canary/daemonset_controller.go | 3 ++- pkg/canary/deployment_controller.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/canary/daemonset_controller.go b/pkg/canary/daemonset_controller.go index a8d74de8..cff63280 100644 --- a/pkg/canary/daemonset_controller.go +++ b/pkg/canary/daemonset_controller.go @@ -108,6 +108,7 @@ func (c *DaemonSetController) Promote(cd *flaggerv1.Canary) error { } label, labelValue, err := c.getSelectorLabel(canary) + primaryLabelValue := fmt.Sprintf("%s-primary", labelValue); if err != nil { return fmt.Errorf("getSelectorLabel failed: %w", err) } @@ -146,7 +147,7 @@ func (c *DaemonSetController) Promote(cd *flaggerv1.Canary) error { } primaryCopy.Spec.Template.Annotations = annotations - primaryCopy.Spec.Template.Labels = makePrimaryLabels(canary.Spec.Template.Labels, labelValue, label) + primaryCopy.Spec.Template.Labels = makePrimaryLabels(canary.Spec.Template.Labels, primaryLabelValue, label) // apply update _, err = c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Update(context.TODO(), primaryCopy, metav1.UpdateOptions{}) diff --git a/pkg/canary/deployment_controller.go b/pkg/canary/deployment_controller.go index b57a8d09..c3e3cc4e 100644 --- a/pkg/canary/deployment_controller.go +++ b/pkg/canary/deployment_controller.go @@ -73,6 +73,7 @@ func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error { } label, labelValue, err := c.getSelectorLabel(canary) + primaryLabelValue := fmt.Sprintf("%s-primary", labelValue); if err != nil { return fmt.Errorf("getSelectorLabel failed: %w", err) } @@ -107,7 +108,7 @@ func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error { } primaryCopy.Spec.Template.Annotations = annotations - primaryCopy.Spec.Template.Labels = makePrimaryLabels(canary.Spec.Template.Labels, labelValue, label) + primaryCopy.Spec.Template.Labels = makePrimaryLabels(canary.Spec.Template.Labels, primaryLabelValue, label) // apply update _, err = c.kubeClient.AppsV1().Deployments(cd.Namespace).Update(context.TODO(), primaryCopy, metav1.UpdateOptions{})