Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

Systemd param fail with Error: chdir: No such file or directory: OCI ... #78

Closed
0b11stan opened this issue Aug 29, 2021 · 4 comments
Closed

Comments

@0b11stan
Copy link
Contributor

Hi, when putting myself on the git branch to try and resolve this issue I came over a new little bug. Using systemd: true results in a failure of the asynchronous creation task for a container.

Versions

molecule 3.4.0 using python 3.9
    ansible:2.11.4
    delegated:3.4.0 from molecule
    podman:1.0.0a2 from molecule_podman requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0

How to reproduce

python -m venv venv
source venv/bin/activate
pip install 'molecule[lint]'
pip install git+https://github.com/ansible-community/molecule-podman.git
molecule init role -d podman poc && cd poc
cat > molecule/default/molecule.yml <<EOF
---
dependency:
  name: galaxy
driver:
  name: podman
platforms:
  - name: instance
    image: docker.io/pycontribs/centos:8
    pre_build_image: true
    tty: True
    systemd: true
provisioner:
  name: ansible
verifier:
  name: ansible
EOF
molecule create

What is happening

TASK [Create molecule instance(s)] *********************************************
changed: [localhost] => (item=instance)

TASK [Wait for instance(s) creation to complete] *******************************
failed: [localhost] (item=instance) => {"ansible_job_id": "703631711799.87139", "ansible_loop_var": "item", "attempts": 1, "changed": true, "cmd": ["/usr/bin/podman", "run", "-d", "--name", "instance", "--tty=True", "--hostname=instance", "--systemd=True", "docker.io/pycontribs/centos:8", "bash", "-c", "while true; do sleep 10000; done"], "delta": "0:00:00.155365", "end": "2021-08-29 10:31:19.994517", "finished": 1, "item": {"ansible_job_id": "703631711799.87139", "ansible_loop_var": "item", "changed": true, "failed": false, "finished": 0, "item": {"image": "docker.io/pycontribs/centos:8", "name": "instance", "pre_build_image": true, "systemd": true, "tty": true}, "results_file": "/home/tristan/.ansible_async/703631711799.87139", "started": 1}, "msg": "non-zero return code", "rc": 127, "start": "2021-08-29 10:31:19.839152", "stderr": "Error: chdir: No such file or directory: OCI runtime attempted to invoke a command that was not found", "stderr_lines": ["Error: chdir: No such file or directory: OCI runtime attempted to invoke a command that was not found"], "stdout": "", "stdout_lines": []}

PLAY RECAP *********************************************************************
localhost                  : ok=7    changed=2    unreachable=0    failed=1    skipped=5    rescued=0    ignored=0

What is expected

TASK [Create molecule instance(s)] *********************************************
changed: [localhost] => (item=instance)

TASK [Wait for instance(s) creation to complete] *******************************
FAILED - RETRYING: Wait for instance(s) creation to complete (300 retries left).
changed: [localhost] => (item=instance)

PLAY RECAP *********************************************************************
localhost                  : ok=8    changed=3    unreachable=0    failed=0    skipped=5    rescued=0    ignored=0
@0b11stan
Copy link
Contributor Author

0b11stan commented Aug 29, 2021

I looked at /home/tristan/.ansible_async/703631711799.87139 and the following podman command is, indeed, failing:

/usr/bin/podman run -d --name "instance" --tty=True --hostname=instance --systemd=True docker.io/pycontribs/centos:8 bash -c "while true; do sleep 10000; done"

Then I tried to put --systemd=true instead of --systemd=True and it works just fine !
I don't know why podman refuses the case sensitive systemd when he have no problem with the tty arg but it may need a little fix ?

I know we just have to put systemd: 'true' in the molecule.yml but it would be maybe more user-friendly with a fix like this:

From 3e81eaa2594c251fec1ced41572fa4d4b5ca2d6b Mon Sep 17 00:00:00 2001
From: Tristan Pinaudeau <[email protected]>
Date: Sun, 29 Aug 2021 10:50:20 +0200
Subject: [PATCH] fix: systemd argument takes only lowercase

---
 src/molecule_podman/playbooks/create.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/molecule_podman/playbooks/create.yml b/src/molecule_podman/playbooks/create.yml
index cc79f30..9fb416a 100644
--- a/src/molecule_podman/playbooks/create.yml
+++ b/src/molecule_podman/playbooks/create.yml
@@ -166,7 +166,7 @@
         {% if item.ip is defined %}--ip={{ item.ip }}{% endif %}
         {% if item.etc_hosts is defined %}{% for i,k in item.etc_hosts.items() %}{% if i != item.name %}--add-host {{ i }}:{{ k }} {% endif %}{% endfor %}{% endif %}
         {% if item.hostname is defined %}--hostname={{ item.hostname }}{% elif item.name is defined %}--hostname={{ item.name }}{% endif %}
-        {% if item.systemd is defined %}--systemd={{ item.systemd }}{% endif %}
+        {% if item.systemd is defined %}--systemd={{ item.systemd|lower }}{% endif %}
         {{ item.pre_build_image | default(false) | ternary('', 'molecule_local/') }}{{ item.image }}
         {{ (command_directives_dict | default({}))[item.name] | default('') }}
       register: server
--
2.33.0

@sshnaidm
Copy link
Collaborator

Yes, podman has such kind of errors, btw worth to create an issue in https://github.com/containers/podman about that.
I think item.systemd|string|lower would be more readable. Can you submit a PR please?

@0b11stan
Copy link
Contributor Author

0b11stan commented Sep 1, 2021

Alright, thanks for your comment, I just created the pull request. And here is the podman issue : containers/podman#11387.

@0b11stan
Copy link
Contributor Author

The following is now working correctly:

python -m venv venv
source venv/bin/activate
pip install 'molecule[lint,podman]'
molecule init role -d podman poc && cd poc
cat > molecule/default/molecule.yml <<EOF
---
dependency:
  name: galaxy
driver:
  name: podman
platforms:
  - name: instance
    image: docker.io/pycontribs/centos:8
    pre_build_image: true
    tty: True
    systemd: true
provisioner:
  name: ansible
verifier:
  name: ansible
EOF
molecule create

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants