Skip to content

Commit

Permalink
fix logs
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Nov 7, 2023
1 parent 8afa379 commit c6b1b87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions lib/charms/mongodb/v1/mongodb_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -421,15 +421,14 @@ def _wait_pbm_status(self) -> None:
except ExecError as e:
self.charm.unit.status = BlockedStatus(self.process_pbm_error(e.stdout))

def get_pbm_status(self) -> StatusBase:
def get_pbm_status(self) -> Optional[StatusBase]:
"""Retrieve pbm status."""
if not self.charm.has_backup_service():
return WaitingStatus("waiting for pbm to start")

if not self.model.get_relation(S3_RELATION):
logger.info("No configurations for backups, not relation to s3-charm.")
return BlockedStatus("Backups require relation to s3-integrator")

return None
try:
previous_pbm_status = self.charm.unit.status
pbm_status = self.charm.run_pbm_command(PBM_STATUS_CMD)
Expand Down
6 changes: 2 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
generate_password,
get_create_user_cmd,
)
from charms.mongodb.v1.mongodb_backups import S3_RELATION, MongoDBBackups
from charms.mongodb.v1.mongodb_backups import MongoDBBackups
from charms.mongodb.v1.mongodb_provider import MongoDBProvider
from charms.mongodb.v1.mongodb_vm_legacy_provider import MongoDBLegacyProvider
from charms.mongodb.v1.mongos import MongosConfiguration
Expand Down Expand Up @@ -1363,9 +1363,7 @@ def get_status(self) -> StatusBase:
if self.is_role(Config.Role.CONFIG_SERVER)
else None
)
pbm_status = (
self.backups.get_pbm_status() if self.model.get_relation(S3_RELATION) else None
)
pbm_status = self.backups.get_pbm_status()

# failure in mongodb takes precedence over sharding and config server
if not isinstance(mongodb_status, ActiveStatus):
Expand Down

0 comments on commit c6b1b87

Please sign in to comment.