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

Commit

Permalink
Merge pull request #76 from ibuildthecloud/network2
Browse files Browse the repository at this point in the history
Assign CNI network name to label
  • Loading branch information
ibuildthecloud authored Oct 31, 2016
2 parents 9bbb7bc + 26b04c5 commit 0c0f2c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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

0 comments on commit 0c0f2c3

Please sign in to comment.