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

Poorly human-readable output when creation process fail because user already exists #23

Closed
deusebio opened this issue Jun 19, 2023 · 1 comment · Fixed by #45
Closed
Labels
bug Something isn't working

Comments

@deusebio
Copy link
Contributor

When we create a user in a namespace and with a service-account name that already exists, the CLI raises an exception which is however not too verbose

Steps to reproduce

  1. Create a username with any name

python -m spark8t.cli.service_account_registry create --username my-spark-user

  1. Re-create the user again

python -m spark8t.cli.service_account_registry create --username my-spark-user

Expected behavior

The second command fail but providing a proper humanly-readable exception

Actual behavior

The actual error is something like

Traceback (most recent call last):
  File "/home/deusebio/.pyenv/versions/3.10.6/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/deusebio/.pyenv/versions/3.10.6/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/deusebio/Canonical/data-platform/repos/spark/spark-k8s-toolkit-py/spark8t/cli/service_account_registry.py", line 201, in <module>
    raise e
  File "/home/deusebio/Canonical/data-platform/repos/spark/spark-k8s-toolkit-py/spark8t/cli/service_account_registry.py", line 195, in <module>
    main(args, logger)
  File "/home/deusebio/Canonical/data-platform/repos/spark/spark-k8s-toolkit-py/spark8t/cli/service_account_registry.py", line 115, in main
    registry.create(service_account)
  File "/home/deusebio/Canonical/data-platform/repos/spark/spark-k8s-toolkit-py/spark8t/services.py", line 1148, in create
    self.kube_interface.create(
  File "/home/deusebio/Canonical/data-platform/repos/spark/spark-k8s-toolkit-py/spark8t/services.py", line 881, in create
    self.exec(
  File "/home/deusebio/Canonical/data-platform/repos/spark/spark-k8s-toolkit-py/spark8t/services.py", line 726, in exec
    else subprocess.check_output(
  File "/home/deusebio/.pyenv/versions/3.10.6/lib/python3.10/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/deusebio/.pyenv/versions/3.10.6/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'kubectl --kubeconfig /home/deusebio/.kube/config  --namespace default  --context microk8s create serviceaccount my-spark-user  -o name ' returned non-zero exit status 1.
(
@deusebio deusebio added the bug Something isn't working label Jun 19, 2023
@deusebio
Copy link
Contributor Author

This may be improved in #45. When an exception occurs, we now log stdout and stderr for the process

@deusebio deusebio linked a pull request Oct 12, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant