Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --host and -H as equivalent options to --url #14947

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Jul 15, 2022

Docker supports -H and --host for specify the listening socket. Podman
should support them also in order to match the CLI.

These will not be documented since Podman defaults to using the
--connection option.

Signed-off-by: Daniel J Walsh [email protected]

Does this PR introduce a user-facing change?

Yes

podman now supports the -H and --host options as equivalent to --url, for Docker compatibility.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2022
@rhatdan
Copy link
Member Author

rhatdan commented Jul 15, 2022

@Luap99 PTAL

@rhatdan
Copy link
Member Author

rhatdan commented Jul 15, 2022

Addresses: #14917

@Luap99
Copy link
Member

Luap99 commented Jul 15, 2022

--connection accepts a name not a url, I think docker --host needs a full url so this should map to --url

@rhatdan rhatdan changed the title Add --host and -H as equivalent options to --connection Add --host and -H as equivalent options to --url Jul 15, 2022
@rhatdan
Copy link
Member Author

rhatdan commented Jul 15, 2022

@Luap99 Your right, thanks.

@rhatdan rhatdan force-pushed the root branch 2 times, most recently from 72dab61 to 53a2b8f Compare July 16, 2022 10:34
systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0
wait_for_port 127.0.0.1 $port

# Start a long-running container.
Copy link
Member

Choose a reason for hiding this comment

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

The comment is confusing as the containers are short lived.

@edsantiago
Copy link
Member

edsantiago commented Jul 18, 2022

APIv2 failure is the deadlock bug (#14929). I'd restart it, except, I think there's something still broken because tests fail on my laptop when I run them manually:

Error: unknown flag: --H

I'll assume that should be a trivial one for you to fix (remove one of the dashes).

What would you think of adding:

diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index 3afd760c3..8e6c7dadc 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -414,6 +414,10 @@ EOF
     run_podman --H $URL run --rm $IMAGE true
 
     systemctl stop $SERVICE_NAME
+
+    # Make sure the option is actually connecting
+    run_podman 125 --host $URL run --rm $IMAGE true
+    assert "$output" =~ "Cannot connect to Podman.*connection refused"
 }
 
 # vim: filetype=sh

@mheon
Copy link
Member

mheon commented Jul 18, 2022

LGTM

Docker supports -H and --host for specify the listening socket. Podman
should support them also in order to match the CLI.

These will not be documented since Podman defaults to using the
--url option.

Signed-off-by: Daniel J Walsh <[email protected]>
Comment on lines +413 to +420
run_podman --host $URL run --rm $IMAGE true
run_podman -H $URL run --rm $IMAGE true

systemctl stop $SERVICE_NAME

# Make sure the option is actually connecting
run_podman 125 --host $URL run --rm $IMAGE true
assert "$output" =~ "Cannot connect to Podman.*connection refused"
Copy link
Member

Choose a reason for hiding this comment

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

Why do we run containers? Could we just call info? That way we can also check for remote.

Copy link
Member Author

Choose a reason for hiding this comment

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

The goal here is to make sure the --host $URL is actually doing something including failing if the socket does not exist.

Copy link
Member

Choose a reason for hiding this comment

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

Yes and info fails without socket.

Copy link
Member Author

Choose a reason for hiding this comment

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

And you think info would be faster? I just used what was suggested by Ed.

Copy link
Member

Choose a reason for hiding this comment

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

I would say yes but it is not really important enough to argue over it. I am ok to merge this.

Copy link
Member

Choose a reason for hiding this comment

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

I just made my suggestion because I didn't think podman info would show the socket. (There's a bug open for that, or maybe it's been fixed, I don't know). Anyway, if podman info shows the socket name, that is a much better solution than running containers.

Copy link
Member

Choose a reason for hiding this comment

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

Hey, the info bug is fixed. Suggestion:

@test "podman-system-service containers --host" {
    skip_if_remote "N/A under podman-remote"

    SERVICE_NAME=podman-service-$(random_string)

    # (Used only in teardown if the test fails)
    touch $UNIT_FILE

    port=$(random_free_port)
    URL=tcp://127.0.0.1:$port

    systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0
    wait_for_port 127.0.0.1 $port

    for opt in --host -H; do
        run_podman $opt $URL info --format '{{.Host.RemoteSocket.Path}}'
        is "$output" "$URL" "RemoteSocket.Path using $opt"
    done

    systemctl stop $SERVICE_NAME
    rm -f $UNIT_FILE
}

This also adds an important cleanup step to prevent leaving the podman server behind on failure.

Copy link
Member

Choose a reason for hiding this comment

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

And yes, I realize that the previous test (from which this was copied) also has a missing cleanup. That's now on my TODO list to fix. Unless you'd like to fix it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Lets get this merged and then fix the test, unless something else fails.

Copy link
Member

Choose a reason for hiding this comment

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

OK, I'll fix it in a cleanup PR later

@edsantiago
Copy link
Member

LGTM but after thinking about it a little, I'm pretty sure this test should not be skipped under podman-remote: that's exactly where this flag is intended.

Unfortunately, making this run under podman-remote is much more complicated than I expected. I will add that to my TODO list.

@rhatdan rhatdan added the lgtm Indicates that a PR is ready to be merged. label Jul 18, 2022
@openshift-ci openshift-ci bot merged commit d890c4d into containers:main Jul 18, 2022
fs.StringVarP(&ignoredConnection, connectionFlagName, "c", "", "")
fs.StringP(connectionFlagName, "c", "", "")
hostFlagName := "host"
fs.StringP(hostFlagName, "H", "", "")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of having an upper cased single character option when most (all?) of our others are lower case. But Docker compatibility, ugh.

Copy link
Member

Choose a reason for hiding this comment

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

I assume that -h had already been taken by --help.

@rhatdan rhatdan deleted the root branch December 1, 2022 22:01
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants