podman icon indicating copy to clipboard operation
podman copied to clipboard

Fix updating connection when SSH port conflict happens

Open gmpify opened this issue 1 year ago • 1 comments
trafficstars

Does this PR introduce a user-facing change?

Fixed a bug where `podman machine` connection URIs would become wrong after an SSH port conflict happens

What is this?

I have this issue that a rootful machine becomes unaccessible via its connection. I noticed that in those cases, its connection URI becomes outdated, with wrong port information. I also noticed the rootless connection URI becomes rootful.

Reproducing the error in MacOS:

// have no machines at start
$ podman machine init
$ podman machine set --rootful=true
$ podman machine start
$ podman system connection list
Name                         URI                                                         Identity                                                                Default     ReadWrite
podman-machine-default       ssh://[email protected]:50433/run/user/501/podman/podman.sock  /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  false       true
podman-machine-default-root  ssh://[email protected]:50433/run/podman/podman.sock           /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  true        true

$ pkill vfkit
$ podman machine start
Starting machine "podman-machine-default"
WARN[0000] detected port conflict on machine ssh port [50433], reassigning
$ podman system connection list
Name                         URI                                                Identity                                                                Default     ReadWrite
podman-machine-default       ssh://[email protected]:50471/run/podman/podman.sock  /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  false       true
podman-machine-default-root  ssh://[email protected]:50433/run/podman/podman.sock  /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  true        true

With the bug fix of this PR:

// have no machines at start
$ podman machine init
$ podman machine set --rootful=true
$ podman machine start
$ podman system connection list
Name                         URI                                                         Identity                                                                Default     ReadWrite
podman-machine-default       ssh://[email protected]:50485/run/user/501/podman/podman.sock  /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  false       true
podman-machine-default-root  ssh://[email protected]:50485/run/podman/podman.sock           /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  true        true

$ pkill vfkit
$ podman machine start
Starting machine "podman-machine-default"
WARN[0000] detected port conflict on machine ssh port [50485], reassigning
$ podman system connection list
Name                         URI                                                         Identity                                                                Default     ReadWrite
podman-machine-default       ssh://[email protected]:50513/run/user/501/podman/podman.sock  /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  false       true
podman-machine-default-root  ssh://[email protected]:50513/run/podman/podman.sock           /Users/gabrielparreiras/.local/share/containers/podman/machine/machine  true        true

gmpify avatar May 03 '24 12:05 gmpify

Thanks for the review, @Luap99 and @rhatdan. Is this failing test something flaky? Is there anything else I should do here?

gmpify avatar May 08 '24 12:05 gmpify

Yes the test is flaky I can restart it although I wonder if this really should get a proper regression test here. At least on linux we could create a machine, then get the port and run nc -l -p <port> to block the port then start it and see that we got a new port assigned.

Luap99 avatar May 08 '24 12:05 Luap99

Hi @Luap99, I've added a regression test that covers this failure scenario. Thanks for the suggestion on using nc -l -p <port>.

gmpify avatar May 09 '24 12:05 gmpify

Ephemeral COPR build failed. @containers/packit-build please check.

Is there anything more missing here? Can these failing tests be retried? They don't seem related to the changes on the PR. cc @Luap99 @rhatdan

gmpify avatar May 13 '24 09:05 gmpify

Cockpit tests failed for commit ee7f6b77972411b642a09352128da3690eb5d19e. @martinpitt, @jelly, @mvollmer please check.

@gmpify Can you sqaush the commits please and give the first one the same title as the PR, thanks. Sorry should have mentioned it before.

Luap99 avatar May 13 '24 16:05 Luap99

np, just pushed it now

gmpify avatar May 13 '24 17:05 gmpify

Ephemeral COPR build failed. @containers/packit-build please check.

ignore ELN failures

lsm5 avatar May 13 '24 17:05 lsm5

Cockpit tests failed for commit 85da84311c25e1958f363259877bfff892c035a1. @martinpitt, @jelly, @mvollmer please check.

Ephemeral COPR build failed. @containers/packit-build please check.

Cockpit tests failed for commit e7fc2edbe13e3230da1690163f3a9868f27010e0. @martinpitt, @jelly, @mvollmer please check.

Ephemeral COPR build failed. @containers/packit-build please check.

Cockpit tests failed for commit 277312d28209f38825c779c3669b997580b31746. @martinpitt, @jelly, @mvollmer please check.

Cockpit tests failed for commit 1322254468502f005603a72de82ffe4833684ae1. @martinpitt, @jelly, @mvollmer please check.

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gmpify, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openshift-ci[bot] avatar May 14 '24 16:05 openshift-ci[bot]

Is there a workaround for this until the next release is out? I keep running into this when I reboot my system, and I keep having to tear down and completely rebuild my podman/minikube stack each time via podman machine init etc.

finsterdexter avatar May 28 '24 12:05 finsterdexter