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

ceph_orch_host: fix bug when state is 'absent' #128

Merged
merged 1 commit into from Jun 20, 2022
Merged

Conversation

guits
Copy link
Collaborator

@guits guits commented Jun 20, 2022

The module fails when trying to remove an host with a task like
following:

TASK [remove hosts from the cluster] ***********************************************************************************************************************************************************************
task path: /home/guillaume/workspaces/cephadm-ansible/adm-wrapper/site.yml:7
Monday 20 June 2022  20:07:14 +0200 (0:00:00.011)       0:00:00.011 ***********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Error EINVAL: invalid command
fatal: [ceph-node0]: FAILED! => changed=false
  ansible_facts:
    discovered_interpreter_python: /usr/libexec/platform-python
  module_stderr: ''
  module_stdout: |-
    Traceback (most recent call last):
      File "/home/vagrant/.ansible/tmp/ansible-tmp-1655748434.431962-3291840-13512576132347/AnsiballZ_ceph_orch_host.py", line 247, in <module>
        _ansiballz_main()
      File "/home/vagrant/.ansible/tmp/ansible-tmp-1655748434.431962-3291840-13512576132347/AnsiballZ_ceph_orch_host.py", line 237, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/vagrant/.ansible/tmp/ansible-tmp-1655748434.431962-3291840-13512576132347/AnsiballZ_ceph_orch_host.py", line 108, in invoke_module
        runpy.run_module(mod_name='ansible.modules.ceph_orch_host', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_ceph_orch_host_payload_61mfbvvg/ansible_ceph_orch_host_payload.zip/ansible/modules/ceph_orch_host.py", line 255, in <module>
      File "/tmp/ansible_ceph_orch_host_payload_61mfbvvg/ansible_ceph_orch_host_payload.zip/ansible/modules/ceph_orch_host.py", line 240, in main
      File "/tmp/ansible_ceph_orch_host_payload_61mfbvvg/ansible_ceph_orch_host_payload.zip/ansible/modules/ceph_orch_host.py", line 147, in update_host
    RuntimeError: Inferring fsid 4217f198-b8b7-11eb-941d-5254004b7a69
    Using recent ceph image quay.ceph.io/ceph-ci/ceph@sha256:6a4c5a18f7674929cc5e9aac8f038e6834a1a4b0fdecf3a428dbb9183956c057
    /sys/class/net/eth0/type
    /sys/class/net/lo/type
    /sys/class/net/eth1/type
    /sys/class/net/eth2/type
    no valid command found; 10 closest matches:
    orch host add <hostname> [<addr>] [<labels>...] [--maintenance]
    orch host rm <hostname> [--force] [--offline]
    orch host drain <hostname> [--force]
    orch host set-addr <hostname> <addr>
    orch host ls [--format {plain|json|json-pretty|yaml|xml-pretty|xml}] [--host_pattern <value>] [--label <value>] [--host_status <value>]
    orch host label add <hostname> <label>
    orch host label rm <hostname> <label> [--force]
    orch host ok-to-stop <hostname>
    orch host maintenance enter <hostname> [--force]
    orch host maintenance exit <hostname>
    Error EINVAL: invalid command
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

This is because the value in variable state is reused but the command
ceph orch host doesn't handle 'absent' obviously.

Signed-off-by: Guillaume Abrioux gabrioux@redhat.com

The module fails when trying to remove an host with a task like
following:
```
TASK [remove hosts from the cluster] ***********************************************************************************************************************************************************************
task path: /home/guillaume/workspaces/cephadm-ansible/adm-wrapper/site.yml:7
Monday 20 June 2022  20:07:14 +0200 (0:00:00.011)       0:00:00.011 ***********
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Error EINVAL: invalid command
fatal: [ceph-node0]: FAILED! => changed=false
  ansible_facts:
    discovered_interpreter_python: /usr/libexec/platform-python
  module_stderr: ''
  module_stdout: |-
    Traceback (most recent call last):
      File "/home/vagrant/.ansible/tmp/ansible-tmp-1655748434.431962-3291840-13512576132347/AnsiballZ_ceph_orch_host.py", line 247, in <module>
        _ansiballz_main()
      File "/home/vagrant/.ansible/tmp/ansible-tmp-1655748434.431962-3291840-13512576132347/AnsiballZ_ceph_orch_host.py", line 237, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/vagrant/.ansible/tmp/ansible-tmp-1655748434.431962-3291840-13512576132347/AnsiballZ_ceph_orch_host.py", line 108, in invoke_module
        runpy.run_module(mod_name='ansible.modules.ceph_orch_host', init_globals=None, run_name='__main__', alter_sys=True)
      File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
        mod_name, mod_spec, pkg_name, script_name)
      File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/tmp/ansible_ceph_orch_host_payload_61mfbvvg/ansible_ceph_orch_host_payload.zip/ansible/modules/ceph_orch_host.py", line 255, in <module>
      File "/tmp/ansible_ceph_orch_host_payload_61mfbvvg/ansible_ceph_orch_host_payload.zip/ansible/modules/ceph_orch_host.py", line 240, in main
      File "/tmp/ansible_ceph_orch_host_payload_61mfbvvg/ansible_ceph_orch_host_payload.zip/ansible/modules/ceph_orch_host.py", line 147, in update_host
    RuntimeError: Inferring fsid 4217f198-b8b7-11eb-941d-5254004b7a69
    Using recent ceph image quay.ceph.io/ceph-ci/ceph@sha256:6a4c5a18f7674929cc5e9aac8f038e6834a1a4b0fdecf3a428dbb9183956c057
    /sys/class/net/eth0/type
    /sys/class/net/lo/type
    /sys/class/net/eth1/type
    /sys/class/net/eth2/type
    no valid command found; 10 closest matches:
    orch host add <hostname> [<addr>] [<labels>...] [--maintenance]
    orch host rm <hostname> [--force] [--offline]
    orch host drain <hostname> [--force]
    orch host set-addr <hostname> <addr>
    orch host ls [--format {plain|json|json-pretty|yaml|xml-pretty|xml}] [--host_pattern <value>] [--label <value>] [--host_status <value>]
    orch host label add <hostname> <label>
    orch host label rm <hostname> <label> [--force]
    orch host ok-to-stop <hostname>
    orch host maintenance enter <hostname> [--force]
    orch host maintenance exit <hostname>
    Error EINVAL: invalid command
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1
```

This is because the value in variable `state` is reused but the command
`ceph orch host` doesn't handle 'absent' obviously.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
@guits guits added backport-quincy backport quincy backport-pacific backport pacific labels Jun 20, 2022
@guits guits merged commit d165f5a into devel Jun 20, 2022
8 checks passed
@guits guits deleted the fix-orch-host-rm branch June 20, 2022 18:56
guits added a commit that referenced this pull request Jun 21, 2022
ceph_orch_host: fix bug when state is 'absent' (backport #128)
guits added a commit that referenced this pull request Jun 21, 2022
ceph_orch_host: fix bug when state is 'absent' (backport #128)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-pacific backport pacific backport-quincy backport quincy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant