Skip to content

show-relation fails on surbordinate applications #179

@gboutry

Description

@gboutry

Trying to show relation of subordinate charm fails.

I tried to read the peer data of a surbordinate charm:

$ jhack show-relation ntp:ntp-peers
...
| /snap/jhack/387/lib/python3.8/site-packages/jhack/utils/show_relation.py:304 in                  │
│ get_metadata_from_status                                                                         │
│                                                                                                  │
│    301 ):                                                                                        │
│    302 │   status = _juju_status(model=model, json=True)                                         │
│    303 │   # machine status json output apparently has no 'scale'... -_-                         │
│ ❱  304 │   app_status = status["applications"][endpoint.app_name]                                │
│    305 │   if app_status.get("subordinate-to"):                                                  │
│    306 │   │   units = {}                                                                        │
│    307 │   │   # todo: need to scavenge unit names from OTHER units' .subordinates field         │
│                                                                                                  │
│ ╭────────── locals ──────────╮                                                                   │
│ │ endpoint = 'ntp:ntp-peers' │                                                                   │
│ │    model = None            │                                                                   │
│ │   status = {}              │                                                                   │
│ ╰────────────────────────────╯                                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'applications'

I tried reading juju-info:

$ jhack show-relation ntp:juju-info sunbeam-charms:juju-info
...
│ /snap/jhack/387/lib/python3.8/site-packages/jhack/utils/show_relation.py:725 in                  │
│ _coalesce_endpoint_and_n                                                                         │
│                                                                                                  │
│    722 │   │   # if either provider or requirer are not apps in this model, OR either one have   │
│    723 │   │   # suspect a malformed CMR request                                                 │
│    724 │   │   status = _juju_status(model=model, json=True)                                     │
│ ❱  725 │   │   apps = status["applications"]                                                     │
│    726 │   │   app1 = apps.get(ep_url_1.app_name)                                                │
│    727 │   │   app2 = apps.get(ep_url_2.app_name)                                                │
│    728 │   │   app_not_found = (                                                                 │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ endpoint1 = 'ntp:juju-info'                                                                  │ │
│ │ endpoint2 = 'sunbeam-charms:juju-info'                                                       │ │
│ │  ep_url_1 = 'ntp:juju-info'                                                                  │ │
│ │  ep_url_2 = 'sunbeam-charms:juju-info'                                                       │ │
│ │      flip = False                                                                            │ │
│ │     found = []                                                                               │ │
│ │     match = False                                                                            │ │
│ │     model = None                                                                             │ │
│ │       msg = "No relation found with endpoints 'ntp:juju-info' -> 'sunbeam-charms:juju-info'  │ │
│ │             i"+30                                                                            │ │
│ │         n = None                                                                             │ │
│ │  relation = Relation(                                                                        │ │
│ │             │   provider='sunbeam-machine',                                                  │ │
│ │             │   provider_endpoint='juju-info',                                               │ │
│ │             │   requirer='ntp',                                                              │ │
│ │             │   requirer_endpoint='juju-info',                                               │ │
│ │             │   interface='juju-info',                                                       │ │
│ │             │   raw_type='subordinate'                                                       │ │
│ │             )                                                                                │ │
│ │ relations = [                                                                                │ │
│ │             │   Relation(                                                                    │ │
│ │             │   │   provider='mysql',                                                        │ │
│ │             │   │   provider_endpoint='database-peers',                                      │ │
│ │             │   │   requirer='mysql',                                                        │ │
│ │             │   │   requirer_endpoint='database-peers',                                      │ │
│ │             │   │   interface='mysql_peers',                                                 │ │
│ │             │   │   raw_type='peer'                                                          │ │
│ │             │   ),                                                                           │ │
│ │             │   Relation(                                                                    │ │
│ │             │   │   provider='mysql',                                                        │ │
│ │             │   │   provider_endpoint='restart',                                             │ │
│ │             │   │   requirer='mysql',                                                        │ │
│ │             │   │   requirer_endpoint='restart',                                             │ │
│ │             │   │   interface='rolling_op',                                                  │ │
│ │             │   │   raw_type='peer'                                                          │ │
│ │             │   ),                                                                           │ │
│ │             │   Relation(                                                                    │ │
│ │             │   │   provider='mysql',                                                        │ │
│ │             │   │   provider_endpoint='upgrade',                                             │ │
│ │             │   │   requirer='mysql',                                                        │ │
│ │             │   │   requirer_endpoint='upgrade',                                             │ │
│ │             │   │   interface='upgrade',                                                     │ │
│ │             │   │   raw_type='peer'                                                          │ │
│ │             │   ),                                                                           │ │
│ │             │   Relation(                                                                    │ │
│ │             │   │   provider='ntp',                                                          │ │
│ │             │   │   provider_endpoint='ntp-peers',                                           │ │
│ │             │   │   requirer='ntp',                                                          │ │
│ │             │   │   requirer_endpoint='ntp-peers',                                           │ │
│ │             │   │   interface='ntp',                                                         │ │
│ │             │   │   raw_type='peer'                                                          │ │
│ │             │   ),                                                                           │ │
│ │             │   Relation(                                                                    │ │
│ │             │   │   provider='sunbeam-machine',                                              │ │
│ │             │   │   provider_endpoint='juju-info',                                           │ │
│ │             │   │   requirer='ntp',                                                          │ │
│ │             │   │   requirer_endpoint='juju-info',                                           │ │
│ │             │   │   interface='juju-info',                                                   │ │
│ │             │   │   raw_type='subordinate'                                                   │ │
│ │             │   )                                                                            │ │
│ │             ]                                                                                │ │
│ │    status = {}                                                                               │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'applications'

Status output:

$ juju status --relations
Model   Controller  Cloud/Region         Version  SLA          Timestamp
testos  lxd         localhost/localhost  3.5.3    unsupported  14:42:54+02:00

App              Version  Status  Scale  Charm            Channel        Rev  Exposed  Message
ntp              4.2      active      5  ntp              latest/stable   50  no       chrony: Ready
sunbeam-machine           active      5  sunbeam-machine  2024.1/edge     36  no       

Unit                Workload  Agent  Machine  Public address                          Ports    Message
sunbeam-machine/0*  active    idle   1        fd00:56ad:9f7a:9800:216:3eff:fe8f:5914           
  ntp/5             active    idle            fd00:56ad:9f7a:9800:216:3eff:fe8f:5914  123/udp  chrony: Ready
sunbeam-machine/1   active    idle   2        fd00:56ad:9f7a:9800:216:3eff:fe39:b945           
  ntp/0             active    idle            fd00:56ad:9f7a:9800:216:3eff:fe39:b945  123/udp  chrony: Ready
sunbeam-machine/2   active    idle   3        fd00:56ad:9f7a:9800:216:3eff:fe74:b927           
  ntp/1*            active    idle            fd00:56ad:9f7a:9800:216:3eff:fe74:b927  123/udp  chrony: Ready
sunbeam-machine/3   active    idle   4        fd00:56ad:9f7a:9800:216:3eff:fe3c:37ca           
  ntp/4             active    idle            fd00:56ad:9f7a:9800:216:3eff:fe3c:37ca  123/udp  chrony: Ready
sunbeam-machine/4   active    idle   5        fd00:56ad:9f7a:9800:216:3eff:febe:90a5           
  ntp/3             active    idle            fd00:56ad:9f7a:9800:216:3eff:febe:90a5  123/udp  chrony: Ready

Machine  State    Address                                 Inst id        Base          AZ  Message
1        started  fd00:56ad:9f7a:9800:216:3eff:fe8f:5914  juju-a1d33d-1  [email protected]      Running
2        started  fd00:56ad:9f7a:9800:216:3eff:fe39:b945  juju-a1d33d-2  [email protected]      Running
3        started  fd00:56ad:9f7a:9800:216:3eff:fe74:b927  juju-a1d33d-3  [email protected]      Running
4        started  fd00:56ad:9f7a:9800:216:3eff:fe3c:37ca  juju-a1d33d-4  [email protected]      Running
5        started  fd00:56ad:9f7a:9800:216:3eff:febe:90a5  juju-a1d33d-5  [email protected]      Running

Integration provider       Requirer       Interface  Type         Message
ntp:ntp-peers              ntp:ntp-peers  ntp        peer         
sunbeam-machine:juju-info  ntp:juju-info  juju-info  subordinate        

jhack version: jhack 0.4.3.2.1 --DEVMODE--
juju version: 3.5.3


Note: if trying to reproduce with these 2 specific charms, know that sunbeam-machine and ntp won't work in a container, they need to be deployed on a VM (--constraints virt-type=virtual-machine to get a LXD vm on a LXD cloud)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions