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

Feat podman runner #17786

Draft
wants to merge 3 commits into
base: develop2
Choose a base branch
from
Draft

Conversation

dyamon
Copy link

@dyamon dyamon commented Feb 14, 2025

Changelog: (Feature): Add podman runner
Docs: https://github.com/conan-io/docs/pull/XXXX (TBD)

The first commit of the pull request is a plain copy of runner/docker.py into runner/podman.py. This makes the second commit an actual overview of the differences between the two runners.

I'm leaving a couple of comments on the code to highlight some potential issue with this runner. Then, I guess, we can move to tests and documentation.

  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Closes #17743

@CLAassistant
Copy link

CLAassistant commented Feb 14, 2025

CLA assistant check
All committers have signed the CLA.

Comment on lines +110 to +112
self.podman_user_name = self.configfile.run.user or 'root'
self.podman_user_home = f'/{"home/" if self.podman_user_name != "root" else ""}{self.podman_user_name}'
self.abs_podman_path = os.path.join(f'{self.podman_user_home}/conanrunner', os.path.basename(self.abs_host_path)).replace("\\","/")
Copy link
Author

Choose a reason for hiding this comment

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

Here I'm placing the conanrunner folder in the user home. This is slightly different from what is done for the docker runner.

workdir = workdir or self.abs_podman_path
if log:
_podman_info(f'Running in container: "{command}"')
_, exec_output = self.container.exec_run(f"/bin/bash -c '{command}'", stream=True, workdir=workdir, demux=True)
Copy link
Author

Choose a reason for hiding this comment

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

Here, if I add tty=True, no output is returned. Can't really tell why.

Comment on lines +222 to +224
#exit_metadata = self.docker_api.exec_inspect(exec_instance['Id'])
#if exit_metadata['Running'] or exit_metadata['ExitCode'] > 0:
# raise RunnerException(command=command, stdout_log=stdout_log, stderr_log=stderr_log)
Copy link
Author

Choose a reason for hiding this comment

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

There seems to be no way to check for the command exit code while using stream=True.

Comment on lines +185 to +197
_, podman_build_logs = self.podman_client.images.build(
dockerfile=dockerfile_file_path,
path=build_path,
tag=self.image,
buildargs=self.configfile.build.build_args,
cache_from=self.configfile.build.cache_from,
)
for chunk in podman_build_logs:
for line in chunk.decode("utf-8").split('\r\n'):
if line:
stream = json.loads(line).get('stream')
if stream:
ConanOutput().status(stream.strip())
Copy link
Author

Choose a reason for hiding this comment

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

No streaming of the output here. The output of the build command is spit out all at once.

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.

[feature] Podman runner
2 participants