1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/buildman/manager/buildcanceller.py
Kenny Lee Sin Cheong 5f63b3a7bb chore: drop deprecated tables and remove unused code (PROJQUAY-522) (#2089)
* chore: drop deprecated tables and remove unused code

* isort imports

* migration: check for table existence before drop
2023-08-25 12:17:24 -04:00

32 lines
921 B
Python

import logging
from buildman.manager.noop_canceller import NoopCanceller
from buildman.manager.orchestrator_canceller import OrchestratorCanceller
logger = logging.getLogger(__name__)
CANCELLERS = {"ephemeral": OrchestratorCanceller}
class BuildCanceller(object):
"""
A class to manage cancelling a build.
"""
def __init__(self, app=None):
self.build_manager_config = app.config.get("BUILD_MANAGER")
if app is None or self.build_manager_config is None:
self.handler = NoopCanceller()
else:
self.handler = None
def try_cancel_build(self, uuid):
"""
A method to kill a running build.
"""
if self.handler is None:
canceller = CANCELLERS.get(self.build_manager_config[0], NoopCanceller)
self.handler = canceller(self.build_manager_config[1])
return self.handler.try_cancel_build(uuid)