[DPE-9070] Handle pgBackRest archive timeout in check_stanza#1350
Merged
marceloneppel merged 1 commit intodpe-8865-extract-error-messagesfrom Dec 15, 2025
Merged
Conversation
Port archive timeout error handling (error code 82) from PR #1328 to allow users to fix network issues and retry with `juju resolve`. When archive operations timeout, the charm enters error state instead of blocked state, enabling recovery via juju resolve. Fixes #1346 Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dpe-8865-extract-error-messages #1350 +/- ##
===================================================================
+ Coverage 70.53% 70.58% +0.04%
===================================================================
Files 16 16
Lines 4273 4280 +7
Branches 690 691 +1
===================================================================
+ Hits 3014 3021 +7
Misses 1048 1048
Partials 211 211 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
onkolahmet
approved these changes
Dec 15, 2025
carlcsaposs-canonical
approved these changes
Dec 15, 2025
ac88cce
into
dpe-8865-extract-error-messages
249 of 251 checks passed
marceloneppel
added a commit
that referenced
this pull request
Dec 16, 2025
* Extract warning and error messages from pgBackRest logs Sometimes the error message is sent to the stdout instead of the stderr, so it's important to check both Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Use semicolon separator for pgBackRest error messages Concatenate multiple ERROR/WARN lines with "; " instead of " " for improved readability when debugging backup issues. Updated unit test to match new separator format. Cherry-picked from #1328 (commit 1f1b601). Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * [DPE-9070] Handle pgBackRest archive timeout in check_stanza (#1350) Port archive timeout error handling (error code 82) from PR #1328 to allow users to fix network issues and retry with `juju resolve`. When archive operations timeout, the charm enters error state instead of blocked state, enabling recovery via juju resolve. Fixes #1346 Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Standardize pgBackRest logging to use stderr consistently Addresses code review feedback from PR #1320 (review #3577653265) about potential log duplication when checking both stdout and stderr for errors. Changes: - Add PGBACKREST_LOG_LEVEL_STDERR constant (--log-level-stderr=warn) to ensure all pgBackRest commands output errors/warnings to stderr - Update all 9 pgBackRest command invocations to include the new flag - Simplify _extract_error_message() to only check stderr (removes stdout parameter entirely) - Update all 8 call sites and 7 unit tests to use new single-parameter API - Remove redundant test for stdout handling This approach eliminates the risk of log duplication while maintaining predictable error extraction. All errors and warnings now consistently appear in stderr, making error handling more reliable. Reference: https://pgbackrest.org/configuration.html#section-log Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Revert "Standardize pgBackRest logging to use stderr consistently" This reverts commit 13a9ac4. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Reapply "Standardize pgBackRest logging to use stderr consistently" This reverts commit 1c3eb04. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Fix test_initialise_stanza and cleanup unused variables - Add --log-level-stderr=warn to test_initialise_stanza expected command to match implementation from commit d3a46b6 - Replace unused stdout variables with '_' in check_stanza, _is_primary_pgbackrest_service_running, and _on_restore_action - Add --log-level-console=debug to backup command for detailed output Fixes assertion error in tests/unit/test_backups.py::test_initialise_stanza Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
a-velasco
pushed a commit
that referenced
this pull request
Jan 15, 2026
* Extract warning and error messages from pgBackRest logs Sometimes the error message is sent to the stdout instead of the stderr, so it's important to check both Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Use semicolon separator for pgBackRest error messages Concatenate multiple ERROR/WARN lines with "; " instead of " " for improved readability when debugging backup issues. Updated unit test to match new separator format. Cherry-picked from #1328 (commit 1f1b601). Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * [DPE-9070] Handle pgBackRest archive timeout in check_stanza (#1350) Port archive timeout error handling (error code 82) from PR #1328 to allow users to fix network issues and retry with `juju resolve`. When archive operations timeout, the charm enters error state instead of blocked state, enabling recovery via juju resolve. Fixes #1346 Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Standardize pgBackRest logging to use stderr consistently Addresses code review feedback from PR #1320 (review #3577653265) about potential log duplication when checking both stdout and stderr for errors. Changes: - Add PGBACKREST_LOG_LEVEL_STDERR constant (--log-level-stderr=warn) to ensure all pgBackRest commands output errors/warnings to stderr - Update all 9 pgBackRest command invocations to include the new flag - Simplify _extract_error_message() to only check stderr (removes stdout parameter entirely) - Update all 8 call sites and 7 unit tests to use new single-parameter API - Remove redundant test for stdout handling This approach eliminates the risk of log duplication while maintaining predictable error extraction. All errors and warnings now consistently appear in stderr, making error handling more reliable. Reference: https://pgbackrest.org/configuration.html#section-log Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Revert "Standardize pgBackRest logging to use stderr consistently" This reverts commit 13a9ac4. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Reapply "Standardize pgBackRest logging to use stderr consistently" This reverts commit 1c3eb04. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Fix test_initialise_stanza and cleanup unused variables - Add --log-level-stderr=warn to test_initialise_stanza expected command to match implementation from commit d3a46b6 - Replace unused stdout variables with '_' in check_stanza, _is_primary_pgbackrest_service_running, and _on_restore_action - Add --log-level-console=debug to backup command for detailed output Fixes assertion error in tests/unit/test_backups.py::test_initialise_stanza Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> Signed-off-by: andreia <andreia.velasco@canonical.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
The archive timeout error handling (error code 82) from PR #1328 to allow users to fix network issues and retry with
juju resolvewas not added to PG 16.Solution
When archive operations timeout, the charm enters error state instead of blocked state, enabling recovery via juju resolve. Fixes #1346
#1320 must be merged before this PR.
Checklist