Skip to content

Commit

Permalink
Fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoda committed Nov 1, 2022
1 parent 7abeb52 commit b94d988
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit b94d988

Please sign in to comment.