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

For patch: Delete controller when terminate #342

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -88,6 +88,8 @@ async def terminate(obj:ProcessManagerContext, query:ProcessQuery) -> 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=False)
@click.pass_obj
Expand All @@ -102,6 +104,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
7 changes: 6 additions & 1 deletion src/drunc/utils/shell_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,14 @@ def get_driver(self, name:str=None) -> GRPCDriver:
raise DruncShellException(f'More than one driver in this context')
return list(self._drivers.values())[0]
except KeyError:
self._log.error(f'FSM Commands cannot be sent until the Session is booted')
self._log.error(f'{name} commands are not available right now')
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"{name} commands are no longer available")

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

Expand Down
Loading