canonical / canonical/postgresql-operator
BlockedStatus object compared to string list in S3 block message check
- Dominant language
- Python
- Stars
- 20
- Forks
- 36
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 30
Description
## Problem
In `src/charm.py` on the `main` branch (line 1755), there is a comparison:
```python
if self.is_blocked and self.unit.status not in S3_BLOCK_MESSAGES:
```
`self.unit.status` is a `BlockedStatus` **object**, while `S3_BLOCK_MESSAGES` is a list of **strings**. A `BlockedStatus` object will never equal a plain string, so this `not in` check is **always True**. The intended S3 block message exclusion never fires.
## Affected branches
- **`main`** — bug exists at `src/charm.py` line 1755
- **`16/edge`** — needs verification (likely same bug if the line exists)
## Impact
The `_on_update_status` method always early-exits when the charm is in any blocked state, including S3-related blocked states that should allow continued processing (e.g., retrying stanza initialization when S3 settings are fixed).
## Fix
Change `self.unit.status` to `self.unit.status.message`:
```python
if self.is_blocked and self.unit.status.message not in S3_BLOCK_MESSAGES:
```
## Notes
- The same bug existed in the K8s charm (`canonical/postgresql-k8s-operator`) on its `main` branch and is being fixed by PR #1243 (branch `include-pgbackrest-error-details`), which switches to `is_s3_block_message(self.unit.status.message)`.
- Inside `backups.py` on both charms, the comparison is done **correctly** using `.message` (e.g., `self.charm.unit.status.message not in S3_BLOCK_MESSAGES`). The bug is only in `charm.py`.
Contributor guide
Research direction
Start at src/charm.py line 1755 in _on_update_status and compare the status value used there with the string entries in S3_BLOCK_MESSAGES. Confirm that the S3 block-message exclusion works after using the status message, and verify whether the same line exists on the 16/edge branch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- databases, devops
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100