Repository: avocado-framework/avocado

Issue:
Podman spawner fails to copy file (avocado egg) to container
**Describe the bug**
The Podman spawner fails to copy file (avocado egg) to a container.

**Steps to reproduce**
```avocado run --nrunner-spawner=podman /bin/true```

**Expected behavior**
A normal execution from the container with Avocado installed as an egg.

**Current behavior**
```JOB ID     : 534fb24887f0ee08f4768994e60b635b88cc7b7f
JOB LOG    : /home/cleber/avocado/job-results/job-2021-12-20T14.21-534fb24/job.log

Avocado crashed: PodmanException: Failed copying data to container False
Traceback (most recent call last):

  File "/home/cleber/src/avocado/avocado/avocado/utils/podman.py", line 88, in copy_to_container
    return await self.execute("cp", src, f"{container_id}:{dst}")

  File "/home/cleber/src/avocado/avocado/avocado/utils/podman.py", line 71, in execute
    raise PodmanException(msg)

avocado.utils.podman.PodmanException: Could not execute the command: 125:b'Error: container "False" does not exist\n'.


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/home/cleber/src/avocado/avocado/avocado/core/job.py", line 636, in run_tests
    summary |= suite.run(self)

  File "/home/cleber/src/avocado/avocado/avocado/core/suite.py", line 338, in run
    return self.runner.run_suite(job, self)

  File "/home/cleber/src/avocado/avocado/avocado/plugins/runner_nrunner.py", line 377, in run_suite
    loop.run_until_complete(asyncio.wait_for(asyncio.gather(*workers),

  File "/usr/lib64/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()

  File "/usr/lib64/python3.10/asyncio/tasks.py", line 408, in wait_for
    return await fut

  File "/home/cleber/src/avocado/avocado/avocado/core/task/statemachine.py", line 299, in run
    await self.start()

  File "/home/cleber/src/avocado/avocado/avocado/core/task/statemachine.py", line 252, in start
    start_ok = await self._spawner.spawn_task(runtime_task)

  File "/home/cleber/src/avocado/avocado/avocado/plugins/spawners/podman.py", line 221, in spawn_task
    await self.deploy_avocado(container_id)

  File "/home/cleber/src/avocado/avocado/avocado/plugins/spawners/podman.py", line 144, in deploy_avocado
    await self.podman.copy_to_container(where, egg, to)

  File "/home/cleber/src/avocado/avocado/avocado/utils/podman.py", line 91, in copy_to_container
    raise PodmanException(error) from ex

avocado.utils.podman.PodmanException: Failed copying data to container False

Please include the traceback info and command line used on your bug report
Report bugs visiting https://github.com/avocado-framework/avocado/issues/new
```

**System information (please complete the following information):**
 - OS: `LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: Fedora
Description:    Fedora release 35 (Thirty Five)
Release:        35
Codename:       ThirtyFive```
 - Avocado version: 94.0
 - Avocado installation method: git




Discussion:

Resolving patch:
diff --git a/avocado/plugins/spawners/podman.py b/avocado/plugins/spawners/podman.py
--- a/avocado/plugins/spawners/podman.py
+++ b/avocado/plugins/spawners/podman.py
@@ -176,7 +176,8 @@ async def _create_container_for_task(self, runtime_task, env_args,
         output_opts = ()
         if test_output:
             podman_output = runtime_task.task.runnable.output_dir
-            output_opts = ("-v", "%s:%s" % (test_output, podman_output))
+            output_opts = ("-v", "%s:%s" % (test_output,
+                                            os.path.expanduser(podman_output)))
 
         image = self.config.get('spawner.podman.image')
 
diff --git a/avocado/utils/podman.py b/avocado/utils/podman.py
--- a/avocado/utils/podman.py
+++ b/avocado/utils/podman.py
@@ -49,7 +49,8 @@ async def execute(self, *args):
         :rtype: tuple with returncode, stdout and stderr.
         """
         try:
-            LOG.debug("Executing %s", args[0])
+            LOG.debug("Executing %s", args)
+
             proc = await create_subprocess_exec(self.podman_bin,
                                                 *args,
                                                 stdout=subprocess.PIPE,
@@ -88,6 +89,7 @@ async def copy_to_container(self, container_id, src, dst):
             return await self.execute("cp", src, f"{container_id}:{dst}")
         except PodmanException as ex:
             error = f"Failed copying data to container {container_id}"
+            LOG.error(error)
             raise PodmanException(error) from ex
 
     async def get_python_version(self, image):


Test patch: