-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MISC] Bugfixes #252
[MISC] Bugfixes #252
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,6 @@ | |
from ops.charm import CharmBase, RelationBrokenEvent, RelationDepartedEvent | ||
from ops.framework import Object | ||
from ops.model import ( | ||
ActiveStatus, | ||
Application, | ||
BlockedStatus, | ||
MaintenanceStatus, | ||
|
@@ -232,7 +231,7 @@ def _on_database_created(self, event: DatabaseCreatedEvent) -> None: | |
self.charm.render_auth_file(auth_file) | ||
self.charm.render_pgb_config(reload_pgbouncer=True) | ||
self.charm.toggle_monitoring_layer(True) | ||
self.charm.unit.status = ActiveStatus() | ||
self.charm.update_status() | ||
return | ||
|
||
logger.info("initialising pgbouncer backend relation") | ||
|
@@ -274,7 +273,7 @@ def _on_database_created(self, event: DatabaseCreatedEvent) -> None: | |
self.charm.render_pgb_config(reload_pgbouncer=True) | ||
self.charm.toggle_monitoring_layer(True) | ||
|
||
self.charm.unit.status = ActiveStatus("backend-database relation initialised.") | ||
self.charm.update_status() | ||
|
||
def _on_endpoints_changed(self, _): | ||
self.charm.render_pgb_config(reload_pgbouncer=True) | ||
|
@@ -300,7 +299,8 @@ def _on_relation_departed(self, event: RelationDepartedEvent): | |
the postgres relation-broken hook removes the user needed to remove authentication for the | ||
users we create. | ||
""" | ||
self.charm.render_pgb_config(reload_pgbouncer=True) | ||
if self.charm.peers.relation: | ||
self.charm.render_pgb_config(reload_pgbouncer=True) | ||
self.charm.update_client_connection_info() | ||
|
||
if event.departing_unit == self.charm.unit: | ||
|
@@ -335,7 +335,6 @@ def _on_relation_departed(self, event: RelationDepartedEvent): | |
return | ||
|
||
self.postgres.delete_user(self.auth_user) | ||
self.charm.peers.remove_user(self.auth_user) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't exist any more |
||
logger.info("pgbouncer auth user removed") | ||
|
||
def _on_relation_broken(self, event: RelationBrokenEvent): | ||
|
@@ -344,11 +343,11 @@ def _on_relation_broken(self, event: RelationBrokenEvent): | |
Removes all traces of this relation from pgbouncer config. | ||
""" | ||
depart_flag = f"{BACKEND_RELATION_NAME}_{event.relation.id}_departing" | ||
self.charm.toggle_monitoring_layer(False) | ||
if self.charm.peers.unit_databag.get(depart_flag, False): | ||
logging.info("exiting relation-broken hook - nothing to do") | ||
return | ||
|
||
self.charm.toggle_monitoring_layer(False) | ||
try: | ||
self.charm.delete_file(f"{PGB_DIR}/userlist.txt") | ||
except PathError: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,7 +237,7 @@ def _on_relation_joined(self, join_event: RelationJoinedEvent): | |
return | ||
|
||
dbs = self.charm.generate_relation_databases() | ||
dbs[join_event.relation.id] = {"name": database, "legacy": True} | ||
dbs[str(join_event.relation.id)] = {"name": database, "legacy": True} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSON keys are string |
||
self.charm.set_relation_databases(dbs) | ||
|
||
self.update_databags( | ||
|
@@ -252,14 +252,16 @@ def _on_relation_joined(self, join_event: RelationJoinedEvent): | |
# Create user and database in backend postgresql database | ||
try: | ||
init_msg = f"initialising database and user for {self.relation_name} relation" | ||
initial_status = self.charm.unit.status | ||
self.charm.unit.status = MaintenanceStatus(init_msg) | ||
logger.info(init_msg) | ||
|
||
self.charm.backend.postgres.create_user(user, password, admin=self.admin) | ||
self.charm.backend.postgres.create_database(database, user) | ||
|
||
created_msg = f"database and user for {self.relation_name} relation created" | ||
self.charm.unit.status = ActiveStatus() | ||
self.charm.unit.status = initial_status | ||
self.charm.update_status() | ||
logger.info(created_msg) | ||
except (PostgreSQLCreateDatabaseError, PostgreSQLCreateUserError): | ||
err_msg = f"failed to create database or user for {self.relation_name}" | ||
|
@@ -323,6 +325,9 @@ def _on_relation_changed(self, change_event: RelationChangedEvent): | |
|
||
def update_connection_info(self, relation: Relation, port: str): | ||
"""Updates databag connection information.""" | ||
if not port: | ||
port = self.charm.config["listen_port"] | ||
|
||
databag = self.get_databags(relation)[0] | ||
database = databag.get("database") | ||
user = databag.get("user") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ | |
|
||
FINOS_WALTZ = "finos-waltz" | ||
ANOTHER_FINOS_WALTZ = "another-finos-waltz" | ||
OPENLDAP = "openldap" | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
@@ -198,15 +197,3 @@ async def test_extensions_blocking(ops_test: OpsTest) -> None: | |
raise_on_blocked=False, | ||
timeout=3000, | ||
) | ||
|
||
|
||
@pytest.mark.group(1) | ||
@pytest.mark.unstable | ||
async def test_relation_with_openldap(ops_test: OpsTest): | ||
Comment on lines
-203
to
-205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The image for the charm cannot be downloaded. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which image? I deployed OpenLDAP through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got errors pulling the image for the same charm last week. Will recheck. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking deeper, it looks like this is the podspec charm and the pull failure seems to originate from the image pulled by the podspec. |
||
"""Test the relation with OpenLDAP charm.""" | ||
await ops_test.model.deploy( | ||
"openldap-charmers-openldap", application_name=OPENLDAP, channel="edge" | ||
) | ||
await ops_test.model.add_relation(f"{PGB}:db", f"{OPENLDAP}:db") | ||
wait_for_relation_joined_between(ops_test, PGB, OPENLDAP) | ||
await ops_test.model.wait_for_idle(apps=[PG, PGB, OPENLDAP], status="active", timeout=1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regenerating should be fast enough and if the mapping is wrong for whatever reason, always using the cache will never fix it.