Skip to content

Commit

Permalink
feat: Update status while integrating to config server (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu1nness authored Oct 9, 2024
1 parent 2c44446 commit 933a314
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/charms/mongodb/v0/config_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
DatabaseRequires,
)
from charms.mongodb.v1.mongos import MongosConnection
from ops.charm import CharmBase, EventBase, RelationBrokenEvent, RelationChangedEvent
from ops.charm import (
CharmBase,
EventBase,
RelationBrokenEvent,
RelationChangedEvent,
RelationCreatedEvent,
)
from ops.framework import Object
from ops.model import (
ActiveStatus,
Expand Down Expand Up @@ -43,7 +49,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 13
LIBPATCH = 14


class ClusterProvider(Object):
Expand Down Expand Up @@ -244,7 +250,7 @@ def __init__(
super().__init__(charm, self.relation_name)
self.framework.observe(
charm.on[self.relation_name].relation_created,
self.database_requires._on_relation_created_event,
self._on_relation_created_handler,
)

self.framework.observe(
Expand All @@ -261,6 +267,11 @@ def __init__(
charm.on[self.relation_name].relation_broken, self._on_relation_broken
)

def _on_relation_created_handler(self, event: RelationCreatedEvent) -> None:
logger.info("Integrating to config-server")
self.charm.status.set_and_share_status(WaitingStatus("Connecting to config-server"))
self.database_requires._on_relation_created_event(event)

def _on_database_created(self, event) -> None:
if self.charm.upgrade_in_progress:
logger.warning(
Expand Down

0 comments on commit 933a314

Please sign in to comment.