Skip to content

Commit 333daca

Browse files
committed
docs(charm): trim storage-detaching comments and fix copyright year
Match the one-liner docstring density of the surrounding handlers instead of an 8-line block (the why lives in the commit that added the guard), and date the new test file 2026 (it was copied as 2025). Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent 817c857 commit 333daca

3 files changed

Lines changed: 10 additions & 29 deletions

File tree

src/charm.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,24 +2568,13 @@ def _install_snap_package(
25682568
raise
25692569

25702570
def _on_storage_detaching(self, _) -> None:
2571-
"""Release the storage so Juju can unmount it on unit teardown.
2572-
2573-
Only act when the whole application is going away (``planned_units == 0``,
2574-
i.e. remove-application/destroy-model), which is where the storage unmount
2575-
actually hangs. On scale-down the surviving units still need this unit's
2576-
Patroni reachable to remove it from the raft cluster, so stopping the
2577-
workload here would break primary election.
2578-
2579-
``storage-detaching`` runs before ``stop``, so this is the earliest hook
2580-
where the snap services and background processes that keep the storage
2581-
mounts busy can be stopped.
2582-
"""
2571+
"""Stop the workload so Juju can unmount the storage on app teardown."""
2572+
# On scale-down the surviving cluster still needs this unit's Patroni to
2573+
# remove it from raft; only stop when the whole app is going away.
25832574
if self.app.planned_units() > 0:
25842575
return
25852576
self._observer.stop_observer()
25862577
self._rotate_logs.stop_log_rotation()
2587-
# Stop every charmed-postgresql snap service (PostgreSQL, pgBackRest, the
2588-
# exporters) so the snap releases the storage mounts before Juju unmounts them.
25892578
try:
25902579
snap.SnapCache()[charm_refresh.snap_name()].stop()
25912580
except snap.SnapError:

tests/integration/test_storage_detaching.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright 2025 Canonical Ltd.
2+
# Copyright 2026 Canonical Ltd.
33
# See LICENSE file for licensing details.
44

55
import logging
@@ -11,11 +11,8 @@
1111

1212
logger = logging.getLogger(__name__)
1313

14-
# rootfs (machine-scoped) storage is the issue's scenario. It matters:
15-
# - Juju 3.6 masks the bug via a cleanup_storage shortcut that removes still-Dying
16-
# storage, so this only reproduces on Juju 4.0 (see tests/spread/.../task.yaml).
17-
# - On 4.0 the detachable ``lxd`` pool lets Juju destroy the container before
18-
# detaching, so only ``rootfs`` reproduces the stuck unmount.
14+
# rootfs (machine-scoped) is the only pool that reproduces the stuck unmount on
15+
# Juju 4.0: the detachable lxd pool destroys the container before detaching.
1916
ROOTFS_STORAGE = dict.fromkeys(("archive", "data", "logs", "temp"), "rootfs")
2017

2118

@@ -24,12 +21,8 @@ def test_storage_released_on_removal(juju: JujuFixture, charm):
2421
"""Graceful removal must release the storage so teardown completes.
2522
2623
Regression test for canonical/postgresql-operator#1550: without stopping the
27-
workload in the ``storage-detaching`` hook the charmed-postgresql snap keeps the
28-
storage mounts busy, so Juju's unmount fails ("target is busy") and the unit,
29-
storage and machine removal hangs forever.
30-
31-
Pinned to Juju 4.0 with rootfs storage by its spread task. ``force=True`` is
32-
required because the charm still declares ``assumes: juju < 4``.
24+
workload in the ``storage-detaching`` hook the snap keeps the storage mounts
25+
busy, so Juju's unmount fails ("target is busy") and teardown hangs.
3326
"""
3427
juju.ext.model.deploy(
3528
charm,

tests/spread/test_storage_detaching.py/task.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
summary: test_storage_detaching.py
22
environment:
33
TEST_MODULE: test_storage_detaching.py
4-
# #1550 only reproduces on Juju 4.0: 3.6 masks it via a cleanup_storage shortcut
5-
# that removes still-Dying storage. Pin this task to a 4.0 variant and drop the
6-
# default juju36 variant so it runs ONLY on 4.0 (the rest of the suite stays 3.6).
4+
# #1550 only reproduces on Juju 4.0 (3.6 masks it by removing still-Dying storage),
5+
# so pin this task to a juju40 variant and drop the default juju36.
76
CONCIERGE_JUJU_CHANNEL/juju40: 4.0/stable
87
variants:
98
- -juju36

0 commit comments

Comments
 (0)