Skip to content

Commit

Permalink
Merge pull request #54 from canonical/update-mongos-status-for-k8s
Browse files Browse the repository at this point in the history
[DPE 5235] update lib for mongos k8s
  • Loading branch information
MiaAltieri authored Aug 30, 2024
2 parents c2698a3 + a585cd9 commit b825a2a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/charms/mongos/v0/set_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from ops.framework import Object
from ops.model import StatusBase

import logging
from ops.model import ActiveStatus

logger = logging.getLogger(__name__)

# The unique Charmhub library identifier, never change it
LIBID = "0713372afa0841359edbb777273ecdbf"
Expand All @@ -16,7 +20,7 @@

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


class MongosStatusHandler(Object):
Expand Down Expand Up @@ -49,4 +53,17 @@ def set_and_share_status(self, status: StatusBase):
def set_app_status(self):
"""TODO Future Feature/Epic: parse statuses and set a status for the entire app."""

def clear_status(self, status_to_clear):
"""Clears the provided status."""
if self.charm.unit.status != status_to_clear:
logger.debug(
"cannot clear status: %s, unit not in that status, unit in %s",
status_to_clear,
self.charm.unit.status,
)
return

# TODO: In the future compute the next highest priority status.
self.charm.unit.status = ActiveStatus()

# END: Helpers

0 comments on commit b825a2a

Please sign in to comment.