Skip to content

Commit

Permalink
Ensure CNI dir exists before writing openshift CNI configuration unde…
Browse files Browse the repository at this point in the history
…r CNI dir

Found this issue on RHEL containerized openshift install.
  • Loading branch information
Ravi Sankar Penta committed Jul 12, 2017
1 parent 33bb61e commit 23368fb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/sdn/plugin/node.go
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"os"
osexec "os/exec"
"path/filepath"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -38,6 +39,11 @@ import (
kexec "k8s.io/kubernetes/pkg/util/exec"
)

const (
cniDirPath = "/etc/cni/net.d"
openshiftCNIFile = "80-openshift-sdn.conf"
)

type osdnPolicy interface {
Name() string
Start(node *OsdnNode) error
Expand Down Expand Up @@ -112,7 +118,7 @@ func NewNodePlugin(pluginName string, osClient *osclient.Client, kClient kclient

// If our CNI config file exists, remove it so that kubelet doesn't think
// we're ready yet
os.Remove("/etc/cni/net.d/80-openshift-sdn.conf")
os.Remove(filepath.Join(cniDirPath, openshiftCNIFile))

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())
if hostname == "" {
Expand Down Expand Up @@ -326,13 +332,17 @@ func (node *OsdnNode) Start() error {
}
}

if err := os.MkdirAll(cniDirPath, 0755); err != nil {
return err
}

go kwait.Forever(node.policy.SyncVNIDRules, time.Hour)

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

// Write our CNI config file out to disk to signal to kubelet that
// our network plugin is ready
return ioutil.WriteFile("/etc/cni/net.d/80-openshift-sdn.conf", []byte(`
return ioutil.WriteFile(filepath.Join(cniDirPath, openshiftCNIFile), []byte(`
{
"cniVersion": "0.1.0",
"name": "openshift-sdn",
Expand Down

0 comments on commit 23368fb

Please sign in to comment.