Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MISC] Revert upgrade lib #489

Closed
wants to merge 2 commits into from
Closed

[MISC] Revert upgrade lib #489

wants to merge 2 commits into from

Conversation

dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Jun 7, 2024

Reverting the upgrade charm lib

Comment on lines -944 to +933
# skip run while in recovery. The event will be retrigged when the cluster is ready
logger.debug("Cluster in recovery, skip...")
# Only defer for vm, that will set unit states to "ready" on upgrade-charm
# on k8s only the upgrading unit will receive the upgrade-charm event
# and deferring will prevent the upgrade stack from being popped
logger.debug("Cluster in recovery, deferring...")
event.defer()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is the cause why the rollback gets stuck.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @dragomirp , this was causing concurrent upgrades on units, so I don't think we should revert it on the lib.
Does manual upgrades run also stuck?
Is the test timming out? I've also observed juju takes humongous amount of time to trigger upgrade-charm after a refresh being run, eating a lot of the wait period, forcing us to increase timeout times for upgrade tests.

Copy link
Member

Choose a reason for hiding this comment

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

The real issue is the following:

  • In the test_upgrade_from_edge test:
    • TimescaleDB in the snap is leading to a longer snap refresh (only some more seconds).
    • With that, Patroni is performing a failover, so a new unit, different from the Juju leader unit (the former primary), becomes the primary.
    • Also with that, the former primary unit, the Juju leader unit, becomes a replica (not a synchronous standby).
  • In the test_fail_and_rollback test:
    • After the failed upgrade, the pre-upgrade-check is run, which sets the recovery state for the Juju leader unit (which is a replica).
    • When the refresh is started, the upgrade charm event is fired in each of the three units, setting the state to ready in all of them.
    • The upgrade changed event is fired only in the non-primary units because only the relation data from the Juju leader unit changed (the state changed from recovery to ready, while in the other units, it was already set to ready, so no change, no events firing for the Juju leader unit).
    • As the Juju leader unit is the replica, it’s the top of the stack unit (the one that should be upgraded first). However, as the upgrade relation changed event hasn’t fired for it, it cannot start the upgrade (in this case is a rollback).

The new version of the upgrade library (which is being reverted through this PR) is also causing this issue to start happening because of the missing defer call that Dragomir commented about.

However, the root cause is the failover happening, which has shown a specific path of the execution that wasn’t covered by the lib. Before adding TimescaleDB, there was no failover, so the Juju leader unit was the primary during the entire test, and what happened in the test_fail_and_rollback test was the following:
* After the failed upgrade, the pre-upgrade-check is run, which sets the recovery state for the Juju leader unit (which is the primary).
* When the refresh is started, the upgrade charm event is fired in each of the three units, setting the state to ready in all of them.
* As the Juju leader unit was not the top of the stack unit, it was ok for it not to receive the upgrade relation event in the first moment.

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.

It may be fixed by canonical/data-platform-libs#176.

@dragomirp dragomirp changed the title [TEST] Test old upgrade lib [MISC] Test old upgrade lib Jun 8, 2024
@dragomirp dragomirp marked this pull request as ready for review June 8, 2024 04:19
@dragomirp dragomirp changed the title [MISC] Test old upgrade lib [MISC] Revert upgrade lib Jun 8, 2024
Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

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

LGTM. sad.

Should we test PostgreSQL test on MySQL changes? :-D

Comment on lines -944 to +933
# skip run while in recovery. The event will be retrigged when the cluster is ready
logger.debug("Cluster in recovery, skip...")
# Only defer for vm, that will set unit states to "ready" on upgrade-charm
# on k8s only the upgrading unit will receive the upgrade-charm event
# and deferring will prevent the upgrade stack from being popped
logger.debug("Cluster in recovery, deferring...")
event.defer()
Copy link
Contributor

Choose a reason for hiding this comment

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

@dragomirp
Copy link
Contributor Author

Superseded by #492

@dragomirp dragomirp closed this Jun 13, 2024
@dragomirp dragomirp deleted the test-old-upgrade-lib branch September 12, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants