Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: endless deployment #39

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, the target's DesiredCount updates has already been updated.

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
Loading