Skip to content

Commit

Permalink
hold snap revision to prevent refresh (#251)
Browse files Browse the repository at this point in the history
## Issue
Snaps will auto refresh, meaning that snaps installed inside a charm and
pinned to a specific revision won't necessarily be kept at that
revision. This means a refresh will update the snap, leading to
potential errors within the charm


## Solution
hold the snap revision
  • Loading branch information
MiaAltieri authored Sep 18, 2023
1 parent 7f630c9 commit c357899
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,11 @@ def _install_snap_packages(self, packages: List[str]) -> None:
try:
snap_cache = snap.SnapCache()
snap_package = snap_cache[snap_name]

if not snap_package.present:
snap_package.ensure(
snap.SnapState.Latest, channel=snap_channel, revision=snap_revision
)
snap_package.ensure(
snap.SnapState.Latest, channel=snap_channel, revision=snap_revision
)
# snaps will auto refresh so it is necessary to hold the current revision
snap_package.hold()

except snap.SnapError as e:
logger.error(
Expand Down

0 comments on commit c357899

Please sign in to comment.