@@ -19,7 +19,6 @@ package canary
1919import (
2020 "context"
2121 "fmt"
22- "maps"
2322
2423 "go.uber.org/zap"
2524 appsv1 "k8s.io/api/apps/v1"
@@ -83,37 +82,17 @@ func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error {
8382 return fmt .Errorf ("deployment %s.%s get query error: %w" , targetName , cd .Namespace , err )
8483 }
8584
86- matchLabels , label , labelValue , err := c .getSelectorLabel (canary )
85+ _ , label , labelValue , err := c .getSelectorLabel (canary )
8786 primaryLabelValue := fmt .Sprintf ("%s-primary" , labelValue )
8887 if err != nil {
8988 return fmt .Errorf ("getSelectorLabel failed: %w" , err )
9089 }
9190
92- matchLabels [label ] = primaryLabelValue
93-
9491 primary , err := c .kubeClient .AppsV1 ().Deployments (cd .Namespace ).Get (context .TODO (), primaryName , metav1.GetOptions {})
9592 if err != nil {
9693 return fmt .Errorf ("deployment %s.%s get query error: %w" , primaryName , cd .Namespace , err )
9794 }
9895
99- if ! maps .Equal (primary .Spec .Selector .MatchLabels , matchLabels ) {
100- c .logger .With ("canary" , fmt .Sprintf (cd .Name , cd .Namespace )).
101- Infof (
102- "Primary deployment %s.%s matchLabels does not match canary deployment %s.%s, recreating..." ,
103- primaryName ,
104- cd .Namespace ,
105- targetName ,
106- cd .Namespace ,
107- )
108- c .recreatePrimaryDeployment (cd , canary , primaryName , c .includeLabelPrefix )
109- }
110-
111- // Get primary deployment again, in case it has changes
112- primary , err = c .kubeClient .AppsV1 ().Deployments (cd .Namespace ).Get (context .TODO (), primaryName , metav1.GetOptions {})
113- if err != nil {
114- return fmt .Errorf ("deployment %s.%s get query error: %w" , primaryName , cd .Namespace , err )
115- }
116-
11796 // promote secrets and config maps
11897 configRefs , err := c .configTracker .GetTargetConfigs (cd )
11998 if err != nil {
@@ -346,20 +325,6 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary, can
346325 return nil
347326}
348327
349- func (c * DeploymentController ) recreatePrimaryDeployment (cd * flaggerv1.Canary , canary * appsv1.Deployment , name string , includeLabelPrefix []string ) error {
350- // TODO: Make sure primary deployment is not receiving any traffic
351-
352- if err := c .kubeClient .AppsV1 ().Deployments (cd .Namespace ).Delete (context .TODO (), name , metav1.DeleteOptions {}); err != nil {
353- return fmt .Errorf ("deployment %s.%s delete error: %w" , name , cd .Namespace , err )
354- }
355-
356- if err := c .createPrimaryDeployment (cd , canary , name , includeLabelPrefix ); err != nil {
357- return fmt .Errorf ("createPrimaryDeployment failed: %w" , err )
358- }
359-
360- return nil
361- }
362-
363328// getSelectorLabel returns the selector match label
364329func (c * DeploymentController ) getSelectorLabel (deployment * appsv1.Deployment ) (map [string ]string , string , string , error ) {
365330 label , labelValue := "" , ""
0 commit comments