canonical / jhack

Chock-full of Juju hackery.
Apache License 2.0
50 stars 24 forks source link

make jhack work with beta juju releases #32

Closed jamesbeedy closed 1 year ago

jamesbeedy commented 1 year ago

Running jhack and using juju from latest/edge gives an error (from what looks like some version or tag parsing).

$ jhack
Traceback (most recent call last):
  File "/snap/jhack/124/bin/jhack", line 5, in <module>
    from jhack.main import main
  File "/snap/jhack/124/lib/python3.8/site-packages/jhack/main.py", line 34, in <module>
    from jhack.utils.event_recorder.client import (
  File "/snap/jhack/124/lib/python3.8/site-packages/jhack/utils/event_recorder/client.py", line 19, in <module>
    from jhack.utils.simulate_event import _simulate_event
  File "/snap/jhack/124/lib/python3.8/site-packages/jhack/utils/simulate_event.py", line 9, in <module>
    _J_EXEC_CMD = "juju-exec" if juju_agent_version() >= (3, 0) else "juju-run"
  File "/snap/jhack/124/lib/python3.8/site-packages/jhack/helpers.py", line 145, in juju_agent_version
    return tuple(map(int, agent_version.split(".")))
ValueError: invalid literal for int() with base 10: '1-beta1'
$ snap info jhack
name:      jhack
summary:   Make charming charming again.
publisher: Pietro Pasotti (ppasotti)
store-url: https://snapcraft.io/jhack
contact:   pietro.pasotti@canonical.com
license:   unset
description: |
  An opinionated collection of scripts and utilities for charmers.

  In order to use the cli tools that hit the juju api, you'll need to connect the
  dot-local-share-juju interface.

  Command: `sudo snap connect jhack:dot-local-share-juju snapd`

  Jhack needs that interface to obtain WRITE access to `~/.local/share/juju`, which is the folder
  where your local juju client stores its state, including:
    - cloud credentials
    - what controllers are registered, which controller is current
    - what models are present on each controller, which model is current

  If you see errors like:

      ERROR cannot load ssh client keys: open /home/pietro/.local/share/juju/ssh: permission denied
      No relations found in model None.

  Then you probably forgot to connect that plug.
commands:
  - jhack
snap-id:      gnxWJ9Sdlew4qfduWHEW8oczvdo2mvTT
tracking:     latest/candidate
refresh-date: 14 days ago, at 23:01 UTC
channels:
  latest/stable:    0.3.2 2022-11-02 (120) 99MB -
  latest/candidate: 0.3.2 2022-11-22 (124) 99MB -
  latest/beta:      0.3.2 2022-11-22 (124) 99MB -
  latest/edge:      0.3.3 2022-12-02 (133) 99MB -
installed:          0.3.2            (124) 99MB -
[localhost-localhost:controller]
bdx@raton00:~/allcode/github/omnivector/slurm-bundles
$ 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:     latest/edge
refresh-date: today at 18:08 UTC
channels:
  2.9/stable:       2.9.37            2022-11-14 (21315) 96MB classic
  2.9/candidate:    ↑                                         
  2.9/beta:         ↑                                         
  2.9/edge:         2.9.38-4985b7c    2022-12-05 (21630) 97MB classic
  latest/stable:    2.9.37            2022-11-14 (21315) 96MB classic
  latest/candidate: ↑                                         
  latest/beta:      ↑                                         
  latest/edge:      3.1-beta1-565f2ac 2022-12-05 (21634) 77MB -
  3.1/stable:       –                                         
  3.1/candidate:    –                                         
  3.1/beta:         –                                         
  3.1/edge:         3.1-beta1-565f2ac 2022-12-05 (21634) 77MB -
  3.0/stable:       3.0.2             2022-12-01 (21474) 76MB -
  3.0/candidate:    ↑                                         
  3.0/beta:         ↑                                         
  3.0/edge:         3.0.3-10fda27     2022-12-05 (21638) 76MB -
  2.8/stable:       2.8.13            2021-11-11 (17665) 74MB classic
  2.8/candidate:    ↑                                         
  2.8/beta:         ↑                                         
  2.8/edge:         ↑                                         
  2.7/stable:       2.7.8             2020-07-22 (13563) 77MB classic
  2.7/candidate:    ↑                                         
  2.7/beta:         ↑                                         
  2.7/edge:         ↑                                         
installed:          3.1-beta1-565f2ac            (21634) 77MB -
PietroPasotti commented 1 year ago

Should be fixed by https://github.com/PietroPasotti/jhack/commit/6c5db8ebde8f8d9091ed28d1bcb2d4344b270a7c

in 0.3.4