Skip to content

Commit

Permalink
Fix REST and schema registry shutdown
Browse files Browse the repository at this point in the history
Shutdown handler for aiohttp Application was set only for
KarapaceAll. On some environments where REST application and
schema registry pplication is run separately, e.g. containers,
the shutdown times out and container manager sends kill signal.

Fix is to move the shutdown handler registration from KarapaceAll
to KarapaceBase.
  • Loading branch information
jjaakola-aiven committed Dec 20, 2021
1 parent 432733f commit acc2c8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 5 additions & 0 deletions karapace/karapace.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def __init__(self, config: dict) -> None:
self.app.on_startup.append(self.create_http_client)
self.master_lock = asyncio.Lock()
self.log.info("Karapace initialized")
self.app.on_shutdown.append(self.close_by_app)

async def close_by_app(self, app):
# pylint: disable=unused-argument
await self.close()

def _create_producer(self) -> KafkaProducer:
while True:
Expand Down
5 changes: 0 additions & 5 deletions karapace/karapace_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ class KarapaceAll(KafkaRest, KarapaceSchemaRegistry):
def __init__(self, config: dict) -> None:
super().__init__(config=config)
self.log = logging.getLogger("KarapaceAll")
self.app.on_shutdown.append(self.close_by_app)

async def close_by_app(self, app):
# pylint: disable=unused-argument
await self.close()


def main() -> int:
Expand Down

0 comments on commit acc2c8a

Please sign in to comment.