Skip to content

Add refresh v3 implementation #241

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

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open

Conversation

carlcsaposs-canonical
Copy link
Contributor

@carlcsaposs-canonical carlcsaposs-canonical commented Apr 2, 2025

Uses charm-refresh Python package: https://github.com/canonical/charm-refresh

@carlcsaposs-canonical
Copy link
Contributor Author

carlcsaposs-canonical commented Apr 10, 2025

You can test the refresh with these charmhub branches (built on #242):

  • dpe/edge/test-refresh-v3-8.0.40
  • dpe/edge/test-refresh-v3-8.0.41
  • dpe/edge/test-refresh-v3-8.0.41-2 - use to test charm-only refresh from 8.0.41
  • dpe/edge/test-refresh-v3-incompat - simulates incompatible workload or charm version
  • dpe/edge/test-refresh-v3-precheckfail - simulates failed pre check
  • dpe/edge/test-refresh-v3-uncaught - simulates uncaught exception (e.g. bug, incorrect arch, etc.)
  • dpe/edge/test-refresh-v3-uncaught-before-snap-refresh - simulates uncaught exception before snap is refreshed
  • dpe/edge/test-refresh-v3-uncaught-except-upgrade-charm-event - simulates uncaught exception, but doesn't raise on upgrade-charm event (juju will get stuck on rollback if exception raised during upgrade charm event [unless --force-units used on refresh])

or modify the branch locally & re-pack the charm

@carlcsaposs-canonical
Copy link
Contributor Author

all tests passed on 16a3cbb: https://github.com/canonical/mysql-router-operator/actions/runs/16269250664?pr=241

ef71408 reverts changes for testing that needed to be reverted before release

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.

🥳

P.S. @carlcsaposs-canonical please do not forget to remove this after the merge.

def refresh_snap(
self, *, snap_name: str, snap_revision: str, refresh: charm_refresh.Machines
) -> None:
# TODO: issue on relation-broken event since event not passed? mitigated by regular event handler?
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this TODO? Are we waiting on a Juju / Ops framework bug to get fixed? It would be nice to know why this is an issue, and when could we consider it resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a potential edge case that we might need to address later, although it is unlikely to happen in production (would require the user to remove the relation while the charm is refreshing the snap)

Left the comment in case that edge case happens to become a real issue

The robustness of refresh has significantly improved from v2 in this PR, don't think this minor edge case should block

str(content),
)
charm_zip.writestr("src/snap.py", new_snap_content)
charm_zip.writestr("refresh_versions.toml", tomli_w.dumps(versions))


def create_invalid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Generic comment for the whole file

Should we replace the word upgrade by the word refresh throughout this file, in addition to the file name? Not sure if we want to continue considering this functionality as a new type of upgrade, or whether should we start calling it refresh everywhere 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't think it's too important since it doesn't affect UX

Everything that's exposed to the user has been changed to "refresh"

@@ -6,13 +6,14 @@ package-mode = false
requires-poetry = ">=2.0.0"

[tool.poetry.dependencies]
python = "^3.8.6" # ^3.8.6 required by juju
python = "^3.10"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this version bump related to the recent drop of support for Ubuntu 20.04 base? If so, could we mention the package that is making us stay in Python 3.10 (similarly to how we had it before)?

Ideally we will make this bump on a separate PR, where all the # TODO python3.10 comments are properly addressed (see GitHub search).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're staying in 3.10 since the base is 22.04. The comment was when we needed a python version higher than what's required by the base

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, UI change, or workload upgrade Libraries: Out of sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants