Skip to content

Commit

Permalink
wip (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyoda authored Jul 31, 2024
1 parent 53b33ef commit a8f1795
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (d *Deployer) Deploy(
d.logger.Info(fmt.Sprintf("Start '%s' health check.", info.IdlingTarget.Type))
err = d.HealthCheck(ctx,
*info.IdlingTarget.TargetGroup.TargetGroupArn,
int(*info.RunningTarget.AutoScalingGroup.DesiredCapacity))
*info.IdlingTarget.AutoScalingGroup.AutoScalingGroupName)
if err != nil {
if errors.Is(err, RetryTimeout) {
d.logger.Error("Health check timed out. Initiating a rollback as the process cannot continue.", nil)
Expand Down Expand Up @@ -349,7 +349,7 @@ func (d *Deployer) Deploy(
return nil
}

func (d *Deployer) HealthCheck(ctx context.Context, targetGroupArn string, desiredCount int) error {
func (d *Deployer) HealthCheck(ctx context.Context, targetGroupArn string, autoScalingGroupName string) error {
maxLimit := d.config.RetryPolicy.MaxLimit
interval := aws.Duration(time.Duration(d.config.RetryPolicy.IntervalSeconds) * time.Second)
return NewFixedIntervalRetryer(maxLimit, interval).Start(
Expand All @@ -359,6 +359,12 @@ func (d *Deployer) HealthCheck(ctx context.Context, targetGroupArn string, desir
return FinishRetry, err
}

autoScalingGroup, err := d.client.DescribeAutoScalingGroup(ctx, autoScalingGroupName)
if err != nil {
return FinishRetry, err
}

desiredCount := int(*autoScalingGroup.DesiredCapacity)
if health.HealthyCount >= desiredCount {
return FinishRetry, nil
}
Expand Down

0 comments on commit a8f1795

Please sign in to comment.