Skip to content

Commit ba388b6

Browse files
committed
Build docker-sys bridge via system-docker args and remove cni-glue
1 parent da8d5ed commit ba388b6

File tree

10 files changed

+31
-52
lines changed

10 files changed

+31
-52
lines changed

assets/docker/cni/bridge.d/bridge.conf

Lines changed: 0 additions & 12 deletions
This file was deleted.

assets/docker/cni/default.d

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/docker/hooks/poststop.d/network.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

assets/docker/hooks/prestart.d/network.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

config/cloudinit/datasource/metadata/cloudstack/metadata.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/rancher/os/config/cloudinit/datasource/metadata"
2626
"github.com/rancher/os/config/cloudinit/pkg"
2727
"github.com/rancher/os/log"
28-
"github.com/vishvananda/netlink"
2928
)
3029

3130
const (
@@ -44,14 +43,10 @@ func NewDatasource(root string) []*MetadataService {
4443
roots := make([]string, 0, 5)
4544

4645
if root == "" {
47-
if links, err := netlink.LinkList(); err == nil {
46+
if links, err := netconf.GetValidLinkList(); err == nil {
4847
log.Infof("Checking to see if a cloudstack server-identifier is available")
4948
for _, link := range links {
5049
linkName := link.Attrs().Name
51-
if linkName == "lo" {
52-
continue
53-
}
54-
5550
log.Infof("searching for cloudstack server %s on %s", serverIdentifier, linkName)
5651
lease := netconf.GetDhcpLease(linkName)
5752
if server, ok := lease[serverIdentifier]; ok {

config/schema.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ var schema = `{
122122
"storage_context": {"type": "string"},
123123
"exec": {"type": ["boolean", "null"]},
124124
"bridge": {"type": "string"},
125+
"bip": {"type": "string"},
125126
"config_file": {"type": "string"},
126127
"containerd": {"type": "string"},
127128
"debug": {"type": ["boolean", "null"]},

config/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ type UpgradeConfig struct {
148148

149149
type EngineOpts struct {
150150
Bridge string `yaml:"bridge,omitempty" opt:"bridge"`
151+
BIP string `yaml:"bip,omitempty" opt:"bip"`
151152
ConfigFile string `yaml:"config_file,omitempty" opt:"config-file"`
152153
Containerd string `yaml:"containerd,omitempty" opt:"containerd"`
153154
Debug *bool `yaml:"debug,omitempty" opt:"debug"`

main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/containernetworking/cni/plugins/ipam/host-local"
8-
"github.com/containernetworking/cni/plugins/main/bridge"
97
"github.com/docker/docker/docker"
108
"github.com/docker/docker/pkg/reexec"
11-
"github.com/rancher/cniglue"
129
"github.com/rancher/os/cmd/cloudinitexecute"
1310
"github.com/rancher/os/cmd/cloudinitsave"
1411
"github.com/rancher/os/cmd/control"
@@ -35,9 +32,6 @@ var entrypoints = map[string]func(){
3532
"ros-bootstrap": control.BootstrapMain,
3633
"ros-sysinit": sysinit.Main,
3734
"wait-for-docker": wait.Main,
38-
"cni-glue": glue.Main,
39-
"bridge": bridge.Main,
40-
"host-local": hostlocal.Main,
4135
"respawn": respawn.Main,
4236

4337
// Power commands

netconf/netconf_linux.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func createInterfaces(netCfg *NetworkConfig) {
6666
}
6767

6868
func createSlaveInterfaces(netCfg *NetworkConfig) {
69-
links, err := netlink.LinkList()
69+
links, err := GetValidLinkList()
7070
if err != nil {
7171
log.Errorf("Failed to list links: %v", err)
7272
return
@@ -167,7 +167,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
167167
createInterfaces(netCfg)
168168
createSlaveInterfaces(netCfg)
169169

170-
links, err := netlink.LinkList()
170+
links, err := GetValidLinkList()
171171
if err != nil {
172172
log.Errorf("error getting LinkList: %s", err)
173173
return false, err
@@ -177,10 +177,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
177177

178178
//apply network config
179179
for _, link := range links {
180-
linkName := link.Attrs().Name
181-
if linkName != "lo" {
182-
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
183-
}
180+
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
184181
}
185182
wg.Wait()
186183

@@ -189,13 +186,11 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
189186
dnsSet := false
190187
for _, link := range links {
191188
linkName := link.Attrs().Name
192-
if linkName != "lo" {
193-
log.Infof("dns testing %s", linkName)
194-
lease := GetDhcpLease(linkName)
195-
if _, ok := lease["domain_name_servers"]; ok {
196-
log.Infof("dns was dhcp set for %s", linkName)
197-
dnsSet = true
198-
}
189+
log.Infof("dns testing %s", linkName)
190+
lease := GetDhcpLease(linkName)
191+
if _, ok := lease["domain_name_servers"]; ok {
192+
log.Infof("dns was dhcp set for %s", linkName)
193+
dnsSet = true
199194
}
200195
}
201196

@@ -510,3 +505,22 @@ func runCmds(cmds []string, iface string) {
510505
}
511506
}
512507
}
508+
509+
func GetValidLinkList() ([]netlink.Link, error) {
510+
var validLinkList []netlink.Link
511+
links, err := netlink.LinkList()
512+
if err != nil {
513+
return validLinkList, err
514+
}
515+
516+
for _, l := range links {
517+
linkName := l.Attrs().Name
518+
if linkName == "lo" || linkName == "docker-sys" {
519+
continue
520+
}
521+
validLinkList = append(validLinkList, l)
522+
}
523+
524+
return validLinkList, nil
525+
526+
}

os-config.tpl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ rancher:
368368
system_docker:
369369
exec: true
370370
storage_driver: overlay2
371-
bridge: none
371+
bip: 172.18.42.1/16
372372
restart: false
373373
graph: /var/lib/system-docker
374374
group: root

0 commit comments

Comments
 (0)