diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2018-03-26 18:26:55 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-27 18:09:12 +0000 |
commit | af64e10400f8533a0c48ecdf5ab9b7fbf329e14e (patch) | |
tree | 59160e3841b440dd35189c724bbb4375a7be173b /vendor/github.com/cri-o/ocicni | |
parent | 26d7e3c7b85e28c4e42998c90fdcc14079f13eef (diff) | |
download | podman-af64e10400f8533a0c48ecdf5ab9b7fbf329e14e.tar.gz podman-af64e10400f8533a0c48ecdf5ab9b7fbf329e14e.tar.bz2 podman-af64e10400f8533a0c48ecdf5ab9b7fbf329e14e.zip |
Vendor in lots of kubernetes stuff to shrink image size
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #554
Approved by: mheon
Diffstat (limited to 'vendor/github.com/cri-o/ocicni')
-rw-r--r-- | vendor/github.com/cri-o/ocicni/pkg/ocicni/ocicni.go | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/vendor/github.com/cri-o/ocicni/pkg/ocicni/ocicni.go b/vendor/github.com/cri-o/ocicni/pkg/ocicni/ocicni.go index 8c7ce5571..c2ba9e4f2 100644 --- a/vendor/github.com/cri-o/ocicni/pkg/ocicni/ocicni.go +++ b/vendor/github.com/cri-o/ocicni/pkg/ocicni/ocicni.go @@ -107,6 +107,23 @@ func (plugin *cniNetworkPlugin) monitorNetDir() { } defer watcher.Close() + if err = watcher.Add(plugin.pluginDir); err != nil { + logrus.Errorf("Failed to add watch on %q: %v", plugin.pluginDir, err) + return + } + + // Now that `watcher` is running and watching the `pluginDir` + // gather the initial configuration, before starting the + // goroutine which will actually process events. It has to be + // done in this order to avoid missing any updates which might + // otherwise occur between gathering the initial configuration + // and starting the watcher. + if err := plugin.syncNetworkConfig(); err != nil { + logrus.Infof("Initial CNI setting failed, continue monitoring: %v", err) + } else { + logrus.Infof("Initial CNI setting succeeded") + } + go func() { for { select { @@ -132,11 +149,6 @@ func (plugin *cniNetworkPlugin) monitorNetDir() { } }() - if err = watcher.Add(plugin.pluginDir); err != nil { - logrus.Error(err) - return - } - <-plugin.monitorNetDirChan } @@ -161,18 +173,13 @@ func InitCNI(pluginDir string, cniDirs ...string) (CNIPlugin, error) { return nil, err } - // Fail loudly if plugin directory doesn't exist, because fsnotify watcher - // won't be able to watch it. - if _, err := os.Stat(pluginDir); err != nil { + // Ensure plugin directory exists, because the following monitoring logic + // relies on that. + if err := os.MkdirAll(pluginDir, 0755); err != nil { return nil, err } - if err := plugin.syncNetworkConfig(); err != nil { - // We do not have a valid default network, so start the - // monitoring thread. Network setup/teardown requests - // will fail until we have a valid default network. - go plugin.monitorNetDir() - } + go plugin.monitorNetDir() return plugin, nil } @@ -344,6 +351,9 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(podNetwork PodNetwork) (stri ip, err := getContainerIP(plugin.nsenterPath, podNetwork.NetNS, DefaultInterfaceName, "-4") if err != nil { + ip, err = getContainerIP(plugin.nsenterPath, podNetwork.NetNS, DefaultInterfaceName, "-6") + } + if err != nil { return "", err } |