Skip to content

Commit

Permalink
Add logging to snap install steps (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgameiroborges authored Apr 14, 2024
1 parent b945094 commit 14d9bc5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/charms/operator_libs_linux/v2/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 4
LIBPATCH = 5


# Regex to locate 7-bit C1 ANSI sequences
Expand Down Expand Up @@ -580,10 +580,17 @@ def ensure(
# We are installing or refreshing a snap.
if self._state not in (SnapState.Present, SnapState.Latest):
# The snap is not installed, so we install it.
logger.info(
"Installing snap %s, revision %s, tracking %s", self._name, revision, channel
)
self._install(channel, cohort, revision)
else:
# The snap is installed, but we are changing it (e.g., switching channels).
logger.info(
"Refreshing snap %s, revision %s, tracking %s", self._name, revision, channel
)
self._refresh(channel=channel, cohort=cohort, revision=revision, devmode=devmode)
logger.info("The snap installation completed successfully")

self._update_snap_apps()
self._state = state
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_snap_ensure_revision():

edge_revision = None
for line in snap_info_juju:
match = re.search(r"latest/edge.*\((\d+)\)", line)
match = re.search(r"3/stable.*\((\d+)\)", line)

if match:
edge_revision = match.group(1)
Expand Down

0 comments on commit 14d9bc5

Please sign in to comment.