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

Add logging to snap install steps #119

Merged
merged 10 commits into from
Apr 14, 2024
Merged

Conversation

lucasgameiroborges
Copy link
Member

Add log messages to signal snap installation/refresh steps, so the user can check how long it took.

Motivated by https://warthogs.atlassian.net/browse/DPE-3845

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this change needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

test was failing, looks like latest/edge is no longer part of the ouput of snap info juju, causing this regex search to fail. Since the focus of the test wasn't to install the revision of latest/edge in particular, I changed it to 3/stable.

ubuntu@ip-172-31-6-38:~$ snap info juju
name:      juju
summary:   Juju - a model-driven operator lifecycle manager for K8s and machines
publisher: Canonical✓
store-url: https://snapcraft.io/juju
contact:   https://canonical.com/
license:   AGPL-3.0
description: |
  A model-driven **universal operator lifecycle manager** for multi cloud and hybrid cloud
  application management on K8s and machines.
  
  **What is an operator lifecycle manager?**
  Kubernetes operators are containers with operations code, that drive your applications on K8s.
  Juju is an operator lifecycle manager that manages the installation, integration and configuration
  of operators on the cluster. Juju also extends the idea of operators to traditional application
  management on Linux and Windows servers, or cloud instances.
  
  **Model-driven operations and integration**
  Organise your operators into models, which group together applications that can be tightly
  integrated on the same substrate and operated by the same team. Capture resource allocation,
  storage, networking and integration information in the model to simplify ongoing operations.
  
  **Better day-2 operations**
  Each operator code package, called a charm, declares methods for actions like back, restore, or
  security audit. Calling these methods provides remote administration of the application with no
  low-level access required.
  
  **Learn more**
  
   - https://juju.is/
   - https://discourse.charmhub.io/
   - https://github.com/juju/juju
commands:
  - juju
services:
  juju.fetch-oci: oneshot, disabled, inactive
snap-id:      e2CPHpB1fUxcKtCyJTsm5t3hN9axJ0yj
tracking:     3/stable
refresh-date: 8 days ago, at 05:44 UTC
channels:
  3/stable:      3.4.2             2024-04-06 (26968)  98MB -
  3/candidate:   ↑                                          
  3/beta:        ↑                                          
  3/edge:        ↑                                          
  4.0/stable:    –                                          
  4.0/candidate: –                                          
  4.0/beta:      4.0-beta2         2024-01-11 (25984)  98MB -
  4.0/edge:      4.0-beta3-4211156 2024-04-04 (26932)  98MB -
  4/stable:      –                                          
  4/candidate:   –                                          
  4/beta:        4.0-beta2         2024-01-17 (25984)  98MB -
  4/edge:        ↑                                          
  3.5/stable:    –                                          
  3.5/candidate: –                                          
  3.5/beta:      –                                          
  3.5/edge:      3.5-beta1-9a37403 2024-04-04 (26924)  98MB -
  3.4/stable:    3.4.2             2024-04-06 (26968)  98MB -
  3.4/candidate: ↑                                          
  3.4/beta:      ↑                                          
  3.4/edge:      3.4.2-4023207     2024-04-04 (26925)  98MB -
  3.3/stable:    3.3.4             2024-04-10 (26984)  98MB -
  3.3/candidate: ↑                                          
  3.3/beta:      ↑                                          
  3.3/edge:      3.3.4-8705907     2024-04-04 (26922)  99MB -
  3.2/stable:    3.2.4             2023-11-22 (25443)  95MB -
  3.2/candidate: ↑                                          
  3.2/beta:      ↑                                          
  3.2/edge:      3.2.5-9e20221     2023-11-17 (25455)  95MB -
  3.1/stable:    3.1.8             2024-04-12 (26977)  95MB -
  3.1/candidate: ↑                                          
  3.1/beta:      ↑                                          
  3.1/edge:      3.1.8-810900f     2024-04-05 (26958)  95MB -
  2.9/stable:    2.9.49            2024-04-08 (26973) 120MB classic
  2.9/candidate: 2.9.49            2024-04-08 (26973) 120MB classic
  2.9/beta:      ↑                                          
  2.9/edge:      2.9.49-a0e0041    2024-04-04 (26919) 120MB classic
  2.8/stable:    2.8.13            2021-11-11 (17665)  74MB classic
  2.8/candidate: ↑                                          
  2.8/beta:      ↑                                          
  2.8/edge:      ↑                                          
installed:       3.4.2                        (26968)  98MB -

@benhoyt
Copy link
Collaborator

benhoyt commented Apr 14, 2024

Seems reasonable to me. @tonyandrewmeyer, could you please review as well?

@lucasgameiroborges
Copy link
Member Author

Still not sure what's causing test_snap_set_and_get_with_typed to fail btw, my change should've been neutral AFAICT...

@benhoyt
Copy link
Collaborator

benhoyt commented Apr 14, 2024

Hmm, me neither. I re-ran in case it was a network glitch, but it failed again. @lucasgameiroborges Are you able to please spend some time looking into it, or at least improving the logging so we can see what's going on?

Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

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

Fine with the change in general, but let's not use f-strings in logging.

lib/charms/operator_libs_linux/v2/snap.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

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

Looks great to me, thanks! The 3/stable change makes sense based on how Juju has change things recently, if I'm understanding correctly.

I'm assuming here that the test issue will get resolved and is not related here, but can re-review if that's wrong.

@lucasgameiroborges
Copy link
Member Author

CI just passed in newest commit. Unless the error was being caused by me using f-strings inside logger calls, it seems like the test fail was transient. The logged messages in the CI looked kind of transient-ish to me and didn't give me much hints for investigation:

error: cannot perform the following tasks:
- Run configure hook of "lxd" snap if present (run hook "configure": error: cannot communicate with server: Post "http://localhost/v2/snapctl": dial unix /run/snapd-snap.socket: connect: no such file or directory)

[...]

   File "/home/runner/work/operator-libs-linux/operator-libs-linux/lib/charms/operator_libs_linux/v2/snap.py", line 280, in _snap
    raise SnapError(
charms.operator_libs_linux.v2.snap.SnapError: Snap: 'lxd'; command ['snap', 'refresh', 'lxd', '--channel="latest"'] failed with output = '2024-04-14T21:21:26Z INFO Waiting for "snap.lxd.daemon.service" to stop.\n'

That being said, I don't see anything fishy in the code itself. @benhoyt and @tonyandrewmeyer, let me know if you want me to investigate this further.

@benhoyt benhoyt merged commit 14d9bc5 into canonical:main Apr 14, 2024
5 checks passed
@benhoyt
Copy link
Collaborator

benhoyt commented Apr 14, 2024

Merged. Thanks for the LIBPATCH version bump, too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants