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)
Steps to reproduce
Expected behavior
Appropriate error message should be shown and the program should not crash.
Actual behavior
The program crashes with exception.
Versions
Operating system: Ubuntu 23.04
Additional context
The bug exists for both backends (
lightkube
andkubectl
)