Command Collection Error: `mdadm -D /dev/md*`
JoySnow opened this issue · 0 comments
JoySnow commented
Spec mdadm_D = simple_command("/usr/sbin/mdadm -D /dev/md*")
from specs/default.py
The command collection returns the following error message:
# cat insights-xiaoxwan-test321-rhel91.default-20240204124004/meta_data/insights.specs.Specs.mdadm_D.json
{"name": "insights.specs.Specs.mdadm_D", "exec_time": 0.00016999244689941406, "errors": ["Traceback (most recent call last):\n File \"/root/Work/insights-core/insights/core/serde.py\", line 102, in call_serializer\n return func(value), None\n File \"/root/Work/insights-core/insights/core/serde.py\", line 87, in serialize\n \"object\": to_dict(obj, root=root),\n File \"/root/Work/insights-core/insights/core/spec_factory.py\", line 1252, in serialize_command_output\n rc = obj.write(dst)\n File \"/root/Work/insights-core/insights/core/spec_factory.py\", line 432, in write\n return p.write(dst, keep_rc=self.keep_rc)\n File \"/root/Work/insights-core/insights/util/subproc.py\", line 126, in write\n six.reraise(be.__class__, be, sys.exc_info()[2])\n File \"/root/Work/insights-core/venv39/lib64/python3.9/site-packages/six.py\", line 719, in reraise\n raise value\n File \"/root/Work/insights-core/insights/util/subproc.py\", line 122, in write\n raise CalledProcessError(rc, self.cmds[0], \"\")\ninsights.core.exceptions.CalledProcessError: (1, ['timeout', '-s', '9', '10', '/usr/sbin/mdadm', '-D', '/dev/md*'], '')\n"], "results": null, "ser_time": 0.011901617050170898}
Test to run command directly with Popen
:
>>> from subprocess import Popen
>>> cmd = ['/usr/sbin/mdadm', '-D', '/dev/md*'] # <---- '/dev/md*' : not work
>>> p = Popen(cmd)
>>> mdadm: cannot open /dev/md*: No such file or directory # <----------- the Root-Cause
>>> cmd = ['/bin/systemctl', 'show', '*.service'] # <---- '*.service' : run as expected
>>> p = Popen(cmd)
Type=simple
ExitType=main
...
Consider to glob extend this /dev/md*'
arg first, then pass the real file paths to the command.