Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Assign CNI network name to label #76

Merged
merged 1 commit into from
Oct 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/compute/compute_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
)

var (
cniWaitLabel = "io.rancher.cni.wait"
cniWaitLabel = "io.rancher.cni.wait"
cniNetworkLabel = "io.rancher.cni.network"
)

func setupPublishPorts(hostConfig *container.HostConfig, instance model.Instance) {
Expand Down Expand Up @@ -170,7 +171,8 @@ func setupNetworkMode(instance model.Instance, client *client.Client,
portsSupported := true
hostnameSupported := true
if len(instance.Nics) > 0 {
kind := instance.Nics[0].Network.Kind
network := instance.Nics[0].Network
kind := network.Kind
if kind == "dockerHost" {
portsSupported = false
hostnameSupported = false
Expand Down Expand Up @@ -199,8 +201,12 @@ func setupNetworkMode(instance model.Instance, client *client.Client,
hostConfig.Links = nil
} else if kind == "cni" {
config.Labels[cniWaitLabel] = "true"
if config.Labels[cniNetworkLabel] == "" && network.Name != "" {
config.Labels[cniNetworkLabel] = network.Name
}
portsSupported = false
config.NetworkDisabled = true
// If this is set true resolv.conf is not setup.
config.NetworkDisabled = false
hostConfig.NetworkMode = "none"
hostConfig.Links = nil
}
Expand Down
1 change: 1 addition & 0 deletions model/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Nic struct {
} `json:"subnet"`
} `json:"ipAddresses"`
Network struct {
Name string `json:"name"`
Kind string `json:"kind"`
NetworkServices []Service
} `json:"network"`
Expand Down