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

Support container provisioner in toolbox #3228

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thrix
Copy link
Collaborator

@thrix thrix commented Sep 19, 2024

For Fedora Silverblue users it is common to run podman via flatpak-spawn --host which runs podman on the host system itself. This requires to pass the toolbox container name when running podman cp to correctly copy stuff from the toolbox container, where tmt is installed to the provisioned container.

Fixes #1020

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

For Fedora Silverblue users it is common to run podman
via `flatpak-spawn --host` which runs podman on the host
system itself. This requires to pass the toolbox container
name when running `podman cp` to correctly copy stuff
from the toolbox container, where `tmt` is installed
to the provisioned container.

Fixes #1020

Signed-off-by: Miroslav Vadkerti <[email protected]>
@thrix
Copy link
Collaborator Author

thrix commented Sep 19, 2024

@jkonecny12 this is the change I talked about, with it tmt container provisioner works well :)

if line.startswith('name="'):
return line[6:-1]

return None
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two look like they belong to guest facts, as they are properties of a machine similar to has_selinux or arch, for example. Once moved, you would reach them via self.parent.plan.my_run.runner.facts.*.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks for the pointers

@functools.cached_property
def _is_toolbox(self) -> bool:
""" Return ``True`` if running in toolbox, ``False`` otherwise. """
if os.path.exists('/run/.toolboxenv'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

os.path should be replaced with Path().exists()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

need to remember we use pathlib here :)

@thrix thrix added this to the 1.37 milestone Sep 20, 2024
@janhavlin
Copy link
Collaborator

janhavlin commented Sep 23, 2024

I'm getting this error, any idea? The directory /var/tmp/tmt/run-135/testing-farm/sanity/provision/default-0 exists only in toolbox it seems.

❯ tmt --version
tmt version: 1.37.0.dev20+gce8a3c6e

❯ tmt run -a provision -h container -i fedora:40 plan -n /testing-farm/sanity
/var/tmp/tmt/run-135

/testing-farm/sanity
    discover
        how: fmf
        directory: /var/home/jhavlin/work/tests
        tests: /testing-farm/script
        summary: 1 test selected
    provision
        queued provision.provision task #1: default-0
        
        provision.provision task #1: default-0
        how: container
        image: fedora:40
        fail: Command 'podman pull -q fedora:40' returned 1.
        fail: Command 'podman pull -q fedora:40' returned 1.
        fail: Command 'podman pull -q fedora:40' returned 1.
        fail: Command 'podman pull -q fedora:40' returned 1.
        fail: Command 'podman pull -q fedora:40' returned 1.
        fail: Retries of 'Pulling 'fedora:40' image' unsuccessful.
    finish
        warn: Nothing to finish, no guests provisioned.

plan failed

The exception was caused by 1 earlier exceptions

Cause number 1:

    provision step failed

    The exception was caused by 1 earlier exceptions

    Cause number 1:

        Retries of 'Pulling 'fedora:40' image' unsuccessful.

        The exception was caused by 5 earlier exceptions

        Cause number 1:

            Command 'podman pull -q fedora:40' returned 1.

            stderr (1/1 lines)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            Portal call failed: Failed to start command: Failed to change to directory “/var/tmp/tmt/run-135/testing-farm/sanity/provision/default-0” (No such file or directory)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

@thrix
Copy link
Collaborator Author

thrix commented Sep 24, 2024

@janhavlin this is something we should document, add this to your environment (I have it in .bashrc):

export TMT_WORKDIR_ROOT=$HOME/.local/share/tmt

@janhavlin
Copy link
Collaborator

Thanks, I got it working!

@thrix thrix modified the milestones: 1.37, 1.38 Oct 1, 2024
@jkonecny12
Copy link

@janhavlin this is something we should document, add this to your environment (I have it in .bashrc):

export TMT_WORKDIR_ROOT=$HOME/.local/share/tmt

Couldn't we have this resolved by default correctly? Requesting users to set somewhere something to make things work seems like an issue generator and unhappy users.

@thrix
Copy link
Collaborator Author

thrix commented Oct 16, 2024

@janhavlin this is something we should document, add this to your environment (I have it in .bashrc):

export TMT_WORKDIR_ROOT=$HOME/.local/share/tmt

Couldn't we have this resolved by default correctly? Requesting users to set somewhere something to make things work seems like an issue generator and unhappy users.

@jkonecny12 I agree it is sad, but we will need to have a discussion with tmt folks :)

@thrix
Copy link
Collaborator Author

thrix commented Oct 17, 2024

So we agreed we will go with this default if we detect running in toolbox :)

@thrix thrix modified the milestones: 1.38, 1.39 Oct 25, 2024
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.

Improve TMT user experience on SilverBlue system
4 participants