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

[WFMP-183] Check if podman exists and use that first, otherwise u… #286

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

jamezp
Copy link
Member

@jamezp jamezp commented Feb 7, 2023

@jmesnil jmesnil changed the title ** [WFARQ-???] Check if podman exists and use that first, otherwise u… ** [WFMP-???] Check if podman exists and use that first, otherwise u… Feb 7, 2023
@vsalbaba
Copy link

vsalbaba commented Feb 7, 2023

It would be even better if the actual executable name could be provided as a parameter on the command line, however, I consider this to be better than the current state.

@jamezp
Copy link
Member Author

jamezp commented Feb 7, 2023

It would be even better if the actual executable name could be provided as a parameter on the command line, however, I consider this to be better than the current state.

I think we could do something like System.getProperty("wildfly.image.dockerBinary"). I'm not sure that would honor anything defined in the <properties/> section of a POM. The standard properties do not work for complex configuration types in maven.

@jamezp jamezp force-pushed the podman-docker branch 3 times, most recently from 0423384 to e701789 Compare February 7, 2023 14:21
@vsalbaba
Copy link

vsalbaba commented Feb 8, 2023

There should also be updates to the documentation, in many places it implies that docker is the binary that will be used

https://github.com/wildfly/wildfly-maven-plugin/search?q=docker

@jmesnil
Copy link
Member

jmesnil commented Feb 8, 2023

@vsalbaba what would be the name to use to categorise both docker and podman?

@jamezp
Copy link
Member Author

jamezp commented Feb 9, 2023

We can't change the <dockerBinary/> without breaking compatibility. I do see some documentation that should be updated, but I don't think we should change the configuration parameters.

@vsalbaba
Copy link

vsalbaba commented Feb 9, 2023

I would go with "container engine".
Example:

The operations related to the image are executing using a docker binary container engine. By default, it uses docker but it is possible to configure it with the <image><docker-binary> element to use another binary such as podman.

@vsalbaba
Copy link

vsalbaba commented Feb 9, 2023

There is also a hardcoded mention at

@BeforeClass
public static void checkDockerInstallation() {
assumeTrue("Docker is not present in the installation, skipping the tests",
execSilentWithTimeout(Duration.ofMillis(3000),
"docker", "-v"));
}

@jamezp jamezp changed the title ** [WFMP-???] Check if podman exists and use that first, otherwise u… [WFMP-183] Check if podman exists and use that first, otherwise u… Feb 9, 2023
@jamezp
Copy link
Member Author

jamezp commented Feb 9, 2023

There is also a hardcoded mention at

@BeforeClass
public static void checkDockerInstallation() {
assumeTrue("Docker is not present in the installation, skipping the tests",
execSilentWithTimeout(Duration.ofMillis(3000),
"docker", "-v"));
}

Thank you. Just fixed that.

@jamezp jamezp marked this pull request as ready for review February 9, 2023 08:53
@vsalbaba
Copy link

vsalbaba commented Feb 9, 2023

I am considering that changing the default from docker to podman might not be a compatible change, as some users may rely on docker is the default option. To resolve this issue, we can make podman the fallback option and keep docker as the default.

Additionally, I am considering the option of allowing the tests to run with both engines. By using mvn test -Dwildlfy.image.binary=docker, the tests should run with docker, even if podman is installed. Although the magic guess feature is convenient, I would also like to have more control over which engine is used.

@jamezp
Copy link
Member Author

jamezp commented Feb 9, 2023

I am considering that changing the default from docker to podman might not be a compatible change, as some users may rely on docker is the default option. To resolve this issue, we can make podman the fallback option and keep docker as the default.

Additionally, I am considering the option of allowing the tests to run with both engines. By using mvn test -Dwildlfy.image.binary=docker, the tests should run with docker, even if podman is installed. Although the magic guess feature is convenient, I would also like to have more control over which engine is used.

I think this makes sense. I'll update the PR once I get a chance.

Copy link
Member

@jmesnil jmesnil left a comment

Choose a reason for hiding this comment

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

LGTM outside of the name of the sysprop

if (dockerBinary == null) {
try {
if (ExecUtil.execSilentWithTimeout(Duration.ofSeconds(3), "podman", "-v")) {
dockerBinary = "podman";
Copy link
Member

Choose a reason for hiding this comment

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

If we use podman first, maybe we should add a INFO log about the actual used binary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do think we should use docker first, then podman to keep the current behavior. I also think it does likely make sense to log the binary being used so the user knows.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, wait that is already being done :)

getLog().info(format("Building application image %s using %s.", image, this.image.getBinary()));

Copy link
Member

Choose a reason for hiding this comment

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

@jamezp that's a good point. And docker remains the most popular binary to build image.

with the `<image><docker-binary>` element to use another binary such as `podman`.
The operations related to the image are executing using a Docker binary. By default, there is an attempt to determine if
`podman` is installed. If not, `docker` is used. This can be explicitly set with the `<image><docker-binary>` element.
It can also be overridden with the `wildfly.image.dockerBinary` property.
Copy link
Member

Choose a reason for hiding this comment

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

the name of the sys prop is now wildfly.image.binary

*/
protected String dockerBinary = "docker";
private String dockerBinary;
Copy link
Member

@rhusar rhusar Feb 14, 2023

Choose a reason for hiding this comment

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

Let's find better name even for internals, something like containerTool, containerBinary, podBinary, imageTool etc. Ideas?

Copy link
Member Author

Choose a reason for hiding this comment

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

+1, that is what I'm doing. I'm just using binary in the ApplicationImageInfo as it is typically referred to as "image" so "binary" just seemed to make sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW this property cannot be changed as it results in the configuration parameter.

<image>
    <docker-binary>docker</docker-binary>
</image>

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, oh well...

… is insalled first, then revert to using docker.

Signed-off-by: James R. Perkins <jperkins@redhat.com>
@jamezp jamezp merged commit 26b2fef into wildfly:main Feb 16, 2023
@jamezp jamezp deleted the podman-docker branch July 7, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants