mirror of
https://github.com/rancher/os.git
synced 2025-04-27 03:00:49 +00:00
Build docker-sys bridge via system-docker args and remove cni-glue
This commit is contained in:
parent
da8d5ed027
commit
ba388b6bc6
@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "bridge",
|
||||
"type": "bridge",
|
||||
"bridge": "docker-sys",
|
||||
"isDefaultGateway": true,
|
||||
"ipMasq": true,
|
||||
"hairpinMode": true,
|
||||
"ipam": {
|
||||
"type": "host-local",
|
||||
"subnet": "172.18.42.1/16"
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
bridge.d/
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"path": "/usr/bin/ros",
|
||||
"args": [
|
||||
"cni-glue",
|
||||
"poststop"
|
||||
]
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"path": "/usr/bin/ros",
|
||||
"args": [
|
||||
"cni-glue"
|
||||
]
|
||||
}
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/rancher/os/config/cloudinit/datasource/metadata"
|
||||
"github.com/rancher/os/config/cloudinit/pkg"
|
||||
"github.com/rancher/os/log"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -44,14 +43,10 @@ func NewDatasource(root string) []*MetadataService {
|
||||
roots := make([]string, 0, 5)
|
||||
|
||||
if root == "" {
|
||||
if links, err := netlink.LinkList(); err == nil {
|
||||
if links, err := netconf.GetValidLinkList(); err == nil {
|
||||
log.Infof("Checking to see if a cloudstack server-identifier is available")
|
||||
for _, link := range links {
|
||||
linkName := link.Attrs().Name
|
||||
if linkName == "lo" {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Infof("searching for cloudstack server %s on %s", serverIdentifier, linkName)
|
||||
lease := netconf.GetDhcpLease(linkName)
|
||||
if server, ok := lease[serverIdentifier]; ok {
|
||||
|
@ -122,6 +122,7 @@ var schema = `{
|
||||
"storage_context": {"type": "string"},
|
||||
"exec": {"type": ["boolean", "null"]},
|
||||
"bridge": {"type": "string"},
|
||||
"bip": {"type": "string"},
|
||||
"config_file": {"type": "string"},
|
||||
"containerd": {"type": "string"},
|
||||
"debug": {"type": ["boolean", "null"]},
|
||||
|
@ -148,6 +148,7 @@ type UpgradeConfig struct {
|
||||
|
||||
type EngineOpts struct {
|
||||
Bridge string `yaml:"bridge,omitempty" opt:"bridge"`
|
||||
BIP string `yaml:"bip,omitempty" opt:"bip"`
|
||||
ConfigFile string `yaml:"config_file,omitempty" opt:"config-file"`
|
||||
Containerd string `yaml:"containerd,omitempty" opt:"containerd"`
|
||||
Debug *bool `yaml:"debug,omitempty" opt:"debug"`
|
||||
|
6
main.go
6
main.go
@ -4,11 +4,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/containernetworking/cni/plugins/ipam/host-local"
|
||||
"github.com/containernetworking/cni/plugins/main/bridge"
|
||||
"github.com/docker/docker/docker"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/rancher/cniglue"
|
||||
"github.com/rancher/os/cmd/cloudinitexecute"
|
||||
"github.com/rancher/os/cmd/cloudinitsave"
|
||||
"github.com/rancher/os/cmd/control"
|
||||
@ -35,9 +32,6 @@ var entrypoints = map[string]func(){
|
||||
"ros-bootstrap": control.BootstrapMain,
|
||||
"ros-sysinit": sysinit.Main,
|
||||
"wait-for-docker": wait.Main,
|
||||
"cni-glue": glue.Main,
|
||||
"bridge": bridge.Main,
|
||||
"host-local": hostlocal.Main,
|
||||
"respawn": respawn.Main,
|
||||
|
||||
// Power commands
|
||||
|
@ -66,7 +66,7 @@ func createInterfaces(netCfg *NetworkConfig) {
|
||||
}
|
||||
|
||||
func createSlaveInterfaces(netCfg *NetworkConfig) {
|
||||
links, err := netlink.LinkList()
|
||||
links, err := GetValidLinkList()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to list links: %v", err)
|
||||
return
|
||||
@ -167,7 +167,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
|
||||
createInterfaces(netCfg)
|
||||
createSlaveInterfaces(netCfg)
|
||||
|
||||
links, err := netlink.LinkList()
|
||||
links, err := GetValidLinkList()
|
||||
if err != nil {
|
||||
log.Errorf("error getting LinkList: %s", err)
|
||||
return false, err
|
||||
@ -177,10 +177,7 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
|
||||
|
||||
//apply network config
|
||||
for _, link := range links {
|
||||
linkName := link.Attrs().Name
|
||||
if linkName != "lo" {
|
||||
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
|
||||
}
|
||||
applyOuter(link, netCfg, &wg, userSetHostname, userSetDNS)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
@ -189,13 +186,11 @@ func ApplyNetworkConfigs(netCfg *NetworkConfig, userSetHostname, userSetDNS bool
|
||||
dnsSet := false
|
||||
for _, link := range links {
|
||||
linkName := link.Attrs().Name
|
||||
if linkName != "lo" {
|
||||
log.Infof("dns testing %s", linkName)
|
||||
lease := GetDhcpLease(linkName)
|
||||
if _, ok := lease["domain_name_servers"]; ok {
|
||||
log.Infof("dns was dhcp set for %s", linkName)
|
||||
dnsSet = true
|
||||
}
|
||||
log.Infof("dns testing %s", linkName)
|
||||
lease := GetDhcpLease(linkName)
|
||||
if _, ok := lease["domain_name_servers"]; ok {
|
||||
log.Infof("dns was dhcp set for %s", linkName)
|
||||
dnsSet = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,3 +505,22 @@ func runCmds(cmds []string, iface string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func GetValidLinkList() ([]netlink.Link, error) {
|
||||
var validLinkList []netlink.Link
|
||||
links, err := netlink.LinkList()
|
||||
if err != nil {
|
||||
return validLinkList, err
|
||||
}
|
||||
|
||||
for _, l := range links {
|
||||
linkName := l.Attrs().Name
|
||||
if linkName == "lo" || linkName == "docker-sys" {
|
||||
continue
|
||||
}
|
||||
validLinkList = append(validLinkList, l)
|
||||
}
|
||||
|
||||
return validLinkList, nil
|
||||
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ rancher:
|
||||
system_docker:
|
||||
exec: true
|
||||
storage_driver: overlay2
|
||||
bridge: none
|
||||
bip: 172.18.42.1/16
|
||||
restart: false
|
||||
graph: /var/lib/system-docker
|
||||
group: root
|
||||
|
Loading…
Reference in New Issue
Block a user