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

CLI crashes with exception on creating a service account in non-existent namespace #55

Open
theoctober19th opened this issue Jan 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@theoctober19th
Copy link
Member

Steps to reproduce

  1. Try creating a new service account using CLI but provide a namespace that does not exist.
python spark8t/cli/service_account_registry.py create --username something --namespace something_that_does_not_exist

Expected behavior

Appropriate error message should be shown and the program should not crash.

Actual behavior

The program crashes with exception.

b'error: failed to create serviceaccount: namespaces "something_that_does_not_exist" not found\n'
Traceback (most recent call last):
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/cli/service_account_registry.py", line 206, in <module>
    raise e
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/cli/service_account_registry.py", line 200, in <module>
    main(args, logger)
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/cli/service_account_registry.py", line 119, in main
    registry.create(service_account)
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/services.py", line 1214, in create
    self.kube_interface.create(
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/services.py", line 909, in create
    self.exec(
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/services.py", line 757, in exec
    else execute_command_output(base_cmd)
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/utils.py", line 285, in execute_command_output
    raise e
  File "/home/bikalpa/canonical/spark-k8s-toolkit-py/spark8t/utils.py", line 279, in execute_command_output
    output = subprocess.check_output(
  File "/usr/local/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'kubectl --kubeconfig /home/bikalpa/.kube/config  --namespace something_that_does_not_exist  --context microk8s create serviceaccount something  -o name ' returned non-zero exit status 1.

Versions

Operating system: Ubuntu 23.04

Additional context

The bug exists for both backends (lightkube and kubectl)

@theoctober19th theoctober19th added the bug Something isn't working label Jan 9, 2024
Copy link

github-actions bot commented Jan 9, 2024

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

No branches or pull requests

1 participant