Skip to content

Commit

Permalink
Attempt to avoid EnterScope errors
Browse files Browse the repository at this point in the history
  • Loading branch information
juditnovak committed Aug 28, 2023
1 parent 9330001 commit cb7dc4a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/integration/database-charm/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import logging
import secrets
import string
from random import randrange
from time import sleep

import psycopg2
from ops.charm import CharmBase, WorkloadEvent
Expand Down Expand Up @@ -100,6 +102,16 @@ def _on_database_requested(self, event: DatabaseRequestedEvent) -> None:
# Share the credentials with the application.
self.database.set_credentials(event.relation.id, username, password)

# Temporary hack to avoid https://bugs.launchpad.net/juju/+bug/2031631
sleep(randrange(3))

assert self.model.get_binding("database")
assert self.model.get_binding("database").network
assert self.model.get_binding("database").network.bind_address
logger.info(
f"Charm binding {self.model.get_binding('database')}, network: {self.model.get_binding('database').network}, IP: self.model.get_binding('database').network.bind_address"
)

# Set the read/write endpoint.
self.database.set_endpoints(
event.relation.id, f'{self.model.get_binding("database").network.bind_address}:5432'
Expand Down

0 comments on commit cb7dc4a

Please sign in to comment.