Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,8 @@ def _set_active_status(self):
self.app_peer_data["s3-initialization-block-message"]
)
return
if not self.upgrade.idle:
return
Comment on lines +1054 to +1055
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If upgrade is not idle, don't overwrite the status.

if (
self._patroni.get_primary(unit_name_pattern=True) == self.unit.name
or self.is_standby_leader
Expand Down
6 changes: 2 additions & 4 deletions src/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
LdapRequirer,
LdapUnavailableEvent,
)
from ops import Relation
from ops.framework import Object
from ops.model import ActiveStatus
from ops import Object, Relation

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -44,7 +42,7 @@ def _on_ldap_ready(self, _: LdapReadyEvent) -> None:
self.charm.app_peer_data.update({"ldap_enabled": "True"})

self.charm.update_config()
self.charm.unit.status = ActiveStatus()
self.charm._set_active_status()

def _on_ldap_unavailable(self, _: LdapUnavailableEvent) -> None:
"""Handler for the LDAP unavailable event."""
Expand Down
9 changes: 6 additions & 3 deletions src/relations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
PostgreSQLDeleteUserError,
PostgreSQLGetPostgreSQLVersionError,
)
from ops.charm import (
from ops import (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import from ops directly, not strictly necessary.

ActiveStatus,
BlockedStatus,
CharmBase,
Object,
Relation,
RelationBrokenEvent,
RelationChangedEvent,
RelationDepartedEvent,
Unit,
)
from ops.framework import Object
from ops.model import ActiveStatus, BlockedStatus, Relation, Unit
from pgconnstr import ConnectionString

from constants import (
Expand Down
13 changes: 10 additions & 3 deletions src/relations/postgresql_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@
PostgreSQLDeleteUserError,
PostgreSQLGetPostgreSQLVersionError,
)
from ops.charm import CharmBase, RelationBrokenEvent, RelationChangedEvent, RelationDepartedEvent
from ops.framework import Object
from ops.model import ActiveStatus, BlockedStatus, Relation
from ops import (
ActiveStatus,
BlockedStatus,
CharmBase,
Object,
Relation,
RelationBrokenEvent,
RelationChangedEvent,
RelationDepartedEvent,
)

from constants import DATABASE_PORT, ENDPOINT_SIMULTANEOUSLY_BLOCKING_MESSAGE
from utils import new_password
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ def test_enable_disable_extensions(harness):
return_value=False,
new_callable=PropertyMock,
),
patch("charm.PostgreSQLUpgrade.idle", new_callable=PropertyMock, return_value=True),
):
# Early exit if no primary
harness.charm.enable_disable_extensions()
Expand Down Expand Up @@ -1718,6 +1719,7 @@ def test_set_active_status(harness):
"charm.PostgresqlOperatorCharm.is_standby_leader", new_callable=PropertyMock
) as _is_standby_leader,
patch("charm.Patroni.get_primary") as _get_primary,
patch("charm.PostgreSQLUpgrade.idle", new_callable=PropertyMock, return_value=True),
):
for values in itertools.product(
[
Expand Down