[DPE-4598] Handle upgrade of top of the stack Juju leader #492
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 PostgreSQL VM charm rollback test started to fail by the combination of adding TimescaleDB to the Charmed PostgreSQL Snap + updating the
upgrade
library to LIBPATCH 16 (which removed adefer
call that was hiding the issue fixed by this PR).Explanation of the issue (considering the tests from the PostgreSQL VM charm):
In the
test_upgrade_from_edge
test:In the
test_fail_and_rollback
test:pre-upgrade-check
is run, which sets therecovery
state for the Juju leader unit (which is a replica).recovery
toready
, while in the other units, it was already set toready
, so no change, no events firing for the Juju leader unit).For Kafka and MySQL operators on VM, it hasn’t happened because both always set the upgrade stack with the Juju leader unit as the last unit to be upgraded. For the following codes, remember that the
build_upgrade_stack
is always executed in the Juju leader unit.Solution
If the Juju leader unit is the top unit of upgrading the stack, execute the
on_upgrade_changed
handler logic during a rollback. This way, it can run the logic that starts the upgrade process, in the end of theon_upgrade_changed
handler.Depends on canonical/data-platform-libs#176.