Skip to content

Conversation

@JoseVillalta
Copy link
Contributor

Summary

This pull request implements support for daemon-bridge network mode in the ECS agent, enabling tasks to run in isolated network namespaces with bridge connectivity to the host for managed daemon workloads.

Implementation details

  • Added daemon-bridge network mode support in BuildTaskNetworkConfiguration
  • Implemented buildHostDaemonNamespaceConfig to create daemon network namespaces using host ENI configuration
  • Added ConfigureDaemonNetNS and StopDaemonNetNS methods to the platform API for daemon network namespace lifecycle management
  • Extended NetworkNamespace model with NetworkMode field and WithNetworkMode() method
  • Added createDaemonBridgePluginConfig for CNI bridge configuration specific to daemon tasks
  • Updated platform API interface and implementations across common, managed Linux platforms
  • Added comprehensive unit tests for new daemon-bridge functionality

Testing

  • End to End tests launched multiple tasks in the daemon-bridge netns along with awsvpc tasks
  • Added unit tests for buildHostDaemonNamespaceConfig covering IPv4 and IPv6 scenarios
  • Added unit tests for NetworkNamespace model changes including WithNetworkMode() method
  • Added unit tests for CNI configuration generation (TestCreateDaemonBridgeConfig)
  • Updated existing test data generation to use consistent NetworkMode values
  • All existing unit tests pass with the new changes

New tests cover the changes: yes

Description for the changelog

Add support for daemon-bridge network mode for managed daemon workloads

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?

No, this PR maintains backward compatibility. The NetworkMode field in NetworkNamespace has a default value of awsvpc to ensure existing functionality remains unchanged.

Does this PR include the addition of new environment variables in the README?

No, this PR does not add any new environment variables.

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@JoseVillalta JoseVillalta requested a review from a team as a code owner November 5, 2025 00:42
@JoseVillalta JoseVillalta requested review from xxx0624 and removed request for a team November 5, 2025 00:42
@JoseVillalta JoseVillalta self-assigned this Nov 5, 2025
@JoseVillalta JoseVillalta requested a review from aviral92 November 5, 2025 00:43
@JoseVillalta JoseVillalta marked this pull request as draft November 5, 2025 01:07
@JoseVillalta JoseVillalta marked this pull request as ready for review November 5, 2025 01:13
Index int

// NetworkMode represents the network mode for this namespace.
// Supported values: awsvpc (default), daemon-bridge (managed-instances only).
Copy link
Contributor

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?


// WithNetworkMode sets the NetworkMode field
func (ns *NetworkNamespace) WithNetworkMode(mode types.NetworkMode) *NetworkNamespace {
ns.NetworkMode = mode
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

NetworkInterfaces: networkInterfaces,
KnownState: status.NetworkNone,
DesiredState: status.NetworkReadyPull,
NetworkMode: types.NetworkModeAwsvpc,
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

err = nb.startAWSVPC(ctx, taskID, netNS)
case types.NetworkModeHost:
err = nb.platformAPI.HandleHostMode()
case "daemon-bridge":
Copy link
Contributor

Choose a reason for hiding this comment

The 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.stopAWSVPC(ctx, netNS)
case types.NetworkModeHost:
err = nb.platformAPI.HandleHostMode()
case "daemon-bridge":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

case types.NetworkModeHost:
err = nb.platformAPI.HandleHostMode()
case "daemon-bridge":
// Adding extra logging to help with debug TODO remove later.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this comment.

err = nb.platformAPI.HandleHostMode()
case "daemon-bridge":
// Adding extra logging to help with debug TODO remove later.
logger.Info("Stopping Daemon network namespace setup", logFields)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this log in production?

Comment on lines +56 to +57
BridgeInterfaceName = "fargate-bridge"
ManagedInstanceBridgeName = "mi-bridge"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This change will impact all EMI tasks, not just the daemon tasks. Should we split this into a separate PR?
  • should we call it emi-bridge ?

}

// createBridgePluginConfig constructs the configuration object for bridge plugin
func createDaemonBridgePluginConfig(netNSPath string) ecscni.PluginConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a managed instance bridge, not a daemon bridge .. correct?


// buildDefaultNetworkNamespace return default network namespace of host ENI for host mode.
func (m *managedLinux) buildDefaultNetworkNamespace(taskID string) ([]*tasknetworkconfig.NetworkNamespace, error) {
func (m *managedLinux) buildDefaultNetworkNamespaceConfig(taskID string) ([]*tasknetworkconfig.NetworkNamespace, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be explicit and call it HostModeNetworkNamespaceConfig .. default can be awsvpc so that can be confusing to readers.

if err != nil {
return nil, errors.Wrap(err, "failed to create network namespace with host eni")
}
case "daemon-bridge":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this enum.

hostENI.SubnetGatewayIpv4Address = aws.String(ipv4SubNet)
}

netNSName := "host-daemon"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this enum.

netInt.DesiredStatus = status.NetworkReadyPull
netInt.KnownStatus = status.NetworkNone
daemonNamespace, err := tasknetworkconfig.NewNetworkNamespace(netNSName, netNSPath,
0, nil, netInt)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a comment, why 0.

}

// StopDaemonNetNS stops and cleans up a daemon network namespace.
func (m *managedLinux) StopDaemonNetNS(ctx context.Context, netNS *tasknetworkconfig.NetworkNamespace) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets rethink what we want to do in stop daemons.

Copy link
Contributor

@aviral92 aviral92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments on rev1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants