Skip to content

Commit

Permalink
Merge pull request #24183 from Luap99/info-socket-url
Browse files Browse the repository at this point in the history
server: fix url parsing in info
  • Loading branch information
openshift-merge-bot[bot] authored Oct 7, 2024
2 parents 35768ae + 45df394 commit e71d8a3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ ginkgo-run: .install.ginkgo
$(GINKGO) -vv $(TESTFLAGS) --tags "$(TAGS) remote" $(GINKGOTIMEOUT) --flake-attempts $(GINKGO_FLAKE_ATTEMPTS) \
--trace $(if $(findstring y,$(GINKGO_NO_COLOR)),--no-color,) \
$(if $(findstring y,$(GINKGO_PARALLEL)),-p,) \
$(if $(FOCUS),--focus "$(FOCUS) --silence-skips",) \
$(if $(FOCUS),--focus "$(FOCUS)" --silence-skips,) \
$(if $(FOCUS_FILE),--focus-file "$(FOCUS_FILE)" --silence-skips,) $(GINKGOWHAT)

.PHONY: ginkgo
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/system/service_abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities
if listener == nil {
return errors.New("unexpected fd received from systemd: cannot listen on it")
}
libpodRuntime.SetRemoteURI(listeners[0].Addr().String())
libpodRuntime.SetRemoteURI(listeners[0].Addr().Network() + "://" + listeners[0].Addr().String())
} else {
uri, err := url.Parse(opts.URI)
if err != nil {
Expand Down
14 changes: 6 additions & 8 deletions pkg/domain/infra/abi/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/containers/podman/v5/libpod/define"
"github.com/containers/podman/v5/pkg/domain/entities"
Expand Down Expand Up @@ -48,19 +49,16 @@ func (ic *ContainerEngine) Info(ctx context.Context) (*define.Info, error) {
info.Host.RemoteSocket.Path = uri.Path
}

uri, err := url.Parse(ic.Libpod.RemoteURI())
if err != nil {
return nil, err
}

if uri.Scheme == "unix" {
err := fileutils.Exists(uri.Path)
// check if the unix path exits, if not unix socket we always we assume it exists, i.e. tcp socket
path, found := strings.CutPrefix(info.Host.RemoteSocket.Path, "unix://")
if found {
err := fileutils.Exists(path)
info.Host.RemoteSocket.Exists = err == nil
} else {
info.Host.RemoteSocket.Exists = true
}

return info, err
return info, nil
}

// SystemPrune removes unused data from the system. Pruning pods, containers, networks, volumes and images.
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/systemd_activate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ var _ = Describe("Systemd activate", func() {
return testUtils.SystemExec(podmanTest.PodmanBinary, args)
}

// regression check for https://github.com/containers/podman/issues/24152
session := podmanRemote("info", "--format", "{{.Host.RemoteSocket.Path}}--{{.Host.RemoteSocket.Exists}}")
Expect(session).Should(testUtils.ExitCleanly())
Expect(session.OutputToString()).To(Equal("tcp://" + addr + "--true"))

containerName := "top_" + testUtils.RandomString(8)
apiSession := podmanRemote(
"create", "--tty", "--name", containerName, "--entrypoint", "top",
Expand Down

1 comment on commit e71d8a3

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.