Skip to content

Commit

Permalink
Merge pull request kata-containers#1181 from sameo/topic/network-inte…
Browse files Browse the repository at this point in the history
…rface

Network interface removal and decoupling
  • Loading branch information
Eric Ernst authored Jan 31, 2019
2 parents 91c454d + 18dcd2c commit 29dae85
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 353 deletions.
2 changes: 0 additions & 2 deletions virtcontainers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ An example tool using the `virtcontainers` API is provided in the `hack/virtc` p

Typically the former is the Docker default networking model while the later is used on Kubernetes deployments.

`virtcontainers` callers can select one or the other, on a per sandbox basis, by setting their `SandboxConfig`'s `NetworkModel` field properly.

[cnm]: https://github.com/docker/libnetwork/blob/master/docs/design.md
[cni]: https://github.com/containernetworking/cni/

Expand Down
15 changes: 6 additions & 9 deletions virtcontainers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func newTestSandboxConfigHyperstartAgentDefaultNetwork() SandboxConfig {
AgentType: HyperstartAgent,
AgentConfig: agentConfig,

NetworkModel: DefaultNetworkModel,
NetworkConfig: netConfig,

Containers: []ContainerConfig{container},
Expand Down Expand Up @@ -2020,7 +2019,7 @@ func TestProcessListContainer(t *testing.T) {
* Benchmarks
*/

func createNewSandboxConfig(hType HypervisorType, aType AgentType, aConfig interface{}, netModel NetworkModel) SandboxConfig {
func createNewSandboxConfig(hType HypervisorType, aType AgentType, aConfig interface{}) SandboxConfig {
hypervisorConfig := HypervisorConfig{
KernelPath: "/usr/share/kata-containers/vmlinux.container",
ImagePath: "/usr/share/kata-containers/kata-containers.img",
Expand All @@ -2037,7 +2036,6 @@ func createNewSandboxConfig(hType HypervisorType, aType AgentType, aConfig inter
AgentType: aType,
AgentConfig: aConfig,

NetworkModel: netModel,
NetworkConfig: netConfig,
}
}
Expand Down Expand Up @@ -2187,7 +2185,7 @@ func createStartStopDeleteContainers(b *testing.B, sandboxConfig SandboxConfig,

func BenchmarkCreateStartStopDeleteSandboxQemuHypervisorHyperstartAgentNetworkNoop(b *testing.B) {
for i := 0; i < b.N; i++ {
sandboxConfig := createNewSandboxConfig(QemuHypervisor, HyperstartAgent, HyperConfig{}, NoopNetworkModel)
sandboxConfig := createNewSandboxConfig(QemuHypervisor, HyperstartAgent, HyperConfig{})

sockDir, err := testGenerateCCProxySockDir()
if err != nil {
Expand All @@ -2208,21 +2206,21 @@ func BenchmarkCreateStartStopDeleteSandboxQemuHypervisorHyperstartAgentNetworkNo

func BenchmarkCreateStartStopDeleteSandboxQemuHypervisorNoopAgentNetworkNoop(b *testing.B) {
for i := 0; i < b.N; i++ {
sandboxConfig := createNewSandboxConfig(QemuHypervisor, NoopAgentType, nil, NoopNetworkModel)
sandboxConfig := createNewSandboxConfig(QemuHypervisor, NoopAgentType, nil)
createStartStopDeleteSandbox(b, sandboxConfig)
}
}

func BenchmarkCreateStartStopDeleteSandboxMockHypervisorNoopAgentNetworkNoop(b *testing.B) {
for i := 0; i < b.N; i++ {
sandboxConfig := createNewSandboxConfig(MockHypervisor, NoopAgentType, nil, NoopNetworkModel)
sandboxConfig := createNewSandboxConfig(MockHypervisor, NoopAgentType, nil)
createStartStopDeleteSandbox(b, sandboxConfig)
}
}

func BenchmarkStartStop1ContainerQemuHypervisorHyperstartAgentNetworkNoop(b *testing.B) {
for i := 0; i < b.N; i++ {
sandboxConfig := createNewSandboxConfig(QemuHypervisor, HyperstartAgent, HyperConfig{}, NoopNetworkModel)
sandboxConfig := createNewSandboxConfig(QemuHypervisor, HyperstartAgent, HyperConfig{})
contConfigs := createNewContainerConfigs(1)

sockDir, err := testGenerateCCProxySockDir()
Expand All @@ -2244,7 +2242,7 @@ func BenchmarkStartStop1ContainerQemuHypervisorHyperstartAgentNetworkNoop(b *tes

func BenchmarkStartStop10ContainerQemuHypervisorHyperstartAgentNetworkNoop(b *testing.B) {
for i := 0; i < b.N; i++ {
sandboxConfig := createNewSandboxConfig(QemuHypervisor, HyperstartAgent, HyperConfig{}, NoopNetworkModel)
sandboxConfig := createNewSandboxConfig(QemuHypervisor, HyperstartAgent, HyperConfig{})
contConfigs := createNewContainerConfigs(10)

sockDir, err := testGenerateCCProxySockDir()
Expand Down Expand Up @@ -2448,7 +2446,6 @@ func TestNetworkOperation(t *testing.T) {
defer deleteNetNS(netNSPath)

config := newTestSandboxConfigNoop()
config.NetworkModel = DefaultNetworkModel
config.NetworkConfig = NetworkConfig{
NetNSPath: netNSPath,
}
Expand Down
108 changes: 0 additions & 108 deletions virtcontainers/default_network.go

This file was deleted.

16 changes: 0 additions & 16 deletions virtcontainers/documentation/api/1.0/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ sandbox lifecycle through the rest of the [sandbox API](#sandbox-functions).
* [ProxyType](#proxytype)
* [ProxyConfig](#proxyconfig)
* [ShimType](#shimtype)
* [NetworkModel](#networkmodel)
* [NetworkConfig](#networkconfig)
* [NetInterworkingModel](#netinterworkingmodel)
* [Volume](#volume)
Expand Down Expand Up @@ -76,7 +75,6 @@ type SandboxConfig struct {
ShimType ShimType
ShimConfig interface{}

NetworkModel NetworkModel
NetworkConfig NetworkConfig

// Volumes is a list of shared volumes between the host and the Sandbox.
Expand Down Expand Up @@ -257,20 +255,6 @@ const (
)
```

##### `NetworkModel`
```Go
// NetworkModel describes the type of network specification.
type NetworkModel string

const (
// NoopNetworkModel is the No-Op network.
NoopNetworkModel NetworkModel = "noop"

// CNMNetworkModel is the CNM network.
CNMNetworkModel NetworkModel = "CNM"
)
```

##### `NetworkConfig`
```Go
// NetworkConfig is the network configuration related to a network.
Expand Down
1 change: 0 additions & 1 deletion virtcontainers/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package virtcontainers
import "testing"

func testEndpointTypeSet(t *testing.T, value string, expected EndpointType) {
//var netModel NetworkModel
var endpointType EndpointType

err := endpointType.Set(value)
Expand Down
12 changes: 0 additions & 12 deletions virtcontainers/hack/virtc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ var sandboxConfigFlags = []cli.Flag{
Usage: "hypervisor machine type",
},

cli.GenericFlag{
Name: "network",
Value: new(vc.NetworkModel),
Usage: "the network model",
},

cli.GenericFlag{
Name: "proxy",
Value: new(vc.ProxyType),
Expand Down Expand Up @@ -150,11 +144,6 @@ func buildSandboxConfig(context *cli.Context) (vc.SandboxConfig, error) {
return vc.SandboxConfig{}, fmt.Errorf("Could not convert agent type")
}

networkModel, ok := context.Generic("network").(*vc.NetworkModel)
if ok != true {
return vc.SandboxConfig{}, fmt.Errorf("Could not convert network model")
}

proxyType, ok := context.Generic("proxy").(*vc.ProxyType)
if ok != true {
return vc.SandboxConfig{}, fmt.Errorf("Could not convert proxy type")
Expand Down Expand Up @@ -212,7 +201,6 @@ func buildSandboxConfig(context *cli.Context) (vc.SandboxConfig, error) {
AgentType: *agentType,
AgentConfig: agConfig,

NetworkModel: *networkModel,
NetworkConfig: netConfig,

ProxyType: *proxyType,
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/iostream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func TestIOStream(t *testing.T) {
hConfig := newHypervisorConfig(nil, nil)
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NoopNetworkModel, NetworkConfig{}, []ContainerConfig{}, nil)
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, []ContainerConfig{}, nil)
if err != nil {
t.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions virtcontainers/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestMonitorSuccess(t *testing.T) {
hConfig := newHypervisorConfig(nil, nil)

// create a sandbox
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NoopNetworkModel, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
if err != nil {
t.Fatal(err)
}
Expand All @@ -43,7 +43,7 @@ func TestMonitorClosedChannel(t *testing.T) {
hConfig := newHypervisorConfig(nil, nil)

// create a sandbox
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NoopNetworkModel, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
s, err := testCreateSandbox(t, testSandboxID, MockHypervisor, hConfig, NoopAgentType, NetworkConfig{}, []ContainerConfig{contConfig}, nil)
if err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit 29dae85

Please sign in to comment.