diff --git a/internal/deployer.go b/internal/deployer.go index f5f003b..6355941 100644 --- a/internal/deployer.go +++ b/internal/deployer.go @@ -476,14 +476,6 @@ func (d *Deployer) UpdateTraffic(ctx context.Context, blueWeight int32, greenWei } func (d *Deployer) SwapTraffic(ctx context.Context, duration *time.Duration) error { - if *duration > 0 { - d.logger.Info(fmt.Sprintf("Traffic update to blue->50%%, green->50%%, wait %.0f seconds.", duration.Seconds())) - if err := d.UpdateTraffic(ctx, int32(50), int32(50)); err != nil { - return err - } - time.Sleep(*duration) - } - blue, err := d.GetDeployTarget(ctx, BlueTargetType) if err != nil { return err @@ -494,6 +486,14 @@ func (d *Deployer) SwapTraffic(ctx context.Context, duration *time.Duration) err return err } + if *duration > 0 { + d.logger.Info(fmt.Sprintf("Traffic update to blue->50%%, green->50%%, wait %.0f seconds.", duration.Seconds())) + if err := d.UpdateTraffic(ctx, int32(50), int32(50)); err != nil { + return err + } + time.Sleep(*duration) + } + d.logger.Info(fmt.Sprintf("Traffic update to blue->%d%%, green->%d%%.", *green.TargetGroup.Weight, *blue.TargetGroup.Weight)) return d.UpdateTraffic(ctx, *green.TargetGroup.Weight, *blue.TargetGroup.Weight) }