-
Notifications
You must be signed in to change notification settings - Fork 422
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
feat: Support UDP listeners in Network Load Balancer #4980
Changes from 5 commits
d053f7b
cb15323
5c4523b
163bce3
2834406
7c5a96a
b46913e
413dbf4
1b27c0b
ea15d8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -500,7 +500,7 @@ func (cfg NetworkLoadBalancerListener) exposedPorts(exposedPorts []ExposedPort, | |||||||||
if cfg.IsEmpty() { | ||||||||||
return nil, nil | ||||||||||
} | ||||||||||
nlbPort, _, err := ParsePortMapping(cfg.Port) | ||||||||||
nlbPort, nlbProtocol, err := ParsePortMapping(cfg.Port) | ||||||||||
if err != nil { | ||||||||||
return nil, err | ||||||||||
} | ||||||||||
|
@@ -513,19 +513,28 @@ func (cfg NetworkLoadBalancerListener) exposedPorts(exposedPorts []ExposedPort, | |||||||||
if cfg.TargetPort != nil { | ||||||||||
targetPort = uint16(aws.IntValue(cfg.TargetPort)) | ||||||||||
} | ||||||||||
targetProtocol := strings.ToLower(TCP) | ||||||||||
if nlbProtocol != nil { | ||||||||||
protocol := strings.ToLower(aws.StringValue(nlbProtocol)) | ||||||||||
// Expose TCP port for TLS listeners. | ||||||||||
if protocol != strings.ToLower(TLS) { | ||||||||||
targetProtocol = protocol | ||||||||||
} | ||||||||||
} | ||||||||||
for _, exposedPort := range exposedPorts { | ||||||||||
if targetPort == exposedPort.Port { | ||||||||||
if targetPort == exposedPort.Port && targetProtocol == exposedPort.Protocol { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
ECS doesn't let you expose the same port twice, even if they are different protocols. Although as a client side tool we don't have to do the same validations as the service, I think I'd prefer erroring out early here. NLB can listen on a port for Anyway, based on this observation, it's likely that we won't need to change this if statement even after they'e supported the feature. So maintenance-wise, this probably won't cause burden in the future anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, that makes sense. I'll add that note and revert the change there. Wouldn't this just silently fail? No There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad!! I somehow was thinking this code was written in Now that I've had my coffee, I realize this comment doesn't make sense for the code here. This function is called after we've done all the manifest validation. At this point, it should be assumed that the manifest is totally valid - that is, no port is exposed twice. Therefore, I think we can keep it as you have (port + protocol). Since the validation already happened, there is effectively no difference between The validation code already checks that "no port is exposed twice" - it doesn't take protocol into consideration. So we are good there as well. Sorry for the confusion!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hey there @tjhorner ! Do you want me to take over the code and address the nit, so that this PR can be merged before our next release? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, that's fine. Thanks! |
||||||||||
return nil, nil | ||||||||||
} | ||||||||||
} | ||||||||||
targetContainer := workloadName | ||||||||||
if cfg.TargetContainer != nil { | ||||||||||
targetContainer = aws.StringValue(cfg.TargetContainer) | ||||||||||
} | ||||||||||
|
||||||||||
return []ExposedPort{ | ||||||||||
{ | ||||||||||
Port: targetPort, | ||||||||||
Protocol: "tcp", | ||||||||||
Protocol: targetProtocol, | ||||||||||
ContainerName: targetContainer, | ||||||||||
}, | ||||||||||
}, nil | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -241,7 +241,7 @@ List of all available properties for a `'Load Balanced Web Service'` manifest. T | |
|
||
nlb: | ||
port: 8080/tcp # Traffic on port 8080/tcp is forwarded to the main container, on port 8080. | ||
additional_rules: | ||
additional_listeners: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch! |
||
- port: 8084/tcp # Traffic on port 8084/tcp is forwarded to the main container, on port 8084. | ||
- port: 8085/tcp # Traffic on port 8085/tcp is forwarded to the sidecar "envoy", on port 3000. | ||
target_port: 3000 | ||
|
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.
Yay thanks for taking care of this case!!
Small nit -
strings.EqualFold
is case-insensitive, so we can use it for the comparison hereThere 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.
TIL! Will update to use this