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

:fix :(docs): changed env PODMAN_BIN to CONTAINER_TOOL #305

Merged
merged 7 commits into from
Aug 12, 2024

Conversation

soham4abc
Copy link
Contributor

This PR changes the environment variable PODMAN_BIN to CONTAINER_TOOL

as kantra falls back to docker if podman is not present, this variable name makes much more sense.

@dagood Please do have a look and provide any necessary feedback for the same.

Closes #168

cmd/settings.go Outdated
@@ -24,7 +24,7 @@ const (

type Config struct {
RootCommandName string `env:"CMD_NAME" default:"kantra"`
PodmanBinary string `env:"PODMAN_BIN" default:"/usr/bin/podman"`
PodmanBinary string `env:"CONTAINER_TOOL" default:"/usr/bin/podman"`
Copy link
Contributor

Choose a reason for hiding this comment

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

My only question here would be whether kantra should keep supporting PODMAN_BIN as an alias of CONTAINER_TOOL for compatibility reasons. (Realized my paragraph about this was unclear in #168, so I've edited it to reword.)

I'm not sure either way. (And to be clear, I'm not a maintainer of the repo.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eemcmullan your views on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's fine to move ahead with CONTAINER_TOOL without supporting PODMAN_BIN. We will then probably want to update instances of the podmanBinary field to something like containerToolBinary, but I don't think that was covered in the issue, and it's not a user-facing var, so I am okay with these changes. Thanks for the contribution!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Welcome @eemcmullan do let me know if further changes are required before merging!!

Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering if during the loading, if PODMAN_BIN is set in line 57 below we could use that.

@eemcmullan won't a user set this env var to use docker if they want?

cmd/settings.go Outdated
@@ -24,7 +24,7 @@ const (

type Config struct {
RootCommandName string `env:"CMD_NAME" default:"kantra"`
PodmanBinary string `env:"PODMAN_BIN" default:"/usr/bin/podman"`
PodmanBinary string `env:"CONTAINER_TOOL" default:"/usr/bin/podman"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's fine to move ahead with CONTAINER_TOOL without supporting PODMAN_BIN. We will then probably want to update instances of the podmanBinary field to something like containerToolBinary, but I don't think that was covered in the issue, and it's not a user-facing var, so I am okay with these changes. Thanks for the contribution!

@eemcmullan
Copy link
Collaborator

@soham4abc apologies for the confusion. After discussing with @shawn-hurley we think it's best to support PODMAN_BIN for a while longer. Can we first check for this var? If CONTAINER_TOOL is also set, we will want to use that instead.

@soham4abc
Copy link
Contributor Author

@soham4abc apologies for the confusion. After discussing with @shawn-hurley we think it's best to support PODMAN_BIN for a while longer. Can we first check for this var? If CONTAINER_TOOL is also set, we will want to use that instead.

Sure... Do you want me to revert the changes to ```PODMAN_BIN?

@eemcmullan
Copy link
Collaborator

@soham4abc We still want to move forward with CONTAINER_TOOL. But for the sake of compatibility, we should probably check for PODMAN_BIN and CONTAINER_TOOL together. If both are set, use CONTAINER_TOOL. If only one or the other, use that.

@soham4abc
Copy link
Contributor Author

@soham4abc We still want to move forward with CONTAINER_TOOL. But for the sake of compatibility, we should probably check for PODMAN_BIN and CONTAINER_TOOL together. If both are set, use CONTAINER_TOOL. If only one or the other, use that.

hey @eemcmullan I have made the changes can you please have a look and test on your end!

@@ -24,6 +24,7 @@ const (

type Config struct {
RootCommandName string `env:"CMD_NAME" default:"kantra"`
ContainerBinary string `env:"CONTAINER_TOOL" default:"/usr/bin/podman"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

CI is failing because this field will need to also be updated where it is being accessed in the rest of the project. This will be where the different commands run. Please let me know if you have any questions on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, Any particular directory this should be pointing to as default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of the latest changes I removed the default path.

@soham4abc
Copy link
Contributor Author

@eemcmullan can you please have a look and run the CI tests?

cmd/settings.go Outdated
// Respect existing PODMAN_BIN setting.
if os.Getenv("PODMAN_BIN") != "" {
// Respect existing CONTAINER_TOOL setting.
if os.Getenv("CONTAINER_TOOL") != "" || os.Getenv("PODMAN_BIN") != "" {
Copy link
Collaborator

@eemcmullan eemcmullan Aug 7, 2024

Choose a reason for hiding this comment

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

I think the check should first look for CONTAINER_TOOL, and then PODMAN_BIN after, only if the former is empty, so CONTAINER_TOOL takes priority.

For the Config struct, we do not need PodmanBinary any longer - just ContainerBinary. This field is used throughout the rest of the project to start the different commands, as the commands run in containers. For example, an analyze command will look something like /usr/bin/podman run --entrypoint <analyzer_bin>.... <image>... where /usr/bin/podman is set from this config struct. You can see an example of this here: https://github.com/konveyor/kantra/blob/main/cmd/analyze.go#L1476

Once these commands are updated with the new struct field name, they should be able to run, and the CI testing should pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot for the review @eemcmullan. I have pushed the recent changes!

@soham4abc soham4abc requested a review from eemcmullan August 7, 2024 23:34
@soham4abc
Copy link
Contributor Author

@shawn-hurley can you please have a look at the changes and provide your reviews?

Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

One minor nit

Two environment variables control the container runtime and the kantra image: `PODMAN_BIN` and `RUNNER_IMG`:
- `PODMAN_BIN`: path to your container runtime (podman or docker)
Two environment variables control the container runtime and the kantra image: `CONTAINER_TOOL` and `RUNNER_IMG`:
- `CONTAINER_TOOL`: path to your container runtime (podman or docker)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: container tool not container runtime.

Container Runtimes are actually different things https://kubernetes.io/docs/setup/production-environment/container-runtimes/ and in this case we don't work with most container runtimes we work with a container tool which is IMO something different.

We can fix this on a follow up though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @shawn-hurley!

@eemcmullan do let me know if this PR needs any more changes

@eemcmullan eemcmullan merged commit 9da4a1f into konveyor:main Aug 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename PODMAN_BIN to CONTAINER_TOOL with backward compatibility
4 participants