Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
k8s: Handle ValueError raised
Browse files Browse the repository at this point in the history
API raises ValueError when namespace is not provided in
definition. Handle and provide meaningful message to user
about this.

Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde committed Dec 10, 2020
1 parent 549dd26 commit 6e1ef57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/handle_valueerror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- k8s - handle ValueError when namespace is not provided.
5 changes: 5 additions & 0 deletions plugins/module_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,11 @@ def perform_action(self, resource, definition):
if self.warnings:
msg += "\n" + "\n ".join(self.warnings)
self.fail_json(msg=msg, error=exc.status, status=exc.status, reason=exc.reason)
except Exception as exc:
msg = "Failed to create object: {0}".format(exc)
if self.warnings:
msg += "\n" + "\n ".join(self.warnings)
self.fail_json(msg=msg, error='', status='', reason='')
success = True
result['result'] = k8s_obj
if wait and not self.check_mode:
Expand Down

0 comments on commit 6e1ef57

Please sign in to comment.