Skip to content

Commit

Permalink
Fix release log msg, check for owner on release
Browse files Browse the repository at this point in the history
  • Loading branch information
bsquizz committed Jan 25, 2022
1 parent b29cd42 commit ccc2fce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bonfire/bonfire.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def _cmd_namespace_reserve(name, requester, duration, timeout, local):
"--force",
is_flag=True,
default=False,
help="Do not check if you own this namespace",
help="Do not ask for confirmation",
)
@options([_local_option])
@click_exception_wrapper("namespace release")
Expand All @@ -636,6 +636,9 @@ def _cmd_namespace_release(namespace, force, local):

if not force:
_warn_before_delete()
ns = Namespace(name=namespace)
if not ns.owned_by_me:
_warn_if_not_owned_by_me()

release_reservation(namespace=namespace, local=local)

Expand Down
3 changes: 2 additions & 1 deletion bonfire/namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ def reserve_namespace(name, requester, duration, timeout, local=True):
def release_reservation(name=None, namespace=None, local=True):
res = get_reservation(name=name, namespace=namespace)
if res:
res_name = res["metadata"]["name"]
res_config = process_reservation(
res["metadata"]["name"],
res["spec"]["requester"],
Expand All @@ -286,7 +287,7 @@ def release_reservation(name=None, namespace=None, local=True):
)

apply_config(None, list_resource=res_config)
msg = f"releasing reservation '{name}'"
msg = f"releasing reservation '{res_name}'"
if namespace:
msg += f" namespace '{namespace}'"
log.info(msg)
Expand Down

0 comments on commit ccc2fce

Please sign in to comment.