Skip to content

Commit 6c544d5

Browse files
committed
common/pkg/config: remove CNI
Signed-off-by: Lokesh Mandvekar <[email protected]>
1 parent 74f39e0 commit 6c544d5

File tree

10 files changed

+7
-171
lines changed

10 files changed

+7
-171
lines changed

common/pkg/config/config.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type Config struct {
4949
Engine EngineConfig `toml:"engine"`
5050
// Machine specifies configurations of podman machine VMs
5151
Machine MachineConfig `toml:"machine"`
52-
// Network section defines the configuration of CNI Plugins
52+
// Network section defines the network configuration
5353
Network NetworkConfig `toml:"network"`
5454
// Secret section defines configurations for the secret management
5555
Secrets SecretConfig `toml:"secrets"`
@@ -586,9 +586,6 @@ type NetworkConfig struct {
586586
// networking.
587587
NetworkBackend string `toml:"network_backend,omitempty"`
588588

589-
// CNIPluginDirs is where CNI plugin binaries are stored.
590-
CNIPluginDirs attributedstring.Slice `toml:"cni_plugin_dirs,omitempty"`
591-
592589
// NetavarkPluginDirs is a list of directories which contain netavark plugins.
593590
NetavarkPluginDirs attributedstring.Slice `toml:"netavark_plugin_dirs,omitempty"`
594591

common/pkg/config/config_local_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,6 @@ var _ = Describe("Config Local", func() {
2727
file.Close()
2828
defer os.Remove(tmpfile)
2929
defConf.Network.NetworkConfigDir = tmpfile
30-
defConf.Network.CNIPluginDirs.Set([]string{})
31-
32-
// When
33-
err = defConf.Network.Validate()
34-
35-
// Then
36-
gomega.Expect(err).ToNot(gomega.HaveOccurred())
37-
})
38-
39-
It("should not fail on invalid CNIPluginDirs", func() {
40-
defConf, err := defaultConfig()
41-
gomega.Expect(err).ToNot(gomega.HaveOccurred())
42-
gomega.Expect(defConf).NotTo(gomega.BeNil())
43-
44-
t := GinkgoT()
45-
validDirPath := t.TempDir()
46-
47-
// Given
48-
defConf.Network.NetworkConfigDir = validDirPath
49-
defConf.Network.CNIPluginDirs.Set([]string{invalidPath})
5030

5131
// When
5232
err = defConf.Network.Validate()
@@ -65,7 +45,6 @@ var _ = Describe("Config Local", func() {
6545

6646
// Given
6747
defConf.Network.NetworkConfigDir = validDirPath
68-
defConf.Network.CNIPluginDirs.Set([]string{validDirPath})
6948

7049
net, _ := types.ParseCIDR("10.0.0.0/24")
7150
defConf.Network.DefaultSubnetPools = []SubnetPool{

common/pkg/config/config_remote_test.go

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,6 @@ import (
88
)
99

1010
var _ = Describe("Config Remote", func() {
11-
It("should succeed on invalid CNIPluginDirs", func() {
12-
t := GinkgoT()
13-
validDirPath := t.TempDir()
14-
15-
// Given
16-
defConf, err := defaultConfig()
17-
gomega.Expect(err).To(gomega.BeNil())
18-
gomega.Expect(defConf).NotTo(gomega.BeNil())
19-
20-
defConf.Network.NetworkConfigDir = validDirPath
21-
defConf.Network.CNIPluginDirs.Set([]string{invalidPath})
22-
23-
// When
24-
err = defConf.Network.Validate()
25-
26-
// Then
27-
gomega.Expect(err).To(gomega.BeNil())
28-
})
29-
3011
It("should succeed on invalid device mode", func() {
3112
// Given
3213
defConf, err := defaultConfig()
@@ -119,40 +100,4 @@ var _ = Describe("Config Remote", func() {
119100
// Then
120101
gomega.Expect(err).To(gomega.BeNil())
121102
})
122-
123-
It("should succeed on invalid CNIPluginDirs", func() {
124-
t := GinkgoT()
125-
validDirPath := t.TempDir()
126-
127-
// Given
128-
defConf, err := defaultConfig()
129-
gomega.Expect(err).To(gomega.BeNil())
130-
gomega.Expect(defConf).NotTo(gomega.BeNil())
131-
defConf.Network.NetworkConfigDir = validDirPath
132-
defConf.Network.CNIPluginDirs.Set([]string{invalidPath})
133-
134-
// When
135-
err = defConf.Network.Validate()
136-
137-
// Then
138-
gomega.Expect(err).To(gomega.BeNil())
139-
})
140-
141-
It("should succeed in validating invalid PluginDir", func() {
142-
t := GinkgoT()
143-
validDirPath := t.TempDir()
144-
145-
// Given
146-
defConf, err := defaultConfig()
147-
gomega.Expect(err).To(gomega.BeNil())
148-
gomega.Expect(defConf).NotTo(gomega.BeNil())
149-
defConf.Network.NetworkConfigDir = validDirPath
150-
defConf.Network.CNIPluginDirs.Set([]string{invalidPath})
151-
152-
// When
153-
err = defConf.Network.Validate()
154-
155-
// Then
156-
gomega.Expect(err).To(gomega.BeNil())
157-
})
158103
})

common/pkg/config/config_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ image_copy_tmp_dir="storage"`
289289
},
290290
}
291291

292-
pluginDirs := []string{
293-
"/usr/libexec/cni",
294-
"/tmp",
295-
}
296-
297292
envs := []string{
298293
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
299294
}
@@ -322,7 +317,6 @@ image_copy_tmp_dir="storage"`
322317
gomega.Expect(defaultConfig.Containers.Env.Get()).To(gomega.BeEquivalentTo(envs))
323318
gomega.Expect(defaultConfig.Containers.Mounts.Get()).To(gomega.BeEquivalentTo(mounts))
324319
gomega.Expect(defaultConfig.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
325-
gomega.Expect(defaultConfig.Network.CNIPluginDirs.Get()).To(gomega.Equal(pluginDirs))
326320
gomega.Expect(defaultConfig.Network.NetavarkPluginDirs.Get()).To(gomega.Equal([]string{"/usr/netavark"}))
327321
gomega.Expect(defaultConfig.Engine.NumLocks).To(gomega.BeEquivalentTo(2048))
328322
gomega.Expect(defaultConfig.Engine.OCIRuntimes).To(gomega.Equal(OCIRuntimeMap))
@@ -452,7 +446,6 @@ image_copy_tmp_dir="storage"`
452446
gomega.Expect(config.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
453447
gomega.Expect(config.Containers.Env.Get()).To(gomega.BeEquivalentTo(envs))
454448
gomega.Expect(config.Containers.UserNS).To(gomega.BeEquivalentTo(""))
455-
gomega.Expect(config.Network.CNIPluginDirs.Get()).To(gomega.Equal(DefaultCNIPluginDirs))
456449
gomega.Expect(config.Network.NetavarkPluginDirs.Get()).To(gomega.Equal(DefaultNetavarkPluginDirs))
457450
gomega.Expect(config.Engine.NumLocks).To(gomega.BeEquivalentTo(2048))
458451
gomega.Expect(config.Engine.OCIRuntimes["runc"]).To(gomega.Equal(OCIRuntimeMap["runc"]))

common/pkg/config/containers.conf

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -354,25 +354,14 @@ default_sysctls = [
354354
[network]
355355

356356
# Network backend determines what network driver will be used to set up and tear down container networks.
357-
# Valid values are "cni" and "netavark".
358-
# The default value is empty which means that it will automatically choose CNI or netavark. If there are
359-
# already containers/images or CNI networks preset it will choose CNI.
357+
# Valid values are "netavark".
358+
# The default value is empty which means that it will automatically choose netavark.
360359
#
361360
# Before changing this value all containers must be stopped otherwise it is likely that
362361
# iptables rules and network interfaces might leak on the host. A reboot will fix this.
363362
#
364363
#network_backend = ""
365364

366-
# Path to directory where CNI plugin binaries are located.
367-
#
368-
#cni_plugin_dirs = [
369-
# "/usr/local/libexec/cni",
370-
# "/usr/libexec/cni",
371-
# "/usr/local/lib/cni",
372-
# "/usr/lib/cni",
373-
# "/opt/cni/bin",
374-
#]
375-
376365
# List of directories that will be searched for netavark plugins.
377366
#
378367
#netavark_plugin_dirs = [
@@ -425,14 +414,6 @@ default_sysctls = [
425414
#
426415
#default_rootless_network_cmd = "pasta"
427416

428-
# Path to the directory where network configuration files are located.
429-
# For the CNI backend the default is "/etc/cni/net.d" as root
430-
# and "$HOME/.config/cni/net.d" as rootless.
431-
# For the netavark backend "/etc/containers/networks" is used as root
432-
# and "$graphroot/networks" as rootless.
433-
#
434-
#network_config_dir = "/etc/cni/net.d/"
435-
436417
# Port to use for dns forwarding daemon with netavark in rootful bridge
437418
# mode and dns enabled.
438419
# Using an alternate port might be useful if other dns services should

common/pkg/config/containers.conf-freebsd

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -271,25 +271,14 @@ default_sysctls = [
271271
[network]
272272

273273
# Network backend determines what network driver will be used to set up and tear down container networks.
274-
# Valid values are "cni" and "netavark".
275-
# The default value is empty which means that it will automatically choose CNI or netavark. If there are
276-
# already containers/images or CNI networks preset it will choose CNI.
274+
# Valid values are "netavark".
275+
# The default value is empty which means that it will automatically choose netavark.
277276
#
278277
# Before changing this value all containers must be stopped otherwise it is likely that
279278
# iptables rules and network interfaces might leak on the host. A reboot will fix this.
280279
#
281280
#network_backend = ""
282281

283-
# Path to directory where CNI plugin binaries are located.
284-
#
285-
#cni_plugin_dirs = [
286-
# "/usr/local/libexec/cni",
287-
# "/usr/libexec/cni",
288-
# "/usr/local/lib/cni",
289-
# "/usr/lib/cni",
290-
# "/opt/cni/bin",
291-
#]
292-
293282
# List of directories that will be searched for netavark plugins.
294283
#
295284
#netavark_plugin_dirs = [
@@ -327,14 +316,6 @@ default_sysctls = [
327316
# {"base" = "10.128.0.0/9", "size" = 24},
328317
#]
329318

330-
# Path to the directory where network configuration files are located.
331-
# For the CNI backend the default is "/etc/cni/net.d" as root
332-
# and "$HOME/.config/cni/net.d" as rootless.
333-
# For the netavark backend "/etc/containers/networks" is used as root
334-
# and "$graphroot/networks" as rootless.
335-
#
336-
#network_config_dir = "/usr/local/etc/cni/net.d/"
337-
338319
[engine]
339320
# Index to the active service
340321
#

common/pkg/config/default.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ var (
117117
"CAP_SYS_CHROOT",
118118
}
119119

120-
// Search these locations in which CNIPlugins can be installed.
121-
DefaultCNIPluginDirs = []string{
122-
"/usr/local/libexec/cni",
123-
"/usr/libexec/cni",
124-
"/usr/local/lib/cni",
125-
"/usr/lib/cni",
126-
"/opt/cni/bin",
127-
}
128120
DefaultNetavarkPluginDirs = []string{
129121
"/usr/local/libexec/netavark",
130122
"/usr/libexec/netavark",
@@ -271,7 +263,6 @@ func defaultConfig() (*Config, error) {
271263
DefaultSubnetPools: DefaultSubnetPools,
272264
DefaultRootlessNetworkCmd: "pasta",
273265
DNSBindPort: 0,
274-
CNIPluginDirs: attributedstring.NewSlice(DefaultCNIPluginDirs),
275266
NetavarkPluginDirs: attributedstring.NewSlice(DefaultNetavarkPluginDirs),
276267
},
277268
Engine: *defaultEngineConfig,

common/pkg/config/testdata/containers_comment.conf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,6 @@
9696
# Pattern of interface name inside container.
9797
# interface_name = ""
9898

99-
100-
# The network table containers settings pertaining to the management of
101-
# CNI plugins.
102-
[network]
103-
104-
# Path to the directory where CNI configuration files are located.
105-
# network_config_dir = "/etc/cni/net.d/"
106-
107-
# Path to directory where CNI plugin binaries are located.
108-
# cni_plugin_dirs = "/usr/libexec/cni"
109-
110-
11199
[engine]
112100

113101
# Cgroup management implementation used for the runtime.

common/pkg/config/testdata/containers_default.conf

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,10 @@ umask="0002"
111111
# default network mode
112112
netns="bridge"
113113

114-
# The network table containers settings pertaining to the management of
115-
# CNI plugins.
114+
# The network table contains settings pertaining to the management of
115+
# netavark and pasta.
116116
[network]
117117

118-
# Path to directory where CNI plugin binaries are located.
119-
cni_plugin_dirs = [
120-
"/usr/libexec/cni",
121-
"/tmp",
122-
]
123-
124-
# Path to the directory where CNI configuration files are located.
125-
network_config_dir = "/etc/cni/net.d/"
126-
127118
default_subnet_pools = [{"base" = "10.89.0.0/16", "size" = 24}, {"base" = "10.90.0.0/15", "size" = 24}]
128119

129120
# firewall driver to be used by default

common/pkg/config/testdata/containers_invalid.conf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,6 @@ shm_size = "-5536k"
8383
init = false
8484

8585

86-
# The network table containers settings pertaining to the management of
87-
# CNI plugins.
88-
[network]
89-
90-
# Path to directory where CNI plugin binaries are located.
91-
cni_plugin_dirs = ["/usr/libexec/cni"]
92-
93-
# Path to the directory where CNI configuration files are located.
94-
network_config_dir = "/etc/cni/net.d/"
95-
9686
[engine]
9787

9888
# Cgroup management implementation used for the runtime.

0 commit comments

Comments
 (0)