-
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
[DHPA] Upudate dockerPortMap() in task.go with dynamic host port range support - part 2 #3585
[DHPA] Upudate dockerPortMap() in task.go with dynamic host port range support - part 2 #3585
Conversation
// (docker would actually complain otherwise). | ||
// | ||
// Note - for service connect bridge mode, we do not allow customers to specify a host port for their application containers. | ||
// Additionally, AppNet will NOT proxy traffic to that port when an ephemeral host port is assigned. | ||
return dockerPortMap, nil |
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: maybe we could add a debug message here saying it's a regular task container and we're leaving the map empty (I also really like these comments as well)
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.
Thanks for the suggestion! I am not sure if adding a debug log here helps because
- Customers don't really have to know what happened to application containers and service connect AppNet containers as port bindings are published by the associated pause containers.
- Customers can check network bindings results for service connect AppNet container and application containers through describe-tasks.
- Showing an empty map in logs probably has less value to customers and us to debug
// | ||
// Note that, | ||
// (a) ECS Agent will not assign a new host port within the dynamic host port range for awsvpc network mode task | ||
// (b) ECS Agent will not assign a new host port within the dynamic host port range if the user-specified host port exists |
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.
Really like your explanations here.
// In buildPortMapWithSCIngressConfig, the dockerPortMap and the containerPortSet will be constructed | ||
// for ingress listeners under two service connect bridge mode cases: | ||
// (1) non-default bridge mode service connect experience: customers specify host ports for listeners in the ingress config. | ||
// (2) default bridge mode service connect experience: customers do not specify host ports for listeners in the ingress config. | ||
// Instead, ECS Agent finds host ports within the given dynamic host port range. | ||
// An error will be returned for case (2) if ECS Agent cannot find an available host port within range. |
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.
Absolutely love this demystification of the process.
Summary
DHPA - Dynamic Host Port Assignment
The target branch of this PR is feature/dynamicHostPortAssignment.
This is a follow-up PR for Upudate dockerPortMap() in task.go with dynamic host port range support - part 1 to implement dynamic host port assignment for default bridge mode service connect ingress listener ports in
dockerPortMap()
.*** For a better view of diffs between these 2 PR, please take a look on this PR. ***
Comparing to the current Upudate dockerPortMap() in task.go with dynamic host port range support - part 1 PR, main changes in this PR include:
buildPortMapWithSCIngressConfig()
to build a dockerPortMap and a containerPortSet for ingress listener ports under two service connect bridge mode cases:dockerPortMap()
to include service connect ingress listener ports infodockerPortMap()
ResetTracker()
in ephemeral_ports.go to reset the last assigned host port to 0. This function will be used in unit testsTestGetHostPort
,TestGetHostPortRange
andTestDockerHostConfigSCBridgeMode
.TestDockerHostConfigSCBridgeMode
to test changes made in this PR.Implementation details
agent/api/task/task.go
buildPortMapWithSCIngressConfig()
to build a dockerPortMap and a containerPortSet for ingress listener portsdockerPortMap()
agent/api/task/task_test.go
TestDockerHostConfigSCBridgeMode
to test changesagent/utils/ephemeral_ports.go
ResetTracker()
and use it inTestGetHostPort
andTestGetHostPortRange
agent/utils/ephemeral_ports_test.go
ResetTracker()
inTestGetHostPort
andTestGetHostPortRange
TestResetTracker
Testing
New tests cover the changes: yes
Unit test
TestDockerHostConfigSCBridgeMode
TestResetTracker
Manual test
See Upudate dockerPortMap() in task.go with dynamic host port range support - part 1 for container port and container port range testing results.
Description for the changelog
[Enhancement] Support user-specified dynamic host port range for a singular port and default bridge mode service connect ingress listener port.
Related PRs
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.