Skip to content

Commit

Permalink
Merge pull request #18464 from pravisankar/sdn-cnibinpath-validation
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Allow configurable CNI bin dir in openshift SDN
  • Loading branch information
openshift-merge-robot committed Mar 11, 2018
2 parents bf0cf42 + 65abbab commit 1e041c8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions pkg/cmd/server/kubernetes/network/sdn_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func NewSDNInterfaces(options configapi.NodeConfig, networkClient networkclient.
}
}

cniBinDir := kcni.DefaultCNIDir
if val, ok := options.KubeletArguments["cni-bin-dir"]; ok && len(val) == 1 {
cniBinDir = val[0]
}
cniConfDir := kcni.DefaultNetDir
if val, ok := options.KubeletArguments["cni-conf-dir"]; ok && len(val) == 1 {
cniConfDir = val[0]
Expand All @@ -55,6 +59,7 @@ func NewSDNInterfaces(options configapi.NodeConfig, networkClient networkclient.
Hostname: options.NodeName,
SelfIP: options.NodeIP,
RuntimeEndpoint: runtimeEndpoint,
CNIBinDir: cniBinDir,
CNIConfDir: cniConfDir,
MTU: options.NetworkConfig.MTU,
NetworkClient: networkClient,
Expand Down
3 changes: 2 additions & 1 deletion pkg/network/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type OsdnNodeConfig struct {
RuntimeEndpoint string
MTU uint32
EnableHostports bool
CNIBinDir string
CNIConfDir string

NetworkClient networkclient.Interface
Expand Down Expand Up @@ -174,7 +175,7 @@ func New(c *OsdnNodeConfig) (network.NodeInterface, error) {
networkClient: c.NetworkClient,
recorder: c.Recorder,
oc: oc,
podManager: newPodManager(c.KClient, policy, c.MTU, oc, c.EnableHostports),
podManager: newPodManager(c.KClient, policy, c.MTU, c.CNIBinDir, oc, c.EnableHostports),
localIP: c.SelfIP,
hostName: c.Hostname,
useConnTrack: useConnTrack,
Expand Down
24 changes: 12 additions & 12 deletions pkg/network/node/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
kcontainer "k8s.io/kubernetes/pkg/kubelet/container"
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
kcni "k8s.io/kubernetes/pkg/kubelet/network/cni"
kubehostport "k8s.io/kubernetes/pkg/kubelet/network/hostport"
kbandwidth "k8s.io/kubernetes/pkg/util/bandwidth"
utildbus "k8s.io/kubernetes/pkg/util/dbus"
Expand All @@ -43,7 +42,6 @@ import (

const (
podInterfaceName = knetwork.DefaultInterfaceName
cniBinPath = kcni.DefaultCNIDir
)

type podHandler interface {
Expand All @@ -69,10 +67,11 @@ type podManager struct {
runningPodsLock sync.Mutex

// Live pod setup/teardown stuff not used in testing code
kClient kclientset.Interface
policy osdnPolicy
mtu uint32
ovs *ovsController
kClient kclientset.Interface
policy osdnPolicy
mtu uint32
cniBinPath string
ovs *ovsController

enableHostports bool
// true if hostports have been synced at least once
Expand All @@ -87,11 +86,12 @@ type podManager struct {
}

// Creates a new live podManager; used by node code0
func newPodManager(kClient kclientset.Interface, policy osdnPolicy, mtu uint32, ovs *ovsController, enableHostports bool) *podManager {
func newPodManager(kClient kclientset.Interface, policy osdnPolicy, mtu uint32, cniBinPath string, ovs *ovsController, enableHostports bool) *podManager {
pm := newDefaultPodManager()
pm.kClient = kClient
pm.policy = policy
pm.mtu = mtu
pm.cniBinPath = cniBinPath
pm.podHandler = pm
pm.ovs = ovs
pm.enableHostports = enableHostports
Expand Down Expand Up @@ -408,7 +408,7 @@ func maybeAddMacvlan(pod *kapi.Pod, netns string) error {
return nil
}

func createIPAMArgs(netnsPath string, action cniserver.CNICommand, id string) *invoke.Args {
func createIPAMArgs(netnsPath, cniBinPath string, action cniserver.CNICommand, id string) *invoke.Args {
return &invoke.Args{
Command: string(action),
ContainerID: id,
Expand All @@ -424,8 +424,8 @@ func (m *podManager) ipamAdd(netnsPath string, id string) (*cni020.Result, net.I
return nil, nil, fmt.Errorf("netns required for CNI_ADD")
}

args := createIPAMArgs(netnsPath, cniserver.CNI_ADD, id)
r, err := invoke.ExecPluginWithResult(cniBinPath+"/host-local", m.ipamConfig, args)
args := createIPAMArgs(netnsPath, m.cniBinPath, cniserver.CNI_ADD, id)
r, err := invoke.ExecPluginWithResult(m.cniBinPath+"/host-local", m.ipamConfig, args)
if err != nil {
return nil, nil, fmt.Errorf("failed to run CNI IPAM ADD: %v", err)
}
Expand All @@ -444,8 +444,8 @@ func (m *podManager) ipamAdd(netnsPath string, id string) (*cni020.Result, net.I

// Run CNI IPAM release for the container
func (m *podManager) ipamDel(id string) error {
args := createIPAMArgs("", cniserver.CNI_DEL, id)
err := invoke.ExecPluginWithoutResult(cniBinPath+"/host-local", m.ipamConfig, args)
args := createIPAMArgs("", m.cniBinPath, cniserver.CNI_DEL, id)
err := invoke.ExecPluginWithoutResult(m.cniBinPath+"/host-local", m.ipamConfig, args)
if err != nil {
return fmt.Errorf("failed to run CNI IPAM DEL: %v", err)
}
Expand Down

0 comments on commit 1e041c8

Please sign in to comment.