agent/ecscni/plugin.go
func (client *cniClient) CleanupNS(
	ctx context.Context,
	cfg *Config,
	timeout time.Duration) error {

	derivedCtx, cancel := context.WithTimeout(ctx, timeout)
	defer cancel()

	err := make(chan error)
	go func(err chan error) {
		err <- client.cleanupNS(cfg)
	}(err)

	select {
	case <-derivedCtx.Done():
		return errors.Wrap(derivedCtx.Err(), "cni cleanup: container namespace cleanup failed")
	case err := <-err:
		return err
	}
}
func (client *cniClient) CleanupNS(
	ctx context.Context,
	cfg *Config,
	timeout time.Duration) error {

	derivedCtx, cancel := context.WithTimeout(ctx, timeout)
	defer cancel()

	err := make(chan error)
	go func(err chan error) {
		err <- client.cleanupNS(cfg)
	}(err)

	select {
	case <-derivedCtx.Done():
		return errors.Wrap(derivedCtx.Err(), "cni cleanup: container namespace cleanup failed")
	case err := <-err:
		return err
	}
}
// CleanupNS will clean up the container namespace, including remove the veth
// pair and stop the dhclient