Skip to content

Commit

Permalink
Split up SDN master/node/proxy/CNI code
Browse files Browse the repository at this point in the history
  • Loading branch information
danwinship committed Aug 15, 2017
1 parent f145031 commit b9b597d
Show file tree
Hide file tree
Showing 41 changed files with 66 additions and 58 deletions.
2 changes: 1 addition & 1 deletion hack/lib/build/constants.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ readonly OS_OUTPUT_PKGDIR="${OS_OUTPUT}/pkgdir"
readonly OS_GO_PACKAGE=github.com/openshift/origin

readonly OS_SDN_COMPILE_TARGETS_LINUX=(
pkg/sdn/plugin/sdn-cni-plugin
pkg/sdn/sdn-cni-plugin
vendor/github.com/containernetworking/cni/plugins/ipam/host-local
vendor/github.com/containernetworking/cni/plugins/main/loopback
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/server/kubernetes/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ func SetFakeContainerManagerInterfaceForIntegrationTest() {
defaultContainerManagerInterface = cm.NewStubContainerManager()
}

// RunPlugin starts the local SDN plugin, if enabled in configuration.
func (c *NodeConfig) RunPlugin() {
if c.SDNPlugin == nil {
// RunSDN starts the SDN, if the OpenShift SDN network plugin is enabled in configuration.
func (c *NodeConfig) RunSDN() {
if c.SDNNode == nil {
return
}
if err := c.SDNPlugin.Start(); err != nil {
if err := c.SDNNode.Start(); err != nil {
glog.Fatalf("error: SDN node startup failed: %v", err)
}
}
Expand Down
23 changes: 12 additions & 11 deletions pkg/cmd/server/kubernetes/node/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import (
"github.com/openshift/origin/pkg/cmd/util/variable"
"github.com/openshift/origin/pkg/dns"
sdnapi "github.com/openshift/origin/pkg/sdn/apis/network"
sdnplugin "github.com/openshift/origin/pkg/sdn/plugin"
sdnnode "github.com/openshift/origin/pkg/sdn/node"
sdnproxy "github.com/openshift/origin/pkg/sdn/proxy"
)

// NodeConfig represents the required parameters to start the OpenShift node
Expand Down Expand Up @@ -79,10 +80,10 @@ type NodeConfig struct {
// DNSConfig controls the DNS configuration.
DNSServer *dns.Server

// SDNPlugin is an optional SDN plugin
SDNPlugin *sdnplugin.OsdnNode
// SDNNode is an optional SDN plugin
SDNNode *sdnnode.OsdnNode
// SDNProxy is an optional service endpoints filterer
SDNProxy *sdnplugin.OsdnProxy
SDNProxy *sdnproxy.OsdnProxy
}

func BuildKubernetesNodeConfig(options configapi.NodeConfig, enableProxy, enableDNS bool) (*NodeConfig, error) {
Expand Down Expand Up @@ -234,7 +235,7 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig, enableProxy, enable
internalKubeInformers := kinternalinformers.NewSharedInformerFactory(kubeClient, proxyconfig.ConfigSyncPeriod.Duration)

// Initialize SDN before building kubelet config so it can modify option
sdnNodeConfig := &sdnplugin.OsdnNodeConfig{
sdnNodeConfig := &sdnnode.OsdnNodeConfig{
PluginName: options.NetworkConfig.NetworkPluginName,
Hostname: options.NodeName,
SelfIP: options.NodeIP,
Expand All @@ -246,12 +247,12 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig, enableProxy, enable
IPTablesSyncPeriod: proxyconfig.IPTables.SyncPeriod.Duration,
ProxyMode: proxyconfig.Mode,
}
sdnPlugin, err := sdnplugin.NewNodePlugin(sdnNodeConfig)
sdnNode, err := sdnnode.New(sdnNodeConfig)
if err != nil {
return nil, fmt.Errorf("SDN initialization failed: %v", err)
}
if sdnPlugin != nil {
// SDN plugin pod setup/teardown is implemented as a CNI plugin
if sdnNode != nil {
// SDN pod setup/teardown is implemented as a CNI plugin
server.NetworkPluginName = kubeletcni.CNIPluginName
server.NetworkPluginDir = kubeletcni.DefaultNetDir
server.CNIConfDir = kubeletcni.DefaultNetDir
Expand Down Expand Up @@ -307,7 +308,7 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig, enableProxy, enable
deps.TLSOptions = nil
}

sdnProxy, err := sdnplugin.NewProxyPlugin(options.NetworkConfig.NetworkPluginName, originClient, kubeClient)
sdnProxy, err := sdnproxy.New(options.NetworkConfig.NetworkPluginName, originClient, kubeClient)
if err != nil {
return nil, fmt.Errorf("SDN proxy initialization failed: %v", err)
}
Expand All @@ -330,8 +331,8 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig, enableProxy, enable
ProxyConfig: proxyconfig,
EnableUnidling: options.EnableUnidling,

SDNPlugin: sdnPlugin,
SDNProxy: sdnProxy,
SDNNode: sdnNode,
SDNProxy: sdnProxy,
}

if enableDNS {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/server/origin/controller/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
osclient "github.com/openshift/origin/pkg/client"
configapi "github.com/openshift/origin/pkg/cmd/server/api"
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
sdnplugin "github.com/openshift/origin/pkg/sdn/plugin"
"github.com/openshift/origin/pkg/sdn/master"
"github.com/openshift/origin/pkg/service/controller/ingressip"
)

Expand All @@ -32,14 +32,14 @@ func (c *SDNControllerConfig) RunController(ctx ControllerContext) (bool, error)
if err != nil {
return false, err
}
err = sdnplugin.StartMaster(
err = master.Start(
c.NetworkConfig,
osClient,
kClient,
ctx.InternalKubeInformers,
)
if err != nil {
return false, fmt.Errorf("failed to start SDN plugin controller: %v", err)
return false, fmt.Errorf("failed to start SDN master controller: %v", err)
}
return true, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/start/start_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func StartNode(nodeConfig configapi.NodeConfig, components *utilflags.ComponentF
config.RunKubelet()
}
if components.Enabled(ComponentPlugins) {
config.RunPlugin()
config.RunSDN()
}
if components.Enabled(ComponentProxy) {
config.RunProxy()
Expand Down
6 changes: 3 additions & 3 deletions pkg/diagnostics/networkpod/util/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
kcontainer "k8s.io/kubernetes/pkg/kubelet/container"

"github.com/openshift/origin/pkg/diagnostics/types"
sdnplugin "github.com/openshift/origin/pkg/sdn/plugin"
sdnnode "github.com/openshift/origin/pkg/sdn/node"
)

type LogInterface struct {
Expand All @@ -26,8 +26,8 @@ func (l *LogInterface) LogNode(kubeClient kclientset.Interface) {

l.Run("brctl show", "bridges")
l.Run("docker ps -a", "docker-ps")
l.Run(fmt.Sprintf("ovs-ofctl -O OpenFlow13 dump-flows %s", sdnplugin.BR), "flows")
l.Run(fmt.Sprintf("ovs-ofctl -O OpenFlow13 show %s", sdnplugin.BR), "ovs-show")
l.Run(fmt.Sprintf("ovs-ofctl -O OpenFlow13 dump-flows %s", sdnnode.BR), "flows")
l.Run(fmt.Sprintf("ovs-ofctl -O OpenFlow13 show %s", sdnnode.BR), "ovs-show")
l.Run("tc qdisc show", "tc-qdisc")
l.Run("tc class show", "tc-class")
l.Run("tc filter show", "tc-filter")
Expand Down
2 changes: 2 additions & 0 deletions pkg/sdn/master/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package master contains the OpenShift SDN code that runs on the master
package master
7 changes: 4 additions & 3 deletions pkg/sdn/plugin/master.go → pkg/sdn/master/master.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package master

import (
"fmt"
Expand All @@ -12,6 +12,7 @@ import (
osapi "github.com/openshift/origin/pkg/sdn/apis/network"
osapivalidation "github.com/openshift/origin/pkg/sdn/apis/network/validation"
"github.com/openshift/origin/pkg/sdn/common"
"github.com/openshift/origin/pkg/sdn/node"
"github.com/openshift/origin/pkg/util/netutils"

kapierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -35,7 +36,7 @@ type OsdnMaster struct {
hostSubnetNodeIPs map[ktypes.UID]string
}

func StartMaster(networkConfig osconfigapi.MasterNetworkConfig, osClient *osclient.Client, kClient kclientset.Interface, informers kinternalinformers.SharedInformerFactory) error {
func Start(networkConfig osconfigapi.MasterNetworkConfig, osClient *osclient.Client, kClient kclientset.Interface, informers kinternalinformers.SharedInformerFactory) error {
if !osapi.IsOpenShiftNetworkPlugin(networkConfig.NetworkPluginName) {
return nil
}
Expand Down Expand Up @@ -137,7 +138,7 @@ func StartMaster(networkConfig osconfigapi.MasterNetworkConfig, osClient *osclie
}

func (master *OsdnMaster) checkClusterNetworkAgainstLocalNetworks() error {
hostIPNets, _, err := netutils.GetHostIPNetworks([]string{TUN})
hostIPNets, _, err := netutils.GetHostIPNetworks([]string{node.TUN})
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package master

import (
"testing"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package master

import (
"fmt"
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdn/plugin/vnids_master.go → pkg/sdn/master/vnids.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package master

import (
"fmt"
Expand All @@ -16,7 +16,7 @@ import (
osclient "github.com/openshift/origin/pkg/client"
osapi "github.com/openshift/origin/pkg/sdn/apis/network"
"github.com/openshift/origin/pkg/sdn/common"
pnetid "github.com/openshift/origin/pkg/sdn/plugin/netid"
pnetid "github.com/openshift/origin/pkg/sdn/master/netid"
)

type masterVNIDMap struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package master

import (
"testing"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions pkg/sdn/node/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package node contains the OpenShift SDN networking code that runs on the nodes
package node
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"sync"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand Down
6 changes: 3 additions & 3 deletions pkg/sdn/plugin/node.go → pkg/sdn/node/node.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand All @@ -13,7 +13,7 @@ import (

log "github.com/golang/glog"

"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
"github.com/openshift/origin/pkg/sdn/node/cniserver"

osclient "github.com/openshift/origin/pkg/client"
osapi "github.com/openshift/origin/pkg/sdn/apis/network"
Expand Down Expand Up @@ -111,7 +111,7 @@ type OsdnNode struct {
}

// Called by higher layers to create the plugin SDN node instance
func NewNodePlugin(c *OsdnNodeConfig) (*OsdnNode, error) {
func New(c *OsdnNodeConfig) (*OsdnNode, error) {
var policy osdnPolicy
var pluginId int
var minOvsVersion string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"encoding/hex"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdn/plugin/pod.go → pkg/sdn/node/pod.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package plugin
package node

import (
"encoding/json"
"fmt"
"net"
"sync"

"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
"github.com/openshift/origin/pkg/sdn/node/cniserver"
"github.com/openshift/origin/pkg/util/netutils"

"github.com/golang/glog"
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdn/plugin/pod_linux.go → pkg/sdn/node/pod_linux.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// +build linux

package plugin
package node

import (
"fmt"
Expand All @@ -9,7 +9,7 @@ import (
"syscall"

sdnapi "github.com/openshift/origin/pkg/sdn/apis/network"
"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
"github.com/openshift/origin/pkg/sdn/node/cniserver"
"github.com/openshift/origin/pkg/util/ipcmd"

"github.com/golang/glog"
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdn/plugin/pod_test.go → pkg/sdn/node/pod_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"encoding/json"
Expand All @@ -10,7 +10,7 @@ import (
"strings"
"testing"

"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
"github.com/openshift/origin/pkg/sdn/node/cniserver"

utiltesting "k8s.io/client-go/util/testing"
khostport "k8s.io/kubernetes/pkg/kubelet/network/hostport"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// +build !linux

package plugin
package node

import (
"fmt"

cnitypes "github.com/containernetworking/cni/pkg/types"

"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
"github.com/openshift/origin/pkg/sdn/node/cniserver"
)

func (m *podManager) setup(req *cniserver.PodRequest) (cnitypes.Result, *runningPod, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/runtime.go → pkg/sdn/node/runtime.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
osapi "github.com/openshift/origin/pkg/sdn/apis/network"
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/subnets_node.go → pkg/sdn/node/subnets.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
log "github.com/golang/glog"
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/vnids_node.go → pkg/sdn/node/vnids.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package node

import (
"testing"
Expand Down
2 changes: 2 additions & 0 deletions pkg/sdn/proxy/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package proxy contains the OpenShift SDN code that runs as part of the service proxy
package proxy
4 changes: 2 additions & 2 deletions pkg/sdn/plugin/proxy.go → pkg/sdn/proxy/proxy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package plugin
package proxy

import (
"fmt"
Expand Down Expand Up @@ -59,7 +59,7 @@ type OsdnProxy struct {
}

// Called by higher layers to create the proxy plugin instance; only used by nodes
func NewProxyPlugin(pluginName string, osClient *osclient.Client, kClient kclientset.Interface) (*OsdnProxy, error) {
func New(pluginName string, osClient *osclient.Client, kClient kclientset.Interface) (*OsdnProxy, error) {
if !osapi.IsOpenShiftMultitenantNetworkPlugin(pluginName) {
return nil, nil
}
Expand Down
File renamed without changes.
Loading

0 comments on commit b9b597d

Please sign in to comment.