diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-01-18 15:42:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 15:42:06 -0500 |
commit | 094b11cbcb528a7d120c31402a1bcd9c82d84938 (patch) | |
tree | 3ce00f13dda775d979a093658f26cea4122646d9 | |
parent | 62212dbf490d736ad06523a92345a480e4972dab (diff) | |
parent | c0e07234631cfcea1d6724c05606964a4d833f39 (diff) | |
download | podman-094b11cbcb528a7d120c31402a1bcd9c82d84938.tar.gz podman-094b11cbcb528a7d120c31402a1bcd9c82d84938.tar.bz2 podman-094b11cbcb528a7d120c31402a1bcd9c82d84938.zip |
Merge pull request #12908 from Luap99/network-conf-dir
rename --cni-config-dir to --network-config-dir
-rw-r--r-- | cmd/podman/root.go | 14 | ||||
-rwxr-xr-x | contrib/cirrus/logformatter | 2 | ||||
-rwxr-xr-x | contrib/cirrus/logformatter.t | 16 | ||||
-rw-r--r-- | docs/source/markdown/podman.1.md | 9 | ||||
-rwxr-xr-x | hack/podman-socat | 2 | ||||
-rw-r--r-- | pkg/bindings/test/common_test.go | 2 | ||||
-rw-r--r-- | pkg/domain/infra/runtime_libpod.go | 2 | ||||
-rw-r--r-- | pkg/specgenutil/util.go | 2 | ||||
-rw-r--r-- | test/apiv2/python/rest_api/fixtures/podman.py | 2 | ||||
-rwxr-xr-x | test/compose/test-compose | 4 | ||||
-rw-r--r-- | test/e2e/common_test.go | 2 | ||||
-rw-r--r-- | test/e2e/libpod_suite_remote_test.go | 2 | ||||
-rw-r--r-- | test/e2e/network_test.go | 20 | ||||
-rw-r--r-- | test/python/docker/__init__.py | 2 |
14 files changed, 57 insertions, 24 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 7989f9cd5..be6eacfc2 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -85,6 +85,14 @@ func init() { ) rootFlags(rootCmd, registry.PodmanConfig()) + + // backwards compat still allow --cni-config-dir + rootCmd.Flags().SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName { + if name == "cni-config-dir" { + name = "network-config-dir" + } + return pflag.NormalizedName(name) + }) rootCmd.SetUsageTemplate(usageTemplate) } @@ -371,9 +379,9 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) { pFlags.StringVar(&cfg.Engine.NetworkCmdPath, networkCmdPathFlagName, cfg.Engine.NetworkCmdPath, "Path to the command for configuring the network") _ = cmd.RegisterFlagCompletionFunc(networkCmdPathFlagName, completion.AutocompleteDefault) - cniConfigDirFlagName := "cni-config-dir" - pFlags.StringVar(&cfg.Network.NetworkConfigDir, cniConfigDirFlagName, cfg.Network.NetworkConfigDir, "Path of the configuration directory for CNI networks") - _ = cmd.RegisterFlagCompletionFunc(cniConfigDirFlagName, completion.AutocompleteDefault) + networkConfigDirFlagName := "network-config-dir" + pFlags.StringVar(&cfg.Network.NetworkConfigDir, networkConfigDirFlagName, cfg.Network.NetworkConfigDir, "Path of the configuration directory for networks") + _ = cmd.RegisterFlagCompletionFunc(networkConfigDirFlagName, completion.AutocompleteDefault) pFlags.StringVar(&cfg.Containers.DefaultMountsFile, "default-mounts-file", cfg.Containers.DefaultMountsFile, "Path to default mounts file") diff --git a/contrib/cirrus/logformatter b/contrib/cirrus/logformatter index 70f119b5b..49ca91399 100755 --- a/contrib/cirrus/logformatter +++ b/contrib/cirrus/logformatter @@ -341,7 +341,7 @@ END_HTML # Highlight the important (non-boilerplate) podman command. $line =~ s/\s+--remote\s+/ /g; # --remote takes no args # Strip out the global podman options, but show them on hover - $line =~ s{(\S+\/podman(-remote)?)((\s+--(root|runroot|runtime|tmpdir|storage-opt|conmon|cgroup-manager|cni-config-dir|storage-driver|events-backend|url) \S+)*)(.*)}{ + $line =~ s{(\S+\/podman(-remote)?)((\s+--(root|runroot|runtime|tmpdir|storage-opt|conmon|cgroup-manager|network-config-dir|storage-driver|events-backend|url) \S+)*)(.*)}{ my ($full_path, $remote, $options, $args) = ($1, $2||'', $3, $6); $options =~ s/^\s+//; diff --git a/contrib/cirrus/logformatter.t b/contrib/cirrus/logformatter.t index d905693ad..a377faa34 100755 --- a/contrib/cirrus/logformatter.t +++ b/contrib/cirrus/logformatter.t @@ -122,17 +122,17 @@ $SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} [+0103s] /var/tmp/go/src/github.com/containers/podman/test/e2e/pod_restart_test.go:18 [+0103s] [It] podman pod restart single empty pod [+0103s] /var/tmp/go/src/github.com/containers/podman/test/e2e/pod_restart_test.go:41 -[+0103s] Running: /var/tmp/go/src/github.com/containers/podman/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --cni-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod create --infra=false --share +[+0103s] Running: /var/tmp/go/src/github.com/containers/podman/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod create --infra=false --share [+0103s] 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 [+0103s] output: 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 -[+0103s] Running: /var/tmp/go/src/github.com/containers/podman/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --cni-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod restart 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 +[+0103s] Running: /var/tmp/go/src/github.com/containers/podman/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod restart 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 [+0103s] Error: no containers in pod 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 have no dependencies, cannot start pod: no such container [+0103s] output: [+0103s] [AfterEach] Podman pod restart [+0103s] /var/tmp/go/src/github.com/containers/podman/test/e2e/pod_restart_test.go:28 -[+0103s] Running: /var/tmp/go/src/github.com/containers/podman/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --cni-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod rm -fa +[+0103s] Running: /var/tmp/go/src/github.com/containers/podman/bin/podman --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs pod rm -fa [+0103s] 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 -[+0104s] Running: /var/tmp/go/src/github.com/containers/libpod/bin/podman-remote --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --cni-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs --remote --url unix:/run/user/12345/podman-xyz.sock pod rm -fa +[+0104s] Running: /var/tmp/go/src/github.com/containers/libpod/bin/podman-remote --storage-opt vfs.imagestore=/tmp/podman/imagecachedir --root /tmp/podman_test553496330/crio --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon --network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file --storage-driver vfs --remote --url unix:/run/user/12345/podman-xyz.sock pod rm -fa [+0104s] 4810be0cfbd42241e349dbe7d50fbc54405cd320a6637c65fd5323f34d64af89 again @@ -183,7 +183,7 @@ $SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon ---cni-config-dir /etc/cni/net.d +--network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file @@ -194,7 +194,7 @@ $SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon ---cni-config-dir /etc/cni/net.d +--network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file @@ -208,7 +208,7 @@ $SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon ---cni-config-dir /etc/cni/net.d +--network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file @@ -220,7 +220,7 @@ $SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP} --runroot /tmp/podman_test553496330/crio-run --runtime /usr/bin/runc --conmon /usr/bin/conmon ---cni-config-dir /etc/cni/net.d +--network-config-dir /etc/cni/net.d --cgroup-manager systemd --tmpdir /tmp/podman_test553496330 --events-backend file diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md index c1a22c0c1..bb8f889f5 100644 --- a/docs/source/markdown/podman.1.md +++ b/docs/source/markdown/podman.1.md @@ -32,8 +32,13 @@ The CGroup manager to use for container cgroups. Supported values are cgroupfs o Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type. Note: CGroup manager is not supported in rootless mode when using CGroups Version V1. -#### **--cni-config-dir** -Path of the configuration directory for CNI networks. (Default: `/etc/cni/net.d`) +#### **--network-config-dir**=*directory* + +Path to the directory where network configuration files are located. +For the CNI backend the default is "/etc/cni/net.d" as root +and "$HOME/.config/cni/net.d" as rootless. +For the netavark backend "/etc/containers/networks" is used as root +and "$graphroot/networks" as rootless. #### **--connection**, **-c** Connection to use for remote podman (Default connection is configured in `containers.conf`) diff --git a/hack/podman-socat b/hack/podman-socat index 6ee6b89d8..28fbb6864 100755 --- a/hack/podman-socat +++ b/hack/podman-socat @@ -95,7 +95,7 @@ EOT PODMAN_ARGS="--storage-driver=vfs \ --root=${TMPDIR}/crio \ --runroot=${TMPDIR}/crio-run \ - --cni-config-dir=$CNI_CONFIG_PATH \ + --network-config-dir=$CNI_CONFIG_PATH \ --cgroup-manager=systemd \ " if [[ -n $VERBOSE ]]; then diff --git a/pkg/bindings/test/common_test.go b/pkg/bindings/test/common_test.go index d1a07598e..f51e5f404 100644 --- a/pkg/bindings/test/common_test.go +++ b/pkg/bindings/test/common_test.go @@ -86,7 +86,7 @@ func (b *bindingTest) runPodman(command []string) *gexec.Session { } val, ok = os.LookupEnv("CNI_CONFIG_DIR") if ok { - cmd = append(cmd, "--cni-config-dir", val) + cmd = append(cmd, "--network-config-dir", val) } val, ok = os.LookupEnv("CONMON") if ok { diff --git a/pkg/domain/infra/runtime_libpod.go b/pkg/domain/infra/runtime_libpod.go index 519af5ab7..f9ceb9305 100644 --- a/pkg/domain/infra/runtime_libpod.go +++ b/pkg/domain/infra/runtime_libpod.go @@ -223,7 +223,7 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo // TODO flag to set libpod static dir? // TODO flag to set libpod tmp dir? - if fs.Changed("cni-config-dir") { + if fs.Changed("network-config-dir") { options = append(options, libpod.WithCNIConfigDir(cfg.Network.NetworkConfigDir)) } if fs.Changed("default-mounts-file") { diff --git a/pkg/specgenutil/util.go b/pkg/specgenutil/util.go index 0a980a576..80d31398b 100644 --- a/pkg/specgenutil/util.go +++ b/pkg/specgenutil/util.go @@ -279,7 +279,7 @@ func CreateExitCommandArgs(storageConfig storageTypes.StoreOptions, config *conf "--log-level", logrus.GetLevel().String(), "--cgroup-manager", config.Engine.CgroupManager, "--tmpdir", config.Engine.TmpDir, - "--cni-config-dir", config.Network.NetworkConfigDir, + "--network-config-dir", config.Network.NetworkConfigDir, "--network-backend", config.Network.NetworkBackend, } if config.Engine.OCIRuntime != "" { diff --git a/test/apiv2/python/rest_api/fixtures/podman.py b/test/apiv2/python/rest_api/fixtures/podman.py index bae04f87d..c700571b9 100644 --- a/test/apiv2/python/rest_api/fixtures/podman.py +++ b/test/apiv2/python/rest_api/fixtures/podman.py @@ -44,7 +44,7 @@ class Podman: os.environ["CNI_CONFIG_PATH"] = os.path.join(self.anchor_directory, "cni", "net.d") os.makedirs(os.environ["CNI_CONFIG_PATH"], exist_ok=True) - self.cmd.append("--cni-config-dir=" + os.environ["CNI_CONFIG_PATH"]) + self.cmd.append("--network-config-dir=" + os.environ["CNI_CONFIG_PATH"]) cni_cfg = os.path.join(os.environ["CNI_CONFIG_PATH"], "87-podman-bridge.conflist") # json decoded and encoded to ensure legal json buf = json.loads( diff --git a/test/compose/test-compose b/test/compose/test-compose index beaf276fd..7c4bf2e91 100755 --- a/test/compose/test-compose +++ b/test/compose/test-compose @@ -220,7 +220,7 @@ function start_service() { --root $WORKDIR/root \ --runroot $WORKDIR/runroot \ --cgroup-manager=systemd \ - --cni-config-dir $WORKDIR/cni \ + --network-config-dir $WORKDIR/cni \ system service \ --time 0 unix://$DOCKER_SOCK \ &> $WORKDIR/server.log & @@ -247,7 +247,7 @@ function podman() { --storage-driver=vfs \ --root $WORKDIR/root \ --runroot $WORKDIR/runroot \ - --cni-config-dir $WORKDIR/cni \ + --network-config-dir $WORKDIR/cni \ "$@") echo -n "$output" >>$WORKDIR/output.log } diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 64f40d2ed..56f050665 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -817,7 +817,7 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents, noCache boo eventsType = "none" } - podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s", + podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --network-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s", debug, p.Root, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager, p.TmpDir, eventsType), " ") if os.Getenv("HOOK_OPTION") != "" { podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) diff --git a/test/e2e/libpod_suite_remote_test.go b/test/e2e/libpod_suite_remote_test.go index 37381a561..4c5e9955f 100644 --- a/test/e2e/libpod_suite_remote_test.go +++ b/test/e2e/libpod_suite_remote_test.go @@ -153,7 +153,7 @@ func (p *PodmanTestIntegration) StopRemoteService() { // MakeOptions assembles all the podman main options func getRemoteOptions(p *PodmanTestIntegration, args []string) []string { - podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s", + podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --network-config-dir %s --cgroup-manager %s", p.Root, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ") if os.Getenv("HOOK_OPTION") != "" { podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION")) diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 877ad37b8..70793fc32 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -38,6 +38,26 @@ var _ = Describe("Podman network", func() { }) + It("podman --cni-config-dir backwards compat", func() { + SkipIfRemote("--cni-config-dir only works locally") + netDir, err := CreateTempDirInTempDir() + Expect(err).ToNot(HaveOccurred()) + defer os.RemoveAll(netDir) + session := podmanTest.Podman([]string{"--cni-config-dir", netDir, "network", "ls", "--noheading"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + // default network always exists + Expect(session.OutputToStringArray()).To(HaveLen(1)) + + // check that the only file in the directory is the network lockfile + dir, err := os.Open(netDir) + Expect(err).ToNot(HaveOccurred()) + names, err := dir.Readdirnames(5) + Expect(err).ToNot(HaveOccurred()) + Expect(names).To(HaveLen(1)) + Expect(names[0]).To(Or(Equal("netavark.lock"), Equal("cni.lock"))) + }) + It("podman network list", func() { name, path := generateNetworkConfig(podmanTest) defer removeConf(path) diff --git a/test/python/docker/__init__.py b/test/python/docker/__init__.py index f75185192..80fc2a133 100644 --- a/test/python/docker/__init__.py +++ b/test/python/docker/__init__.py @@ -57,7 +57,7 @@ class Podman(object): self.anchor_directory, "cni", "net.d" ) os.makedirs(os.environ["CNI_CONFIG_PATH"], exist_ok=True) - self.cmd.append("--cni-config-dir=" + os.environ["CNI_CONFIG_PATH"]) + self.cmd.append("--network-config-dir=" + os.environ["CNI_CONFIG_PATH"]) cni_cfg = os.path.join( os.environ["CNI_CONFIG_PATH"], "87-podman-bridge.conflist" ) |