Skip to content

Commit

Permalink
delete controller when terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
Wanyun Su committed Dec 18, 2024
1 parent 87571b9 commit 600f955
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/drunc/process_manager/interface/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ async def terminate(obj:ProcessManagerContext) -> None:
from drunc.process_manager.utils import tabulate_process_instance_list
obj.print(tabulate_process_instance_list(result.data, 'Terminated process', False))

obj.delete_driver('controller')

@click.command('kill')
@add_query_options(at_least_one=True)
@click.pass_obj
Expand All @@ -100,6 +102,7 @@ async def kill(obj:ProcessManagerContext, query:ProcessQuery) -> None:
from drunc.process_manager.utils import tabulate_process_instance_list
obj.print(tabulate_process_instance_list(result.data, 'Killed process', False))

obj.delete_driver('controller')

@click.command('flush')
@add_query_options(at_least_one=False, all_processes_by_default=True)
Expand Down
8 changes: 8 additions & 0 deletions src/drunc/utils/shell_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ def get_driver(self, name:str=None) -> GRPCDriver:
self._log.error(f'Controller-specific commands cannot be sent until the session is booted')
raise SystemExit(1) # used to avoid having to catch multiple Attribute errors when this function gets called

def delete_driver(self, name: str) -> None:
if name in self._drivers:
del self._drivers[name]
self._log.info(f"Driver '{name}' has been deleted.")
else:
self._log.warn(f"Driver '{name}' does not exist in this context.")


def get_token(self) -> Token:
return self._token

Expand Down

0 comments on commit 600f955

Please sign in to comment.