Skip to content

Commit

Permalink
update reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Aug 31, 2023
1 parent 2fc61dd commit 959879c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ cosl==0.0.5
importlib-resources==5.10.2
tenacity==8.1.0
pymongo==4.3.3
ops==2.0.0
ops==2.4.1
jsonschema==4.17.3
cryptography==38.0.4
pure-sasl==0.6.2
pycparser==2.2
pkgutil-resolve-name==1.3.10
pydantic==1.10.7
pyrsistent==0.19.3
pyyaml==6.0
pyyaml==6.0.1
zipp==3.11.0
pyOpenSSL==22.1.0
typing-extensions==4.5.0
24 changes: 13 additions & 11 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ def _peers(self) -> Optional[Relation]:
return self.model.get_relation(Config.Relations.PEERS)

@property
def _db_initialised(self) -> bool:
def db_initialised(self) -> bool:
"""Check if MongoDB is initialised."""
return "db_initialised" in self.app_peer_data

@_db_initialised.setter
def _db_initialised(self, value):
@db_initialised.setter
def db_initialised(self, value):
"""Set the db_initialised flag."""
if isinstance(value, bool):
self.app_peer_data["db_initialised"] = str(value)
else:
Expand Down Expand Up @@ -345,7 +347,7 @@ def _on_relation_handler(self, event: RelationEvent) -> None:
# only leader should configure replica set and app-changed-events can trigger the relation
# changed hook resulting in no JUJU_REMOTE_UNIT if this is the case we should return
# further reconfiguration can be successful only if a replica set is initialised.
if not (self.unit.is_leader() and event.unit) or not self._db_initialised:
if not (self.unit.is_leader() and event.unit) or not self.db_initialised:
return

with MongoDBConnection(self.mongodb_config) as mongo:
Expand Down Expand Up @@ -455,7 +457,7 @@ def _on_update_status(self, event: UpdateStatusEvent):
return

# no need to report on replica set status until initialised
if not self._db_initialised:
if not self.db_initialised:
return

# Cannot check more advanced MongoDB statuses if mongod hasn't started.
Expand Down Expand Up @@ -676,15 +678,15 @@ def _generate_secrets(self) -> None:

def _update_hosts(self, event: LeaderElectedEvent) -> None:
"""Update replica set hosts and remove any unremoved replicas from the config."""
if not self._db_initialised:
if not self.db_initialised:
return

self.process_unremoved_units(event)
self.app_peer_data["replica_set_hosts"] = json.dumps(self._unit_ips)

def update_app_relation_data(self) -> None:
"""Helper function to update application relation data."""
if not self._db_initialised:
if not self.db_initialised:
return

database_users = set()
Expand Down Expand Up @@ -826,7 +828,7 @@ def _push_tls_certificate_to_workload(self) -> None:

def _connect_mongodb_exporter(self) -> None:
"""Exposes the endpoint to mongodb_exporter."""
if not self._db_initialised:
if not self.db_initialised:
return

# must wait for leader to set URI before connecting
Expand All @@ -840,7 +842,7 @@ def _connect_mongodb_exporter(self) -> None:

def _connect_pbm_agent(self) -> None:
"""Updates URI for pbm-agent."""
if not self._db_initialised:
if not self.db_initialised:
return

# must wait for leader to set URI before any attempts to update are made
Expand Down Expand Up @@ -879,7 +881,7 @@ def _run_diagnostic_command(self, cmd) -> None:
logger.error(f"Exception occurred running '{cmd}'\n {e}")

def _initialise_replica_set(self, event: StartEvent) -> None:
if self._db_initialised:
if self.db_initialised:
# The replica set should be initialised only once. Check should be
# external (e.g., check initialisation inside peer relation). We
# shouldn't rely on MongoDB response because the data directory
Expand Down Expand Up @@ -913,7 +915,7 @@ def _initialise_replica_set(self, event: StartEvent) -> None:
return

# replica set initialised properly and ready to go
self._db_initialised = True
self.db_initialised = True
self.unit.status = ActiveStatus()

def _unit_ip(self, unit: Unit) -> str:
Expand Down
16 changes: 8 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pass_env =
CI_PACKED_CHARMS
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand All @@ -86,7 +86,7 @@ pass_env =
CI_PACKED_CHARMS
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand All @@ -100,7 +100,7 @@ pass_env =
CI_PACKED_CHARMS
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand All @@ -114,7 +114,7 @@ pass_env =
CI_PACKED_CHARMS
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand All @@ -128,7 +128,7 @@ pass_env =
CI_PACKED_CHARMS
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand All @@ -147,7 +147,7 @@ pass_env =
GCP_SECRET_KEY
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand All @@ -161,7 +161,7 @@ pass_env =
CI_PACKED_CHARMS
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand All @@ -176,7 +176,7 @@ pass_env =
CI_PACKED_CHARMS
deps =
pytest
juju==2.9.38.1 # juju 3.3.0 has issues with retrieving action results
juju==2.9.44.0 # The latest python-libjuju that supports both juju 2.9 and 3.0
pytest-operator
-r {tox_root}/requirements.txt
commands =
Expand Down

0 comments on commit 959879c

Please sign in to comment.