Skip to content

Commit

Permalink
Merge pull request #749 from rhatdan/config
Browse files Browse the repository at this point in the history
add some cni plugin paths
  • Loading branch information
openshift-merge-robot authored Sep 1, 2021
2 parents 08184df + 6e42d9e commit d7266bc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
13 changes: 12 additions & 1 deletion docs/containers.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ func (c *NetworkConfig) Validate() error {
}
}

if stringsEq(c.CNIPluginDirs, cniBinDir) {
if stringsEq(c.CNIPluginDirs, DefaultCNIPluginDirs) {
return nil
}

Expand Down
13 changes: 2 additions & 11 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand All @@ -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() {
Expand Down
8 changes: 7 additions & 1 deletion pkg/config/containers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
8 changes: 5 additions & 3 deletions pkg/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down Expand Up @@ -207,7 +209,7 @@ func DefaultConfig() (*Config, error) {
DefaultNetwork: "podman",
DefaultSubnet: DefaultSubnet,
NetworkConfigDir: cniConfig,
CNIPluginDirs: cniBinDir,
CNIPluginDirs: DefaultCNIPluginDirs,
},
Engine: *defaultEngineConfig,
Secrets: defaultSecretConfig(),
Expand Down
6 changes: 2 additions & 4 deletions pkg/config/testdata/containers_default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d7266bc

Please sign in to comment.