-
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
Add network builder and platform APIs #3939
Conversation
Added the network builder and platform APIs into the shared library package.
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.
Overall LGTM, some nit and clarification questions
@@ -84,6 +84,10 @@ type NetworkInterface struct { | |||
ipv4SubnetCIDRBlock string | |||
ipv6SubnetCIDRBlock string | |||
|
|||
// Primary denotes whether the interface is responsible | |||
// for handling default route within the netns it resides in. | |||
Primary bool |
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: naming -- if this designates the Default route, should this be Default
?
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.
That makes sense. Will modify accordingly.
) | ||
|
||
func TestNewNetworkBuilder(t *testing.T) { | ||
|
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.
should this have a test body?
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.
Will add the body. Thanks for catching.
case WarmpoolPlatform: | ||
return &containerd{ | ||
common: commonPlatform, | ||
}, 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.
Can we add a TODO for the missing platforms (so we can see our way toward EC2 integration)?
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.
Will do.
} | ||
|
||
// The number of network namespaces required to create depends on the | ||
// number of unique interface names list across all container definitions |
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.
I believe device names are unique instance-wide at a single given time, but are not guaranteed to be unique over time. if we use the device name as our identifier we'll run the risk of collision.
So for handling a single task payload, device name is fine for differentiation, but we'll want to reference the NetworkInterfaceId where possible to guarantee uniqueness over time.
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.
I will reword this comment here. When I mentioned interface names
, I wasn't referring to the device name on the host. I was referring to ElasticNetworkInterface.Name
in the task payload. This name
field is configurable by the customer in the task definition. If the customer choses to not configure it, we default it to a string derived from the ENI's mac address.
@@ -0,0 +1,46 @@ | |||
package netlib |
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 & non-blocking comment
- Doc comments are missing in new files
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
- We can add log messages to help debug. Find examples as follows.
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.
Thank @chienhanlin for calling that out. This PR is one of the first in a list changes for UNL. I have already put in place the copyright comments for the missing pages in the next commit and I will make sure the required logging is also put in place.
Added the network builder and platform APIs into the shared library package. Network builder is intended to act as the API to be consumed by the agent to setup networking resources on the host. Network builder invokes the platform APIs to execute platform specific operations like creation of network namespaces etc. --------- Co-authored-by: Samuel Konat <[email protected]>
This reverts commit 75db5cb. 2. Revert "update daemon log path host root in container (aws#3982)" This reverts commit 6166b6e. 3. Revert "Fix loading CSI driver container from state if it exists" This reverts commit 1391502. 4. Revert "Latest FE model files (aws#3974)" This reverts commit b589a08. 5. Revert "Move utils function Uint16SliceToStringSlice to shared lib" This reverts commit 882bcb2. 6. Revert "Move remaining credentials module to shared library" This reverts commit f58f228. 7. Revert "fix merge import failure (aws#3976)" This reverts commit 46e21e6. 8. Revert "Fixing task volumes from payload for EBS-backed tasks" This reverts commit fc97633. 9. Revert "Create Generic Attachment to decouple from ENI and save attachment state. (aws#3969)" This reverts commit 12e23ed. 10. Revert "Add support for finding EBS devices on Xen instances (aws#3971)" This reverts commit 3500ac2. 11. Revert "Add network builder and platform APIs (aws#3939)" This reverts commit b8d2a7f. 12. Revert "Minor refactor of TTL cache (allow nil TTL + get TTL)" This reverts commit 4b33664. 13. Revert "Move httpclient to ecs-agent/ and minor refactor" This reverts commit 041ca3f. 14. Revert "Add missing EBSTaskAttach changes from feature branch" This reverts commit 7a0d116.
1. Revert "Load Managed Daemon images in background (aws#3984)" This reverts commit 75db5cb. 2. Revert "update daemon log path host root in container (aws#3982)" This reverts commit 6166b6e. 3. Revert "Fix loading CSI driver container from state if it exists" This reverts commit 1391502. 4. Revert "Latest FE model files (aws#3974)" This reverts commit b589a08. 5. Revert "Move utils function Uint16SliceToStringSlice to shared lib" This reverts commit 882bcb2. 6. Revert "Move remaining credentials module to shared library" This reverts commit f58f228. 7. Revert "fix merge import failure (aws#3976)" This reverts commit 46e21e6. 8. Revert "Fixing task volumes from payload for EBS-backed tasks" This reverts commit fc97633. 9. Revert "Create Generic Attachment to decouple from ENI and save attachment state. (aws#3969)" This reverts commit 12e23ed. 10. Revert "Add support for finding EBS devices on Xen instances (aws#3971)" This reverts commit 3500ac2. 11. Revert "Add network builder and platform APIs (aws#3939)" This reverts commit b8d2a7f. 12. Revert "Minor refactor of TTL cache (allow nil TTL + get TTL)" This reverts commit 4b33664. 13. Revert "Move httpclient to ecs-agent/ and minor refactor" This reverts commit 041ca3f. 14. Revert "Add missing EBSTaskAttach changes from feature branch" This reverts commit 7a0d116.
1. Revert "Load Managed Daemon images in background (#3984)" This reverts commit 75db5cb. 2. Revert "update daemon log path host root in container (#3982)" This reverts commit 6166b6e. 3. Revert "Fix loading CSI driver container from state if it exists" This reverts commit 1391502. 4. Revert "Latest FE model files (#3974)" This reverts commit b589a08. 5. Revert "Move utils function Uint16SliceToStringSlice to shared lib" This reverts commit 882bcb2. 6. Revert "Move remaining credentials module to shared library" This reverts commit f58f228. 7. Revert "fix merge import failure (#3976)" This reverts commit 46e21e6. 8. Revert "Fixing task volumes from payload for EBS-backed tasks" This reverts commit fc97633. 9. Revert "Create Generic Attachment to decouple from ENI and save attachment state. (#3969)" This reverts commit 12e23ed. 10. Revert "Add support for finding EBS devices on Xen instances (#3971)" This reverts commit 3500ac2. 11. Revert "Add network builder and platform APIs (#3939)" This reverts commit b8d2a7f. 12. Revert "Minor refactor of TTL cache (allow nil TTL + get TTL)" This reverts commit 4b33664. 13. Revert "Move httpclient to ecs-agent/ and minor refactor" This reverts commit 041ca3f. 14. Revert "Add missing EBSTaskAttach changes from feature branch" This reverts commit 7a0d116.
Summary
Added the network builder and platform APIs into the shared library package. Network builder is intended to act as the API to be consumed by the agent to setup networking resources on the host. Network builder invokes the platform APIs to execute platform specific operations like creation of network namespaces etc.
In this PR, we mostly have the skeleton of the APIs + implementation of the methods to translate the task payload into the task network configuration. Remaining workflows in the builder and platform layers will follow in subsequent PRs.
Implementation details
The most significant additions are the
ecs-agent/netlib/network_builder.go
andecs-agent/netlib/platform/*
files. TheNetworkBuilder
interface exposes higher level functions for network setup andplatform.API
exposes platform specific methods to be consumed byNetworkBuilder
methods.As of now, the only method from
NetworkBuilder
we have implemented isBuildTaskNetworkConfiguration
. The remaining will be implemented in the subsequent PRs.Testing
go test -tags unit ./ecs-agent/...
Existing and new unit tests pass.
New tests cover the changes: Yes
Description for the changelog
Add network builder and platform APIs
Does this PR include breaking model changes? If so, Have you added transformation functions?
No
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.