|
6 | 6 | "net"
|
7 | 7 | "os"
|
8 | 8 | osexec "os/exec"
|
| 9 | + "path/filepath" |
9 | 10 | "strings"
|
10 | 11 | "sync"
|
11 | 12 | "time"
|
@@ -38,6 +39,11 @@ import (
|
38 | 39 | kexec "k8s.io/kubernetes/pkg/util/exec"
|
39 | 40 | )
|
40 | 41 |
|
| 42 | +const ( |
| 43 | + cniDirPath = "/etc/cni/net.d" |
| 44 | + openshiftCNIFile = "80-openshift-sdn.conf" |
| 45 | +) |
| 46 | + |
41 | 47 | type osdnPolicy interface {
|
42 | 48 | Name() string
|
43 | 49 | Start(node *OsdnNode) error
|
@@ -112,7 +118,7 @@ func NewNodePlugin(pluginName string, osClient *osclient.Client, kClient kclient
|
112 | 118 |
|
113 | 119 | // If our CNI config file exists, remove it so that kubelet doesn't think
|
114 | 120 | // we're ready yet
|
115 |
| - os.Remove("/etc/cni/net.d/80-openshift-sdn.conf") |
| 121 | + os.Remove(filepath.Join(cniDirPath, openshiftCNIFile)) |
116 | 122 |
|
117 | 123 | log.Infof("Initializing SDN node of type %q with configured hostname %q (IP %q), iptables sync period %q", pluginName, hostname, selfIP, proxyConfig.IPTablesSyncPeriod.Duration.String())
|
118 | 124 | if hostname == "" {
|
@@ -326,13 +332,17 @@ func (node *OsdnNode) Start() error {
|
326 | 332 | }
|
327 | 333 | }
|
328 | 334 |
|
| 335 | + if err := os.MkdirAll(cniDirPath, 0755); err != nil { |
| 336 | + return err |
| 337 | + } |
| 338 | + |
329 | 339 | go kwait.Forever(node.policy.SyncVNIDRules, time.Hour)
|
330 | 340 |
|
331 | 341 | log.V(5).Infof("openshift-sdn network plugin ready")
|
332 | 342 |
|
333 | 343 | // Write our CNI config file out to disk to signal to kubelet that
|
334 | 344 | // our network plugin is ready
|
335 |
| - return ioutil.WriteFile("/etc/cni/net.d/80-openshift-sdn.conf", []byte(` |
| 345 | + return ioutil.WriteFile(filepath.Join(cniDirPath, openshiftCNIFile), []byte(` |
336 | 346 | {
|
337 | 347 | "cniVersion": "0.1.0",
|
338 | 348 | "name": "openshift-sdn",
|
|
0 commit comments