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 26, 2017
1 parent 0320dcc commit 4570e27
Show file tree
Hide file tree
Showing 39 changed files with 56 additions and 48 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
12 changes: 6 additions & 6 deletions pkg/cmd/server/kubernetes/node/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ type NodeConfig struct {
// DNSConfig controls the DNS configuration.
DNSServer *dns.Server

// SDNPlugin is an optional SDN plugin
SDNPlugin sdn.NodeInterface
// SDNNode is an optional SDN node interface
SDNNode sdn.NodeInterface
// SDNProxy is an optional service endpoints filterer
SDNProxy sdn.ProxyInterface
}
Expand Down Expand Up @@ -234,10 +234,10 @@ 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
var sdnPlugin sdn.NodeInterface
var sdnNode sdn.NodeInterface
var sdnProxy sdn.ProxyInterface
if sdn.IsOpenShiftNetworkPlugin(options.NetworkConfig.NetworkPluginName) {
sdnPlugin, sdnProxy, err = NewSDNInterfaces(options, originClient, kubeClient, internalKubeInformers, proxyconfig)
sdnNode, sdnProxy, err = NewSDNInterfaces(options, originClient, kubeClient, internalKubeInformers, proxyconfig)
if err != nil {
return nil, fmt.Errorf("SDN initialization failed: %v", err)
}
Expand Down Expand Up @@ -312,8 +312,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
7 changes: 4 additions & 3 deletions pkg/cmd/server/kubernetes/node/sdn_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
osclient "github.com/openshift/origin/pkg/client"
configapi "github.com/openshift/origin/pkg/cmd/server/api"
"github.com/openshift/origin/pkg/sdn"
sdnplugin "github.com/openshift/origin/pkg/sdn/plugin"
sdnnode "github.com/openshift/origin/pkg/sdn/node"
sdnproxy "github.com/openshift/origin/pkg/sdn/proxy"
)

func NewSDNInterfaces(options configapi.NodeConfig, originClient *osclient.Client, kubeClient kclientset.Interface, internalKubeInformers kinternalinformers.SharedInformerFactory, proxyconfig *componentconfig.KubeProxyConfiguration) (sdn.NodeInterface, sdn.ProxyInterface, error) {
node, err := sdnplugin.NewNodePlugin(&sdnplugin.OsdnNodeConfig{
node, err := sdnnode.New(&sdnnode.OsdnNodeConfig{
PluginName: options.NetworkConfig.NetworkPluginName,
Hostname: options.NodeName,
SelfIP: options.NodeIP,
Expand All @@ -28,7 +29,7 @@ func NewSDNInterfaces(options configapi.NodeConfig, originClient *osclient.Clien
return nil, nil, err
}

proxy, err := sdnplugin.NewProxyPlugin(options.NetworkConfig.NetworkPluginName, originClient, kubeClient)
proxy, err := sdnproxy.New(options.NetworkConfig.NetworkPluginName, originClient, kubeClient)
if err != nil {
return nil, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/server/origin/controller/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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"
sdnmaster "github.com/openshift/origin/pkg/sdn/master"
)

type SDNControllerConfig struct {
Expand All @@ -29,7 +29,7 @@ func (c *SDNControllerConfig) RunController(ctx ControllerContext) (bool, error)
if err != nil {
return false, err
}
err = sdnplugin.StartMaster(
err = sdnmaster.Start(
c.NetworkConfig,
osClient,
kClient,
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
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 @@ -13,6 +13,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 @@ -36,7 +37,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 !sdn.IsOpenShiftNetworkPlugin(networkConfig.NetworkPluginName) {
return nil
}
Expand Down Expand Up @@ -138,7 +139,7 @@ func StartMaster(networkConfig osconfigapi.MasterNetworkConfig, osClient *osclie
}

func (master *OsdnMaster) checkClusterNetworkAgainstLocalNetworks() error {
hostIPNets, _, err := netutils.GetHostIPNetworks([]string{Tun0})
hostIPNets, _, err := netutils.GetHostIPNetworks([]string{node.Tun0})
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 @@ -17,7 +17,7 @@ import (
"github.com/openshift/origin/pkg/sdn"
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"
"github.com/openshift/origin/pkg/sdn"
Expand Down Expand Up @@ -112,7 +112,7 @@ type OsdnNode struct {
}

// Called by higher layers to create the plugin SDN node instance
func NewNodePlugin(c *OsdnNodeConfig) (sdn.NodeInterface, error) {
func New(c *OsdnNodeConfig) (sdn.NodeInterface, 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,4 +1,4 @@
package plugin
package node

import (
"encoding/json"
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/openshift/origin/pkg/util/netutils"

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
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 (
"github.com/openshift/origin/pkg/sdn"
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 @@ -60,7 +60,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) (sdn.ProxyInterface, error) {
func New(pluginName string, osClient *osclient.Client, kClient kclientset.Interface) (sdn.ProxyInterface, error) {
if !sdn.IsOpenShiftMultitenantNetworkPlugin(pluginName) {
return nil, nil
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"strings"
"time"

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

"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
cnitypes "github.com/containernetworking/cni/pkg/types"
cni020 "github.com/containernetworking/cni/pkg/types/020"

"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
"github.com/openshift/origin/pkg/sdn/node/cniserver"
utiltesting "k8s.io/client-go/util/testing"
)

Expand Down

0 comments on commit 4570e27

Please sign in to comment.