Skip to content

Commit

Permalink
virtcontainers: Remove the network interface
Browse files Browse the repository at this point in the history
There's only one real implementer of the network interface and no real
need to implement anything else. We can just go ahead and remove this
abstraction.

Fixes: kata-containers#1179

Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
Samuel Ortiz committed Jan 25, 2019
1 parent 2b4080a commit 4d1f791
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 352 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 @@ -156,7 +156,6 @@ func newTestSandboxConfigHyperstartAgentDefaultNetwork() SandboxConfig {
AgentType: HyperstartAgent,
AgentConfig: agentConfig,

NetworkModel: DefaultNetworkModel,
NetworkConfig: netConfig,

Containers: []ContainerConfig{container},
Expand Down Expand Up @@ -1994,7 +1993,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 @@ -2011,7 +2010,6 @@ func createNewSandboxConfig(hType HypervisorType, aType AgentType, aConfig inter
AgentType: aType,
AgentConfig: aConfig,

NetworkModel: netModel,
NetworkConfig: netConfig,
}
}
Expand Down Expand Up @@ -2161,7 +2159,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 @@ -2182,21 +2180,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 @@ -2218,7 +2216,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 @@ -2422,7 +2420,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`

This comment has been minimized.

Copy link
@egernst

egernst Jan 30, 2019

What will this mean with respect to semantic versioning for kata-runtime @sameo ?

```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 4d1f791

Please sign in to comment.