Skip to content

Commit 65abbab

Browse files
author
Ravi Sankar Penta
committed
Allow configurable CNI bin dir in openshift SDN
1 parent 2755ea7 commit 65abbab

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

pkg/cmd/server/kubernetes/network/sdn_linux.go

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func NewSDNInterfaces(options configapi.NodeConfig, networkClient networkclient.
3636
}
3737
}
3838

39+
cniBinDir := kcni.DefaultCNIDir
40+
if val, ok := options.KubeletArguments["cni-bin-dir"]; ok && len(val) == 1 {
41+
cniBinDir = val[0]
42+
}
3943
cniConfDir := kcni.DefaultNetDir
4044
if val, ok := options.KubeletArguments["cni-conf-dir"]; ok && len(val) == 1 {
4145
cniConfDir = val[0]
@@ -55,6 +59,7 @@ func NewSDNInterfaces(options configapi.NodeConfig, networkClient networkclient.
5559
Hostname: options.NodeName,
5660
SelfIP: options.NodeIP,
5761
RuntimeEndpoint: runtimeEndpoint,
62+
CNIBinDir: cniBinDir,
5863
CNIConfDir: cniConfDir,
5964
MTU: options.NetworkConfig.MTU,
6065
NetworkClient: networkClient,

pkg/network/node/node.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type OsdnNodeConfig struct {
7575
RuntimeEndpoint string
7676
MTU uint32
7777
EnableHostports bool
78+
CNIBinDir string
7879
CNIConfDir string
7980

8081
NetworkClient networkclient.Interface
@@ -174,7 +175,7 @@ func New(c *OsdnNodeConfig) (network.NodeInterface, error) {
174175
networkClient: c.NetworkClient,
175176
recorder: c.Recorder,
176177
oc: oc,
177-
podManager: newPodManager(c.KClient, policy, c.MTU, oc, c.EnableHostports),
178+
podManager: newPodManager(c.KClient, policy, c.MTU, c.CNIBinDir, oc, c.EnableHostports),
178179
localIP: c.SelfIP,
179180
hostName: c.Hostname,
180181
useConnTrack: useConnTrack,

pkg/network/node/pod.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
2727
kcontainer "k8s.io/kubernetes/pkg/kubelet/container"
2828
knetwork "k8s.io/kubernetes/pkg/kubelet/network"
29-
kcni "k8s.io/kubernetes/pkg/kubelet/network/cni"
3029
kubehostport "k8s.io/kubernetes/pkg/kubelet/network/hostport"
3130
kbandwidth "k8s.io/kubernetes/pkg/util/bandwidth"
3231
utildbus "k8s.io/kubernetes/pkg/util/dbus"
@@ -43,7 +42,6 @@ import (
4342

4443
const (
4544
podInterfaceName = knetwork.DefaultInterfaceName
46-
cniBinPath = kcni.DefaultCNIDir
4745
)
4846

4947
type podHandler interface {
@@ -69,10 +67,11 @@ type podManager struct {
6967
runningPodsLock sync.Mutex
7068

7169
// Live pod setup/teardown stuff not used in testing code
72-
kClient kclientset.Interface
73-
policy osdnPolicy
74-
mtu uint32
75-
ovs *ovsController
70+
kClient kclientset.Interface
71+
policy osdnPolicy
72+
mtu uint32
73+
cniBinPath string
74+
ovs *ovsController
7675

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

8988
// Creates a new live podManager; used by node code0
90-
func newPodManager(kClient kclientset.Interface, policy osdnPolicy, mtu uint32, ovs *ovsController, enableHostports bool) *podManager {
89+
func newPodManager(kClient kclientset.Interface, policy osdnPolicy, mtu uint32, cniBinPath string, ovs *ovsController, enableHostports bool) *podManager {
9190
pm := newDefaultPodManager()
9291
pm.kClient = kClient
9392
pm.policy = policy
9493
pm.mtu = mtu
94+
pm.cniBinPath = cniBinPath
9595
pm.podHandler = pm
9696
pm.ovs = ovs
9797
pm.enableHostports = enableHostports
@@ -408,7 +408,7 @@ func maybeAddMacvlan(pod *kapi.Pod, netns string) error {
408408
return nil
409409
}
410410

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

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

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

0 commit comments

Comments
 (0)