From 69d737ef15b793d698067a691ca7124b3c2ae952 Mon Sep 17 00:00:00 2001 From: Charlie Doern Date: Tue, 25 Oct 2022 10:37:18 -0400 Subject: [PATCH] fix connection usage with containers.conf --connection was failing due to the servicedestinations array being empty on runtime. Fix by making sure the cached config is used resolves #16282 Signed-off-by: Charlie Doern --- cmd/podman/root.go | 2 ++ test/e2e/system_connection_test.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 7cdc74595b..a5ab58b47d 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -198,6 +198,8 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { if contextConn != nil && contextConn.Changed { return fmt.Errorf("use of --connection and --context at the same time is not allowed") } + // need to give our blank containers.conf all of the service destinations if we are using one. + podmanConfig.ContainersConf.Engine.ServiceDestinations = podmanConfig.ContainersConfDefaultsRO.Engine.ServiceDestinations podmanConfig.ContainersConf.Engine.ActiveService = conn.Value.String() if err := setupConnection(); err != nil { return err diff --git a/test/e2e/system_connection_test.go b/test/e2e/system_connection_test.go index 221f598eb7..3c320778aa 100644 --- a/test/e2e/system_connection_test.go +++ b/test/e2e/system_connection_test.go @@ -276,6 +276,11 @@ var _ = Describe("podman system connection", func() { Expect(session.Out.Contents()).Should(BeEmpty()) Expect(session.Err.Contents()).Should(BeEmpty()) + cmd = exec.Command(podmanTest.RemotePodmanBinary, + "--connection", "QA", "ps") + _, err = Start(cmd, GinkgoWriter, GinkgoWriter) + Expect(err).ToNot(HaveOccurred()) + uri := url.URL{ Scheme: "ssh", User: url.User(u.Username),