From 8f422fa5a23a90f79f0d308e0efb359631848f10 Mon Sep 17 00:00:00 2001 From: Hemanth Nakkina Date: Thu, 17 Nov 2022 11:06:45 +0530 Subject: [PATCH] update container status once service is ready Currently the container handler status is updated only when update_status hook is triggered. Update the status once the service is ready instead of waiting for update_status hook. Change-Id: I52cf06af03dd1807ee0097d7dd7fb8bc85e13781 --- ops-sunbeam/ops_sunbeam/container_handlers.py | 3 +++ ops-sunbeam/ops_sunbeam/ovn/container_handlers.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/ops-sunbeam/ops_sunbeam/container_handlers.py b/ops-sunbeam/ops_sunbeam/container_handlers.py index b8c427ad..0af299e0 100644 --- a/ops-sunbeam/ops_sunbeam/container_handlers.py +++ b/ops-sunbeam/ops_sunbeam/container_handlers.py @@ -166,6 +166,7 @@ class PebbleHandler(ops.charm.Object): self.setup_dirs() self.write_config(context) self._state.service_ready = True + self.status.set(ActiveStatus("")) def default_container_configs( self, @@ -315,6 +316,7 @@ class ServicePebbleHandler(PebbleHandler): else: self.start_service(restart=False) self._state.service_ready = True + self.status.set(ActiveStatus("")) def start_service(self, restart: bool = True) -> None: """Check and start services in container. @@ -447,6 +449,7 @@ class WSGIPebbleHandler(PebbleHandler): else: self.start_wsgi(restart=False) self._state.service_ready = True + self.status.set(ActiveStatus("")) @property def wsgi_conf(self) -> str: diff --git a/ops-sunbeam/ops_sunbeam/ovn/container_handlers.py b/ops-sunbeam/ops_sunbeam/ovn/container_handlers.py index f2e71465..0377a0c4 100644 --- a/ops-sunbeam/ops_sunbeam/ovn/container_handlers.py +++ b/ops-sunbeam/ops_sunbeam/ovn/container_handlers.py @@ -18,6 +18,10 @@ from typing import ( List, ) +from ops.model import ( + ActiveStatus, +) + from .. import container_handlers as sunbeam_chandlers from .. import core as sunbeam_core @@ -46,6 +50,7 @@ class OVNPebbleHandler(sunbeam_chandlers.ServicePebbleHandler): self.setup_dirs() self.write_config(context) self._state.service_ready = True + self.status.set(ActiveStatus("")) @property def service_description(self) -> str: