-
Notifications
You must be signed in to change notification settings - Fork 640
Daemon bridge clean #4806
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
base: dev
Are you sure you want to change the base?
Daemon bridge clean #4806
Changes from all commits
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 |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import ( | |
| "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/networkinterface" | ||
| "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/serviceconnect" | ||
| "github.com/aws/amazon-ecs-agent/ecs-agent/netlib/model/status" | ||
| "github.com/aws/aws-sdk-go-v2/service/ecs/types" | ||
| ) | ||
|
|
||
| // NetworkNamespace is model representing each network namespace. | ||
|
|
@@ -30,6 +31,10 @@ type NetworkNamespace struct { | |
| Path string | ||
| Index int | ||
|
|
||
| // NetworkMode represents the network mode for this namespace. | ||
| // Supported values: awsvpc (default), daemon-bridge (managed-instances only). | ||
| NetworkMode types.NetworkMode | ||
|
|
||
| // NetworkInterfaces represents ENIs or any kind of network interface associated the particular netns. | ||
| NetworkInterfaces []*networkinterface.NetworkInterface | ||
|
|
||
|
|
@@ -58,6 +63,7 @@ func NewNetworkNamespace( | |
| NetworkInterfaces: networkInterfaces, | ||
| KnownState: status.NetworkNone, | ||
| DesiredState: status.NetworkReadyPull, | ||
| NetworkMode: types.NetworkModeAwsvpc, | ||
|
Contributor
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. should we add a comment here that we are defaulting to awsvpc if the caller does not explicity set the network mode. |
||
| } | ||
|
|
||
| // Sort interfaces as per their index values in ascending order. | ||
|
|
@@ -104,3 +110,9 @@ func (ns *NetworkNamespace) GetInterfaceByIndex(idx int64) *networkinterface.Net | |
|
|
||
| return nil | ||
| } | ||
|
|
||
| // WithNetworkMode sets the NetworkMode field | ||
| func (ns *NetworkNamespace) WithNetworkMode(mode types.NetworkMode) *NetworkNamespace { | ||
| ns.NetworkMode = mode | ||
|
Contributor
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. Should we add a validation here that the caller should only send the supported modes? |
||
| return ns | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,8 @@ func (nb *networkBuilder) Start( | |
| err = nb.startAWSVPC(ctx, taskID, netNS) | ||
| case types.NetworkModeHost: | ||
| err = nb.platformAPI.HandleHostMode() | ||
| case "daemon-bridge": | ||
|
Contributor
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. Can we remove this hard-coded config and move this to the enum. |
||
| err = nb.platformAPI.ConfigureDaemonNetNS(netNS) | ||
| default: | ||
| err = errors.New("invalid network mode: " + string(mode)) | ||
| } | ||
|
|
@@ -132,6 +134,10 @@ func (nb *networkBuilder) Stop(ctx context.Context, mode types.NetworkMode, task | |
| err = nb.stopAWSVPC(ctx, netNS) | ||
| case types.NetworkModeHost: | ||
| err = nb.platformAPI.HandleHostMode() | ||
| case "daemon-bridge": | ||
|
Contributor
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. same here. |
||
| // Adding extra logging to help with debug TODO remove later. | ||
|
Contributor
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. we can remove this comment. |
||
| logger.Info("Stopping Daemon network namespace setup", logFields) | ||
|
Contributor
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. Do we need this log in production? |
||
| err = nb.platformAPI.StopDaemonNetNS(ctx, netNS) | ||
| default: | ||
| err = errors.New("invalid network mode: " + string(mode)) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,8 @@ const ( | |
| VPCTunnelInterfaceTypeGeneve = "geneve" | ||
| VPCTunnelInterfaceTypeTap = "tap" | ||
|
|
||
| BridgeInterfaceName = "fargate-bridge" | ||
| BridgeInterfaceName = "fargate-bridge" | ||
| ManagedInstanceBridgeName = "mi-bridge" | ||
|
Comment on lines
+56
to
+57
Contributor
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.
|
||
|
|
||
| IPAMDataFileName = "eni-ipam.db" | ||
|
|
||
|
|
@@ -121,6 +122,40 @@ func createBridgePluginConfig(netNSPath string) ecscni.PluginConfig { | |
| return bridgeConfig | ||
| } | ||
|
|
||
| // createBridgePluginConfig constructs the configuration object for bridge plugin | ||
| func createDaemonBridgePluginConfig(netNSPath string) ecscni.PluginConfig { | ||
|
Contributor
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. This should be a managed instance bridge, not a daemon bridge .. correct? |
||
| cniConfig := ecscni.CNIConfig{ | ||
| NetNSPath: netNSPath, | ||
| CNISpecVersion: cniSpecVersion, | ||
| CNIPluginName: BridgePluginName, | ||
| } | ||
|
|
||
| _, routeIPNet, _ := net.ParseCIDR(AgentEndpoint) | ||
| route := &types.Route{ | ||
| Dst: *routeIPNet, | ||
| } | ||
|
|
||
| ipamConfig := &ecscni.IPAMConfig{ | ||
| CNIConfig: ecscni.CNIConfig{ | ||
| NetNSPath: netNSPath, | ||
| CNISpecVersion: cniSpecVersion, | ||
| CNIPluginName: IPAMPluginName, | ||
| }, | ||
| IPV4Subnet: ECSSubNet, | ||
| IPV4Routes: []*types.Route{route}, | ||
| ID: netNSPath, | ||
| } | ||
|
|
||
| // Invoke the bridge plugin and ipam plugin | ||
| bridgeConfig := &ecscni.BridgeConfig{ | ||
| CNIConfig: cniConfig, | ||
| Name: ManagedInstanceBridgeName, | ||
| IPAM: *ipamConfig, | ||
| } | ||
|
|
||
| return bridgeConfig | ||
| } | ||
|
|
||
| func createAppMeshPluginConfig( | ||
| netNSPath string, | ||
| cfg *appmesh.AppMesh, | ||
|
|
||
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.
Is there someplace we enforce this? like can a caller call with any mode possible or can a caller not using EMI call with daemon-bridge mode?