Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdn: miscellaneous fixes after the CNI merge #11613

Merged
merged 5 commits into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/sdn/plugin/cniserver/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (

"github.com/golang/glog"
"github.com/gorilla/mux"

utilruntime "k8s.io/kubernetes/pkg/util/runtime"
utilwait "k8s.io/kubernetes/pkg/util/wait"
)

// *** The CNIServer is PRIVATE API between OpenShift SDN components and may be
Expand Down Expand Up @@ -141,7 +144,11 @@ func (s *CNIServer) Start(requestFunc cniRequestFunc) error {
}

s.SetKeepAlivesEnabled(false)
go s.Serve(l)
go utilwait.Forever(func() {
if err := s.Serve(l); err != nil {
utilruntime.HandleError(fmt.Errorf("CNI server Serve() failed: %v", err))
}
}, 0)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (plugin *OsdnNode) alreadySetUp(localSubnetGatewayCIDR, clusterNetworkCIDR
}
found = false
for _, addr := range addrs {
if strings.Contains(addr, localSubnetGatewayCIDR+" ") {
if strings.Contains(addr, localSubnetGatewayCIDR) {
found = true
break
}
Expand Down
15 changes: 11 additions & 4 deletions pkg/sdn/plugin/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type OsdnNode struct {
localIP string
hostName string
podNetworkReady chan struct{}
kubeletInitReady chan struct{}
vnids *nodeVNIDMap
iptablesSyncPeriod time.Duration
mtu uint32
Expand Down Expand Up @@ -96,6 +97,7 @@ func NewNodePlugin(pluginName string, osClient *osclient.Client, kClient *kclien
hostName: hostname,
vnids: newNodeVNIDMap(),
podNetworkReady: make(chan struct{}),
kubeletInitReady: make(chan struct{}),
iptablesSyncPeriod: iptablesSyncPeriod,
mtu: mtu,
egressPolicies: make(map[uint32][]*osapi.EgressNetworkPolicy),
Expand Down Expand Up @@ -203,10 +205,18 @@ func (node *OsdnNode) Start() error {
}
}

log.V(5).Infof("Creating and initializing openshift-sdn pod manager")
node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.mtu)
if err != nil {
return err
}
if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the listener always ready once this returns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, processCNIRequests() will be running in a goroutine at this point, handling subsequent requests from UpdatePod and kubelet.

But there's one more part to this bug that I'll push as a second commit and get another round of LGTM. @DirectXMan12 found the issues yesterday when running a combined process master and node that this PR should fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the listener established synchronously before the goroutine is spawned?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, found l, err := net.Listen("unix", s.path) in CNIServer#Start before the Serve goroutine is kicked off

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if go s.Serve(l) returns an error, nothing will log/handle/restart/exit... if it panics, the process will exit. Do we need to put handling around the Serve call inside the goroutine?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liggitt in this specific case, the CNI listener/server isn't actually in the hot path, since the Update request that this PR fixes doesn't go through the listener. We just need to make sure that processCNIRequests() is running.

return err
}

// Wait for kubelet to init the plugin so we get a knetwork.Host
log.V(5).Infof("Waiting for kubelet network plugin initialization")
<-node.kubeletInitReady

if networkChanged {
var pods []kapi.Pod
Expand All @@ -223,10 +233,7 @@ func (node *OsdnNode) Start() error {
}
}

if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil {
return err
}

log.V(5).Infof("openshift-sdn network plugin ready")
node.markPodNetworkReady()

return nil
Expand Down
10 changes: 9 additions & 1 deletion pkg/sdn/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
kcni "k8s.io/kubernetes/pkg/kubelet/network/cni"
utilsets "k8s.io/kubernetes/pkg/util/sets"

"github.com/golang/glog"
)

// This kubelet network plugin shim only exists to grab the knetwork.Host
Expand All @@ -22,7 +24,13 @@ func (node *OsdnNode) Init(host knetwork.Host, hairpinMode componentconfig.Hairp
node.host = host
node.kubeletCniPlugin = plugins[0]

return node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)
err := node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu)

// Let initial pod updates happen if they need to
glog.V(5).Infof("openshift-sdn CNI plugin initialized")
close(node.kubeletInitReady)

return err
}

func (node *OsdnNode) Name() string {
Expand Down