-
Notifications
You must be signed in to change notification settings - Fork 619
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
bugfix for container port range #3494
bugfix for container port range #3494
Conversation
430ff15
to
074b1a9
Compare
9868c82
074b1a9
to
9868c82
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.
Reapproving after testing fix rebase.
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.
Approving the rebase.
0ddd2c1
9868c82
to
0ddd2c1
Compare
0ddd2c1
to
66ef2bb
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.
Approved. As discussed offline, the loop-back may result in Agent finding overlapping ranges for a single container in some cases (which would result in container failing to start) but that's a risk we are willing to take for the potential benefit of finding contiguous port ranges.
Summary
This PR makes 2 bug-fixes:
Implementation details
We currently log ports information in agent logs here and here. With this project, we made the
containerPort
andcontainerPortRange
pointer to int/string values. So the logger is now logging the addresses of variables, rather than the values themselves. We have 2 options to fix this:a) Encode the ports into JSON and then print it. example
b) Change the references back to values. The reason why these were references in the first place is because we wanted to perform nil checks. Since we know that
containerPort: 0
andcontainerPortRange: ""
are not valid (validated on ECS side), we can stick to non-references.We're doing option (b) in this PR, since its simple and also avoids a lot of type conversions in unit tests.
Fixing concurrent host port search when a container requests multiple port mappings, each with a container port range. Currently, we lock the method where we do host port search. Once we identify host ports, we send it to docker which then maps it. A case where the same container requests multiple container port ranges, would get the same host ports picked because we do the search (for both ranges) before sending a create-container call to docker. This PR fixes it by tracking which host port was last picked and locking read/updates to this tracker. Note that the method to get host ports is also concurrent-safe to prevent two task-level go routines get ports at the same time.
Testing
Description for the changelog
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.