add some cni plugin paths

add some possible paths for the cni plugin to be stored

Replaces: containers/common#728

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
unknowndevQwQ 2021-08-14 14:02:55 +08:00 committed by Daniel J Walsh
parent aff2c4e55c
commit 43bd1ced8a
6 changed files with 29 additions and 21 deletions

View File

@ -279,10 +279,21 @@ Options are:
The `network` table contains settings pertaining to the management of CNI
plugins.
**cni_plugin_dirs**=["/opt/cni/bin/",]
**cni_plugin_dirs**=[]
List of paths to directories where CNI plugin binaries are located.
The default list is:
```
cni_plugin_dirs = [
"/usr/local/libexec/cni",
"/usr/libexec/cni",
"/usr/local/lib/cni",
"/usr/lib/cni",
"/opt/cni/bin",
]
```
**default_network**="podman"
The network name of the default CNI network to attach pods to.

View File

@ -778,7 +778,7 @@ func (c *NetworkConfig) Validate() error {
}
}
if stringsEq(c.CNIPluginDirs, cniBinDir) {
if stringsEq(c.CNIPluginDirs, DefaultCNIPluginDirs) {
return nil
}

View File

@ -155,9 +155,7 @@ var _ = Describe("Config", func() {
pluginDirs := []string{
"/usr/libexec/cni",
"/usr/lib/cni",
"/usr/local/lib/cni",
"/opt/cni/bin",
"/usr/libexec/foo",
}
envs := []string{
@ -262,13 +260,6 @@ var _ = Describe("Config", func() {
},
}
pluginDirs := []string{
"/usr/libexec/cni",
"/usr/lib/cni",
"/usr/local/lib/cni",
"/opt/cni/bin",
}
envs := []string{
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm",
@ -290,7 +281,7 @@ var _ = Describe("Config", func() {
gomega.Expect(config.Containers.ApparmorProfile).To(gomega.Equal(apparmor.Profile))
gomega.Expect(config.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
gomega.Expect(config.Containers.Env).To(gomega.BeEquivalentTo(envs))
gomega.Expect(config.Network.CNIPluginDirs).To(gomega.Equal(pluginDirs))
gomega.Expect(config.Network.CNIPluginDirs).To(gomega.Equal(DefaultCNIPluginDirs))
gomega.Expect(config.Engine.NumLocks).To(gomega.BeEquivalentTo(2048))
gomega.Expect(config.Engine.OCIRuntimes["runc"]).To(gomega.Equal(OCIRuntimeMap["runc"]))
if useSystemd() {

View File

@ -262,7 +262,13 @@ default_sysctls = [
# Path to directory where CNI plugin binaries are located.
#
#cni_plugin_dirs = ["/usr/libexec/cni"]
#cni_plugin_dirs = [
# "/usr/local/libexec/cni",
# "/usr/libexec/cni",
# "/usr/local/lib/cni",
# "/usr/lib/cni",
# "/opt/cni/bin",
#]
# The network name of the default CNI network to attach pods to.
#

View File

@ -76,10 +76,12 @@ var (
"CAP_SYS_CHROOT",
}
cniBinDir = []string{
// It may seem a bit unconventional, but it is necessary to do so
DefaultCNIPluginDirs = []string{
"/usr/local/libexec/cni",
"/usr/libexec/cni",
"/usr/lib/cni",
"/usr/local/lib/cni",
"/usr/lib/cni",
"/opt/cni/bin",
}
@ -207,7 +209,7 @@ func DefaultConfig() (*Config, error) {
DefaultNetwork: "podman",
DefaultSubnet: DefaultSubnet,
NetworkConfigDir: cniConfig,
CNIPluginDirs: cniBinDir,
CNIPluginDirs: DefaultCNIPluginDirs,
},
Engine: *defaultEngineConfig,
Secrets: defaultSecretConfig(),

View File

@ -99,10 +99,8 @@ rootless_networking = "cni"
# Path to directory where CNI plugin binaries are located.
cni_plugin_dirs = [
"/usr/libexec/cni",
"/usr/lib/cni",
"/usr/local/lib/cni",
"/opt/cni/bin",
"/usr/libexec/cni",
"/usr/libexec/foo",
]
# Path to the directory where CNI configuration files are located.