Skip to content

Commit

Permalink
Fixed build regarding opts and logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoboat committed Sep 28, 2022
1 parent 2452161 commit a7bc593
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions awscommons/v2/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func WaitForContainerInstancesToDrain(opts *Options, clusterName string, contain
numBatches := int(math.Ceil(float64(len(containerInstanceArns) / batchSize)))

err = retry.DoWithRetry(
opts.Logger,
opts.Logger.Logger,
"Wait for Container Instances to be Drained",
maxRetries, sleepBetweenRetries,
func() error {
Expand Down Expand Up @@ -144,7 +144,7 @@ func WaitForContainerInstancesToDrain(opts *Options, clusterName string, contain
}

// Yay, all done.
if drained, _ := allInstancesFullyDrained(responses); drained == true {
if drained, _ := allInstancesFullyDrained(opts, responses); drained == true {
if opts.Logger != nil {
opts.Logger.Debugf("All container instances have been drained in Cluster %s!", clusterName)
}
Expand Down Expand Up @@ -177,23 +177,23 @@ func NewECSClient(opts *Options) (*ecs.Client, error) {
return ecs.NewFromConfig(cfg), nil
}

func allInstancesFullyDrained(responses []*ecs.DescribeContainerInstancesOutput) (bool, error) {
func allInstancesFullyDrained(opts *Options, responses []*ecs.DescribeContainerInstancesOutput) (bool, error) {
for _, response := range responses {
instances := response.ContainerInstances
if len(instances) == 0 {
return false, errors.WithStackTrace(fmt.Errorf("querying DescribeContainerInstances returned no instances"))
}

for _, instance := range instances {
if !instanceFullyDrained(instance) {
if !instanceFullyDrained(opts, instance) {
return false, nil
}
}
}
return true, nil
}

func instanceFullyDrained(instance ecs_types.ContainerInstance) bool {
func instanceFullyDrained(opts *Options, instance ecs_types.ContainerInstance) bool {
instanceArn := instance.ContainerInstanceArn

if *instance.Status == "ACTIVE" {
Expand Down

0 comments on commit a7bc593

Please sign in to comment.