From a8f17956725bffcbe49c99a22051a6c9fdbd25e7 Mon Sep 17 00:00:00 2001 From: yyoda Date: Wed, 31 Jul 2024 11:32:56 +0900 Subject: [PATCH] wip (#39) --- internal/deployer.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/deployer.go b/internal/deployer.go index 55912cd..5615d0c 100644 --- a/internal/deployer.go +++ b/internal/deployer.go @@ -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) @@ -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( @@ -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 }