Merge ~yoshikadokawa/layer-snap:lp1938271 into layer-snap:master

Proposed by Yoshi Kadokawa
Status: Merged
Approved by: Tom Haddon
Approved revision: 52b05b8bb6b7371ceca9be7081697b14f6f231ca
Merged at revision: d935a04074740e14feb0b73d485952b2546ae04c
Proposed branch: ~yoshikadokawa/layer-snap:lp1938271
Merge into: layer-snap:master
Diff against target: 21 lines (+9/-1)
1 file modified
lib/charms/layer/snap.py (+9/-1)
Reviewer Review Type Date Requested Status
Tom Haddon Approve
James Troup (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+406295@code.launchpad.net

Commit message

Fix unexpected error when getting snap channel

LP: #1938271

Description of the change

Added extra try-exception layer to avoid unexpected errors.

To post a comment you must log in.
Revision history for this message
Yoshi Kadokawa (yoshikadokawa) wrote :

It's been a week now, but would someone be able to review this?

Revision history for this message
James Troup (elmo) wrote :

LGTM

review: Approve
Revision history for this message
Tom Haddon (mthaddon) wrote :

One small comment inline, otherwise looks good.

Revision history for this message
Tom Haddon (mthaddon) wrote :

LGTM

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision d935a04074740e14feb0b73d485952b2546ae04c

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/charms/layer/snap.py b/lib/charms/layer/snap.py
index 6909748..06cc4b1 100644
--- a/lib/charms/layer/snap.py
+++ b/lib/charms/layer/snap.py
@@ -300,7 +300,15 @@ def get_installed_channel(snapname):
300 hookenv.WARNING,300 hookenv.WARNING,
301 )301 )
302 return302 return
303 return subprocess.check_output(cmd).decode("utf-8", errors="replace").partition("tracking:")[-1].split()[0]303 try:
304 return subprocess.check_output(cmd).decode("utf-8", errors="replace").partition("tracking:")[-1].split()[0]
305 except Exception as e:
306 # If it fails to get the channel information(ex. installed via resource), return nothing.
307 hookenv.log(
308 "Cannot get snap tracking (channel): {}".format(e),
309 hookenv.WARNING,
310 )
311 return
304312
305313
306def _snap_args(314def _snap_args(

Subscribers

People subscribed via source and target branches