Skip to content

Commit

Permalink
If HPA isn't set and replicas are not specified, it uses the primary …
Browse files Browse the repository at this point in the history
…replicas when scaling up the canary

Signed-off-by: Moscagus <gustavo.varisco@gmail.com>
  • Loading branch information
Moscagus committed Mar 10, 2022
1 parent cf8fe94 commit f7fd6cc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/canary/deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ func (c *DeploymentController) ScaleFromZero(cd *flaggerv1.Canary) error {
replicas := int32p(1)
if dep.Spec.Replicas != nil && *dep.Spec.Replicas > 0 {
replicas = dep.Spec.Replicas
} else if cd.Spec.AutoscalerRef == nil {
// If HPA isn't set and replicas are not specified, it uses the primary replicas when scaling up the canary
primaryName := fmt.Sprintf("%s-primary", targetName)
primary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("deployment %s.%s get query error: %w", primaryName, cd.Namespace, err)
}

if primary.Spec.Replicas != nil && *primary.Spec.Replicas > 0 {
replicas = primary.Spec.Replicas
}
}
depCopy := dep.DeepCopy()
depCopy.Spec.Replicas = replicas
Expand Down

0 comments on commit f7fd6cc

Please sign in to comment.