canonical/microk8s-core-addons

Mayastor 2 installed - cannot create pools using helper scripts - error: "TypeError: fork_exec() takes exactly 21 arguments (17 given)"

RachelAmbler opened this issue · 5 comments

Summary

Executed microk8s mayastor-pools add --node kcp01.test.local --device /dev/sdb --size 10GB

Received the following stack trace:

Traceback (most recent call last):
  File "/var/snap/microk8s/common/plugins/mayastor-pools", line 146, in <module>
    pools.main()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/var/snap/microk8s/common/plugins/mayastor-pools", line 92, in add
    subprocess.run([KUBECTL, "apply", "-f", "-"], input=format_pool(node, dev))
  File "/snap/microk8s/5372/usr/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/snap/microk8s/5372/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/snap/microk8s/5372/usr/lib/python3.8/subprocess.py", line 1639, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: fork_exec() takes exactly 21 arguments (17 given)

What Should Happen Instead?

Disk pool should be created with no errors!

Reproduction Steps

As above

More information

I was running microk8s 1.26 and upgraded to 1.27, however apparently this upgrade does not seem to upgrade any admins, so I cloned this 1.27 core admins repo and replaced the mayastor addon scripts with the newer versions. This fixed my initial issues I was having with mayastor but now I'm unable to use the helper scripts.

Are you interested in contributing with a fix?

Sorry, I'm not a Pythonista!

Hi @RachelAmbler, looks like the script is loading the click module from the host OS instead of the one inside the snap (based on the traceback)

Traceback (most recent call last):
  File "/var/snap/microk8s/common/plugins/mayastor-pools", line 146, in <module>
    pools.main()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/var/snap/microk8s/common/plugins/mayastor-pools", line 92, in add
    subprocess.run([KUBECTL, "apply", "-f", "-"], input=format_pool(node, dev))

This looks like a bug due to the way we setup Python's PATH. As a quick workaround, can you test if the following helps you?

export PYTHONPATH=/snap/microk8s/current/usr/lib/python3.8:/snap/microk8s/current/lib/python3.8/site-packages:/snap/microk8s/current/usr/lib/python3/dist-packages

microk8s mayastor-pools add --node kcp01.test.local --device /dev/sdb --size 10GB

Finally, can you share the output of:

python3 --version
cat /etc/os-release

Thank you!

export PYTHONPATH=/snap/microk8s/current/usr/lib/python3.8:/snap/microk8s/current/lib/python3.8/site-packages:/snap/microk8s/current/usr/lib/python3/dist-packages

microk8s mayastor-pools add --node kcp01.test.local --device /dev/sdb --size 10GB`

Yields

Traceback (most recent call last):
  File "/var/snap/microk8s/common/plugins/mayastor-pools", line 146, in <module>
    pools.main()
  File "/snap/microk8s/current/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/snap/microk8s/current/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/microk8s/current/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/microk8s/current/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/var/snap/microk8s/common/plugins/mayastor-pools", line 92, in add
    subprocess.run([KUBECTL, "apply", "-f", "-"], input=format_pool(node, dev))
  File "/snap/microk8s/current/usr/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/snap/microk8s/current/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/snap/microk8s/current/usr/lib/python3.8/subprocess.py", line 1639, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: fork_exec() takes exactly 21 arguments (17 given)

python3 --version

Python 3.10.6

cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Okay, so it looks like that's one of the two problems. The other is that we are using the python3 from the host. Can you also try to edit /var/snap/microk8s/common/plugins/mayastor-pools and change #!/usr/bin/env python3 to #!/snap/microk8s/current/usr/bin/python3?

That should make it work (again, as a workaround), until we fix this properly.

That did the trick and as a workaround it's horribly easy!

I'm good to run with this.

Should the upgrade have brought the newer version of the admins over, or was my path a valid alternative?

This should now be fixed on all supported tracks, please re-open if you find this again. Thank you!

Should the upgrade have brought the newer version of the admins over, or was my path a valid alternative?

Yes, automatic upgrades will make sure everything is in order, since we now set the PATH and PYTHONPATHs accordingly