-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add utilities for ecs. #73
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM! Had a few nits.
awscommons/v2/ecs.go
Outdated
logger := logging.GetProjectLogger() | ||
logger.Infof("Looking up Container Instance ARNs for ECS cluster %s", clusterName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the autoscaling PR, the logger should be injected in the Options
struct.
awscommons/v2/ecs.go
Outdated
input := &ecs.ListContainerInstancesInput{Cluster: aws.String(clusterName)} | ||
arns := []string{} | ||
// Handle pagination by repeatedly making the API call while there is a next token set. | ||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: consider adding a maximum to the loop iteration to avoid an infinite loop. Logically, the AWS API should prevent such an infinite loop, but it's always good to practice defensive coding to avoid unknown unknowns causing unexpected behaviors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's true. I'll take care of this in the next review cycle, putting a todo here for now.
awscommons/v2/ecs.go
Outdated
} | ||
|
||
// Yay, all done. | ||
if drained, _ := allInstancesFullyDrained(responses); drained == true { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should handle the error or add comment as to why it's ok not to handle the error.
awscommons/v2/ecs.go
Outdated
// If there's no error, retry. | ||
if err == nil { | ||
return errors.WithStackTrace(fmt.Errorf("container instances still draining")) | ||
} | ||
|
||
// Else, there's an error, halt and fail. | ||
return retry.FatalError{Underlying: err} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This err
check is a tautology, since err
is only set within the for loop above, and you immediately return err
if there is an error. So it will always be nil
at this point.
You can reduce this to return the container instances still draining
error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. I think the best thing is to retry in all other cases. If timeout exceeded, exit with error. If drained, return nil. All other cases, retry.
af3384e
to
a8078c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Ah, Build failure, fixing... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! But it looks like there is a conflict now since you merged in the asg updates.
Let's see if that adequately fixed the merge conflict... |
Description
Add utilities for ecs.
This isn't quite ready--we probably need tests.
Documentation
TODOs
Related Issues
Related to https://github.com/gruntwork-io/ecsgrunt/pull/2.