canonical / jhack

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

imatrix crashes on terminated application #56

Closed taurus-forever closed 1 year ago

taurus-forever commented 1 year ago

Hi,

There is a well known Juju K8s issue which causes terminated state for some application as charm got killed by juju->pebble, Fix, WIP.

the command jhack imatrix view crashes if models has such an application (see status=terminated, workload=unknown for s3-integrator):

> juju status
Model     Controller  Cloud/Region        Version  SLA          Timestamp
welcome6  charm-dev   microk8s/localhost  2.9.38   unsupported  13:29:44+01:00

App                        Version                  Status      Scale  Charm                      Channel  Rev  Address         Exposed  Message
application                                         waiting         1  application                           0  10.152.183.247  no       installing agent
mysql-k8s                  8.0.31-0ubuntu0.22.04.1  active          1  mysql-k8s                  edge      39  10.152.183.203  no       
mysql-router-k8s           8.0.30                   active          1  mysql-router-k8s                      1  10.152.183.56   no       
s3-integrator                                       terminated    0/1  s3-integrator              edge       6  10.152.183.69   no       unit stopped by the cloud
tls-certificates-operator                           active          1  tls-certificates-operator  edge      22  10.152.183.161  no       

Unit                          Workload  Agent  Address      Ports  Message
application/0*                blocked   idle   10.1.84.122         Able to write using the read-only connection
mysql-k8s/0*                  active    idle   10.1.84.125         
mysql-router-k8s/0*           active    idle   10.1.84.65          
s3-integrator/0               unknown   lost   10.1.84.118         agent lost, see 'juju show-status-log s3-integrator/0'
tls-certificates-operator/0*  active    idle   10.1.84.127         
the full trace
ubuntu@taurus-dev:~/mysql-router-k8s-operator/tests/integration/application-charm$ jhack imatrix view
ERROR pod "s3-integrator-0" not found
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /snap/jhack/186/lib/python3.8/site-packages/jhack/helpers.py:224 in fetch_file                   │
│                                                                                                  │
│   221 │   model_arg = f" -m {model}" if model else ""                                            │
│   222 │   cmd = f"juju ssh{model_arg} {unit} cat /var/lib/juju/agents/unit-{unit_sanitized}/ch   │
│   223 │   try:                                                                                   │
│ ❱ 224 │   │   raw = check_output(cmd.split())                                                    │
│   225 │   except CalledProcessError as e:                                                        │
│   226 │   │   raise RuntimeError(                                                                │
│   227 │   │   │   f"Failed to fetch {remote_path} from {unit_sanitized}."                        │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │            cmd = 'juju ssh s3-integrator/0 cat                                               │ │
│ │                  /var/lib/juju/agents/unit-s3-integrator-0/charm/met'+10                     │ │
│ │     local_path = None                                                                        │ │
│ │          model = None                                                                        │ │
│ │      model_arg = ''                                                                          │ │
│ │    remote_path = 'metadata.yaml'                                                             │ │
│ │           unit = 's3-integrator/0'                                                           │ │
│ │ unit_sanitized = 's3-integrator-0'                                                           │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /usr/lib/python3.8/subprocess.py:415 in check_output                                             │
│                                                                                                  │
│    412 │   │   │   empty = b''                                                                   │
│    413 │   │   kwargs['input'] = empty                                                           │
│    414 │                                                                                         │
│ ❱  415 │   return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,                      │
│    416 │   │   │      **kwargs).stdout                                                           │
│    417                                                                                           │
│    418                                                                                           │
│                                                                                                  │
│ ╭────────────────────────────────────── locals ───────────────────────────────────────╮          │
│ │    kwargs = {}                                                                      │          │
│ │ popenargs = (                                                                       │          │
│ │             │   [                                                                   │          │
│ │             │   │   'juju',                                                         │          │
│ │             │   │   'ssh',                                                          │          │
│ │             │   │   's3-integrator/0',                                              │          │
│ │             │   │   'cat',                                                          │          │
│ │             │   │   '/var/lib/juju/agents/unit-s3-integrator-0/charm/metadata.yaml' │          │
│ │             │   ],                                                                  │          │
│ │             )                                                                       │          │
│ │   timeout = None                                                                    │          │
│ ╰─────────────────────────────────────────────────────────────────────────────────────╯          │
│                                                                                                  │
│ /usr/lib/python3.8/subprocess.py:516 in run                                                      │
│                                                                                                  │
│    513 │   │   │   raise                                                                         │
│    514 │   │   retcode = process.poll()                                                          │
│    515 │   │   if check and retcode:                                                             │
│ ❱  516 │   │   │   raise CalledProcessError(retcode, process.args,                               │
│    517 │   │   │   │   │   │   │   │   │    output=stdout, stderr=stderr)                        │
│    518 │   return CompletedProcess(process.args, retcode, stdout, stderr)                        │
│    519                                                                                           │
│                                                                                                  │
│ ╭───────────────────────────────────────── locals ─────────────────────────────────────────╮     │
│ │ capture_output = False                                                                   │     │
│ │          check = True                                                                    │     │
│ │          input = None                                                                    │     │
│ │         kwargs = {'stdout': -1}                                                          │     │
│ │      popenargs = (                                                                       │     │
│ │                  │   [                                                                   │     │
│ │                  │   │   'juju',                                                         │     │
│ │                  │   │   'ssh',                                                          │     │
│ │                  │   │   's3-integrator/0',                                              │     │
│ │                  │   │   'cat',                                                          │     │
│ │                  │   │   '/var/lib/juju/agents/unit-s3-integrator-0/charm/metadata.yaml' │     │
│ │                  │   ],                                                                  │     │
│ │                  )                                                                       │     │
│ │        process =                              │     │
│ │        retcode = 1                                                                       │     │
│ │         stderr = None                                                                    │     │
│ │         stdout = b''                                                                     │     │
│ │        timeout = None                                                                    │     │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
CalledProcessError: Command '['juju', 'ssh', 's3-integrator/0', 'cat', '/var/lib/juju/agents/unit-s3-integrator-0/charm/metadata.yaml']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /snap/jhack/186/lib/python3.8/site-packages/jhack/utils/integrate.py:370 in show                 │
│                                                                                                  │
│   367 │   color: Optional[str] = ColorOption,                                                    │
│   368 ):                                                                                         │
│   369 │   """Display the avaiable integrations between any number of juju applications in a ni   │
│ ❱ 370 │   mtrx = IntegrationMatrix(apps=apps, model=model, color=color)                          │
│   371 │   if watch:                                                                              │
│   372 │   │   mtrx.watch(refresh_rate=refresh_rate)                                              │
│   373 │   else:                                                                                  │
│                                                                                                  │
│ ╭─────── locals ────────╮                                                                        │
│ │         apps = None   │                                                                        │
│ │        color = 'auto' │                                                                        │
│ │        model = None   │                                                                        │
│ │ refresh_rate = None   │                                                                        │
│ │        watch = None   │                                                                        │
│ ╰───────────────────────╯                                                                        │
│                                                                                                  │
│ /snap/jhack/186/lib/python3.8/site-packages/jhack/utils/integrate.py:78 in __init__              │
│                                                                                                  │
│    75 │   ):                                                                                     │
│    76 │   │   self._model = model                                                                │
│    77 │   │   self._color = color                                                                │
│ ❱  78 │   │   self._endpoints = _gather_endpoints(model, apps)                                   │
│    79 │   │   self._apps = tuple(sorted(self._endpoints))                                        │
│    80 │   │                                                                                      │
│    81 │   │   if apps:                                                                           │
│                                                                                                  │
│ ╭────────────────────────────────── locals ──────────────────────────────────╮                   │
│ │  apps = None                                                               │                   │
│ │ color = 'auto'                                                             │                   │
│ │ model = None                                                               │                   │
│ │  self =  │                   │
│ ╰────────────────────────────────────────────────────────────────────────────╯                   │
│                                                                                                  │
│ /snap/jhack/186/lib/python3.8/site-packages/jhack/utils/integrate.py:54 in _gather_endpoints     │
│                                                                                                  │
│    51 │   │                                                                                      │
│    52 │   │   app_eps = {}                                                                       │
│    53 │   │   unit = next(iter(app["units"]))                                                    │
│ ❱  54 │   │   metadata = fetch_file(unit, "metadata.yaml", model=model)                          │
│    55 │   │   meta = yaml.safe_load(metadata)                                                    │
│    56 │   │                                                                                      │
│    57 │   │   for role in ("requires", "provides"):                                              │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ all_apps = {                                                                                 │ │
│ │            │   'application': {                                                              │ │
│ │            │   │   'charm': 'local:focal/application-0',                                     │ │
│ │            │   │   'base': {'name': 'ubuntu', 'channel': '20.04'},                           │ │
│ │            │   │   'charm-origin': 'local',                                                  │ │
│ │            │   │   'charm-name': 'application',                                              │ │
│ │            │   │   'charm-rev': 0,                                                           │ │
│ │            │   │   'scale': 1,                                                               │ │
│ │            │   │   'provider-id': '0440e2ff-2cbf-4826-8190-5f790ecc3b1e',                    │ │
│ │            │   │   'address': '10.152.183.247',                                              │ │
│ │            │   │   'exposed': False,                                                         │ │
│ │            │   │   'application-status': {                                                   │ │
│ │            │   │   │   'current': 'waiting',                                                 │ │
│ │            │   │   │   'message': 'installing agent',                                        │ │
│ │            │   │   │   'since': '27 Feb 2023 13:28:35+01:00'                                 │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   ... +3                                                                    │ │
│ │            │   },                                                                            │ │
│ │            │   'mysql-k8s': {                                                                │ │
│ │            │   │   'charm': 'mysql-k8s',                                                     │ │
│ │            │   │   'base': {'name': 'kubernetes', 'channel': 'kubernetes'},                  │ │
│ │            │   │   'charm-origin': 'charmhub',                                               │ │
│ │            │   │   'charm-name': 'mysql-k8s',                                                │ │
│ │            │   │   'charm-rev': 39,                                                          │ │
│ │            │   │   'charm-channel': 'edge',                                                  │ │
│ │            │   │   'can-upgrade-to': 'ch:amd64/jammy/mysql-k8s-40',                          │ │
│ │            │   │   'scale': 1,                                                               │ │
│ │            │   │   'provider-id': 'e1edea21-6095-4786-a0fa-abb782e7d187',                    │ │
│ │            │   │   'address': '10.152.183.203',                                              │ │
│ │            │   │   ... +6                                                                    │ │
│ │            │   },                                                                            │ │
│ │            │   'mysql-router-k8s': {                                                         │ │
│ │            │   │   'charm': 'local:jammy/mysql-router-k8s-1',                                │ │
│ │            │   │   'base': {'name': 'kubernetes', 'channel': 'kubernetes'},                  │ │
│ │            │   │   'charm-origin': 'local',                                                  │ │
│ │            │   │   'charm-name': 'mysql-router-k8s',                                         │ │
│ │            │   │   'charm-rev': 1,                                                           │ │
│ │            │   │   'scale': 1,                                                               │ │
│ │            │   │   'provider-id': 'baa5d805-1ff5-4f74-b68d-5fc188f13c8b',                    │ │
│ │            │   │   'address': '10.152.183.56',                                               │ │
│ │            │   │   'exposed': False,                                                         │ │
│ │            │   │   'application-status': {                                                   │ │
│ │            │   │   │   'current': 'active',                                                  │ │
│ │            │   │   │   'since': '27 Feb 2023 13:28:13+01:00'                                 │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   ... +4                                                                    │ │
│ │            │   },                                                                            │ │
│ │            │   's3-integrator': {                                                            │ │
│ │            │   │   'charm': 's3-integrator',                                                 │ │
│ │            │   │   'base': {'name': 'ubuntu', 'channel': '22.04'},                           │ │
│ │            │   │   'charm-origin': 'charmhub',                                               │ │
│ │            │   │   'charm-name': 's3-integrator',                                            │ │
│ │            │   │   'charm-rev': 6,                                                           │ │
│ │            │   │   'charm-channel': 'edge',                                                  │ │
│ │            │   │   'scale': 1,                                                               │ │
│ │            │   │   'provider-id': '595335ff-8241-429f-89c6-d1747296ecc9',                    │ │
│ │            │   │   'address': '10.152.183.69',                                               │ │
│ │            │   │   'exposed': False,                                                         │ │
│ │            │   │   ... +5                                                                    │ │
│ │            │   },                                                                            │ │
│ │            │   'tls-certificates-operator': {                                                │ │
│ │            │   │   'charm': 'tls-certificates-operator',                                     │ │
│ │            │   │   'base': {'name': 'ubuntu', 'channel': '22.04'},                           │ │
│ │            │   │   'charm-origin': 'charmhub',                                               │ │
│ │            │   │   'charm-name': 'tls-certificates-operator',                                │ │
│ │            │   │   'charm-rev': 22,                                                          │ │
│ │            │   │   'charm-channel': 'edge',                                                  │ │
│ │            │   │   'scale': 1,                                                               │ │
│ │            │   │   'provider-id': '64a7405c-e4c3-4709-b9b6-7c18eeb3b06b',                    │ │
│ │            │   │   'address': '10.152.183.161',                                              │ │
│ │            │   │   'exposed': False,                                                         │ │
│ │            │   │   ... +4                                                                    │ │
│ │            │   }                                                                             │ │
│ │            }                                                                                 │ │
│ │      app = {                                                                                 │ │
│ │            │   'charm': 's3-integrator',                                                     │ │
│ │            │   'base': {'name': 'ubuntu', 'channel': '22.04'},                               │ │
│ │            │   'charm-origin': 'charmhub',                                                   │ │
│ │            │   'charm-name': 's3-integrator',                                                │ │
│ │            │   'charm-rev': 6,                                                               │ │
│ │            │   'charm-channel': 'edge',                                                      │ │
│ │            │   'scale': 1,                                                                   │ │
│ │            │   'provider-id': '595335ff-8241-429f-89c6-d1747296ecc9',                        │ │
│ │            │   'address': '10.152.183.69',                                                   │ │
│ │            │   'exposed': False,                                                             │ │
│ │            │   ... +5                                                                        │ │
│ │            }                                                                                 │ │
│ │  app_eps = {}                                                                                │ │
│ │ app_name = 's3-integrator'                                                                   │ │
│ │     apps = None                                                                              │ │
│ │      eps = {                                                                                 │ │
│ │            │   'application': {                                                              │ │
│ │            │   │   'requires': {'database': ('mysql_client', ['mysql-router-k8s'])},         │ │
│ │            │   │   'provides': {}                                                            │ │
│ │            │   },                                                                            │ │
│ │            │   'mysql-k8s': {                                                                │ │
│ │            │   │   'requires': {                                                             │ │
│ │            │   │   │   'certificates': ('tls-certificates', ['tls-certificates-operator']),  │ │
│ │            │   │   │   's3-parameters': ('s3', [])                                           │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'provides': {                                                             │ │
│ │            │   │   │   'mysql': ('mysql', []),                                               │ │
│ │            │   │   │   'database': ('mysql_client', ['mysql-router-k8s']),                   │ │
│ │            │   │   │   'osm-mysql': ('mysql', [])                                            │ │
│ │            │   │   }                                                                         │ │
│ │            │   },                                                                            │ │
│ │            │   'mysql-router-k8s': {                                                         │ │
│ │            │   │   'requires': {                                                             │ │
│ │            │   │   │   'backend-database': ('mysql_client', ['mysql-k8s']),                  │ │
│ │            │   │   │   'certificates': ('tls-certificates', ['tls-certificates-operator'])   │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'provides': {'database': ('mysql_client', ['application'])}               │ │
│ │            │   }                                                                             │ │
│ │            }                                                                                 │ │
│ │     meta = {                                                                                 │ │
│ │            │   'name': 'mysql-router-k8s',                                                   │ │
│ │            │   'display-name': 'MySQL Router',                                               │ │
│ │            │   'maintainers': [                                                              │ │
│ │            │   │   'Paulo Machado ',                            │ │
│ │            │   │   'Shayan Patel '                               │ │
│ │            │   ],                                                                            │ │
│ │            │   'description': 'K8S charmed operator for mysql-router.\n',                    │ │
│ │            │   'summary': 'Charmed operator for mysql-router.\nEnables effective access to   │ │
│ │            group replicated '+39,                                                            │ │
│ │            │   'containers': {'mysql-router': {'resource': 'mysql-router-image'}},           │ │
│ │            │   'provides': {'database': {'interface': 'mysql_client'}},                      │ │
│ │            │   'requires': {                                                                 │ │
│ │            │   │   'backend-database': {'interface': 'mysql_client', 'limit': 1},            │ │
│ │            │   │   'certificates': {'interface': 'tls-certificates', 'limit': 1}             │ │
│ │            │   },                                                                            │ │
│ │            │   'peers': {'mysql-router-peers': {'interface': 'mysql-router-peers'}},         │ │
│ │            │   'resources': {                                                                │ │
│ │            │   │   'mysql-router-image': {                                                   │ │
│ │            │   │   │   'type': 'oci-image',                                                  │ │
│ │            │   │   │   'description': 'OCI image for mysql-router',                          │ │
│ │            │   │   │   'upstream-source': 'dataplatformoci/mysql-router:latest'              │ │
│ │            │   │   }                                                                         │ │
│ │            │   },                                                                            │ │
│ │            │   ... +1                                                                        │ │
│ │            }                                                                                 │ │
│ │ metadata = '# Copyright 2022 Canonical Ltd.\r\n# See LICENSE file for licensing              │ │
│ │            details.\r\nname'+910                                                             │ │
│ │    model = None                                                                              │ │
│ │  remotes = .remotes at 0x7f5977664d30>                   │ │
│ │     role = 'provides'                                                                        │ │
│ │ role_eps = {'database': ('mysql_client', ['application'])}                                   │ │
│ │   status = {                                                                                 │ │
│ │            │   'model': {                                                                    │ │
│ │            │   │   'name': 'welcome6',                                                       │ │
│ │            │   │   'type': 'caas',                                                           │ │
│ │            │   │   'controller': 'charm-dev',                                                │ │
│ │            │   │   'cloud': 'microk8s',                                                      │ │
│ │            │   │   'region': 'localhost',                                                    │ │
│ │            │   │   'version': '2.9.38',                                                      │ │
│ │            │   │   'model-status': {                                                         │ │
│ │            │   │   │   'current': 'available',                                               │ │
│ │            │   │   │   'since': '24 Feb 2023 11:51:18+01:00'                                 │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'sla': 'unsupported'                                                      │ │
│ │            │   },                                                                            │ │
│ │            │   'machines': {},                                                               │ │
│ │            │   'applications': {                                                             │ │
│ │            │   │   'application': {                                                          │ │
│ │            │   │   │   'charm': 'local:focal/application-0',                                 │ │
│ │            │   │   │   'base': {'name': 'ubuntu', 'channel': '20.04'},                       │ │
│ │            │   │   │   'charm-origin': 'local',                                              │ │
│ │            │   │   │   'charm-name': 'application',                                          │ │
│ │            │   │   │   'charm-rev': 0,                                                       │ │
│ │            │   │   │   'scale': 1,                                                           │ │
│ │            │   │   │   'provider-id': '0440e2ff-2cbf-4826-8190-5f790ecc3b1e',                │ │
│ │            │   │   │   'address': '10.152.183.247',                                          │ │
│ │            │   │   │   'exposed': False,                                                     │ │
│ │            │   │   │   'application-status': {                                               │ │
│ │            │   │   │   │   'current': 'waiting',                                             │ │
│ │            │   │   │   │   'message': 'installing agent',                                    │ │
│ │            │   │   │   │   'since': '27 Feb 2023 13:28:35+01:00'                             │ │
│ │            │   │   │   },                                                                    │ │
│ │            │   │   │   ... +3                                                                │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'mysql-k8s': {                                                            │ │
│ │            │   │   │   'charm': 'mysql-k8s',                                                 │ │
│ │            │   │   │   'base': {'name': 'kubernetes', 'channel': 'kubernetes'},              │ │
│ │            │   │   │   'charm-origin': 'charmhub',                                           │ │
│ │            │   │   │   'charm-name': 'mysql-k8s',                                            │ │
│ │            │   │   │   'charm-rev': 39,                                                      │ │
│ │            │   │   │   'charm-channel': 'edge',                                              │ │
│ │            │   │   │   'can-upgrade-to': 'ch:amd64/jammy/mysql-k8s-40',                      │ │
│ │            │   │   │   'scale': 1,                                                           │ │
│ │            │   │   │   'provider-id': 'e1edea21-6095-4786-a0fa-abb782e7d187',                │ │
│ │            │   │   │   'address': '10.152.183.203',                                          │ │
│ │            │   │   │   ... +6                                                                │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'mysql-router-k8s': {                                                     │ │
│ │            │   │   │   'charm': 'local:jammy/mysql-router-k8s-1',                            │ │
│ │            │   │   │   'base': {'name': 'kubernetes', 'channel': 'kubernetes'},              │ │
│ │            │   │   │   'charm-origin': 'local',                                              │ │
│ │            │   │   │   'charm-name': 'mysql-router-k8s',                                     │ │
│ │            │   │   │   'charm-rev': 1,                                                       │ │
│ │            │   │   │   'scale': 1,                                                           │ │
│ │            │   │   │   'provider-id': 'baa5d805-1ff5-4f74-b68d-5fc188f13c8b',                │ │
│ │            │   │   │   'address': '10.152.183.56',                                           │ │
│ │            │   │   │   'exposed': False,                                                     │ │
│ │            │   │   │   'application-status': {                                               │ │
│ │            │   │   │   │   'current': 'active',                                              │ │
│ │            │   │   │   │   'since': '27 Feb 2023 13:28:13+01:00'                             │ │
│ │            │   │   │   },                                                                    │ │
│ │            │   │   │   ... +4                                                                │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   's3-integrator': {                                                        │ │
│ │            │   │   │   'charm': 's3-integrator',                                             │ │
│ │            │   │   │   'base': {'name': 'ubuntu', 'channel': '22.04'},                       │ │
│ │            │   │   │   'charm-origin': 'charmhub',                                           │ │
│ │            │   │   │   'charm-name': 's3-integrator',                                        │ │
│ │            │   │   │   'charm-rev': 6,                                                       │ │
│ │            │   │   │   'charm-channel': 'edge',                                              │ │
│ │            │   │   │   'scale': 1,                                                           │ │
│ │            │   │   │   'provider-id': '595335ff-8241-429f-89c6-d1747296ecc9',                │ │
│ │            │   │   │   'address': '10.152.183.69',                                           │ │
│ │            │   │   │   'exposed': False,                                                     │ │
│ │            │   │   │   ... +5                                                                │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'tls-certificates-operator': {                                            │ │
│ │            │   │   │   'charm': 'tls-certificates-operator',                                 │ │
│ │            │   │   │   'base': {'name': 'ubuntu', 'channel': '22.04'},                       │ │
│ │            │   │   │   'charm-origin': 'charmhub',                                           │ │
│ │            │   │   │   'charm-name': 'tls-certificates-operator',                            │ │
│ │            │   │   │   'charm-rev': 22,                                                      │ │
│ │            │   │   │   'charm-channel': 'edge',                                              │ │
│ │            │   │   │   'scale': 1,                                                           │ │
│ │            │   │   │   'provider-id': '64a7405c-e4c3-4709-b9b6-7c18eeb3b06b',                │ │
│ │            │   │   │   'address': '10.152.183.161',                                          │ │
│ │            │   │   │   'exposed': False,                                                     │ │
│ │            │   │   │   ... +4                                                                │ │
│ │            │   │   }                                                                         │ │
│ │            │   },                                                                            │ │
│ │            │   'storage': {                                                                  │ │
│ │            │   │   'storage': {                                                              │ │
│ │            │   │   │   'database/1': {                                                       │ │
│ │            │   │   │   │   'kind': 'filesystem',                                             │ │
│ │            │   │   │   │   'life': 'alive',                                                  │ │
│ │            │   │   │   │   'status': {                                                       │ │
│ │            │   │   │   │   │   'current': 'attached',                                        │ │
│ │            │   │   │   │   │   'since': '24 Feb 2023 17:59:27+01:00'                         │ │
│ │            │   │   │   │   },                                                                │ │
│ │            │   │   │   │   'persistent': False,                                              │ │
│ │            │   │   │   │   'attachments': {'units': {'mysql-k8s/0': {'life': 'alive'}}}      │ │
│ │            │   │   │   },                                                                    │ │
│ │            │   │   │   'pgdata/0': {                                                         │ │
│ │            │   │   │   │   'kind': 'filesystem',                                             │ │
│ │            │   │   │   │   'life': 'alive',                                                  │ │
│ │            │   │   │   │   'status': {                                                       │ │
│ │            │   │   │   │   │   'current': 'detached',                                        │ │
│ │            │   │   │   │   │   'since': '27 Feb 2023 13:20:33+01:00'                         │ │
│ │            │   │   │   │   },                                                                │ │
│ │            │   │   │   │   'persistent': False                                               │ │
│ │            │   │   │   }                                                                     │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'filesystems': {                                                          │ │
│ │            │   │   │   '0': {                                                                │ │
│ │            │   │   │   │   'provider-id': 'c2e37220-1122-4a68-9f7e-c63c03e52b70',            │ │
│ │            │   │   │   │   'volume': '0',                                                    │ │
│ │            │   │   │   │   'storage': 'pgdata/0',                                            │ │
│ │            │   │   │   │   'Attachments': None,                                              │ │
│ │            │   │   │   │   'pool': 'kubernetes',                                             │ │
│ │            │   │   │   │   'size': 1024,                                                     │ │
│ │            │   │   │   │   'life': 'alive',                                                  │ │
│ │            │   │   │   │   'status': {                                                       │ │
│ │            │   │   │   │   │   'current': 'detached',                                        │ │
│ │            │   │   │   │   │   'since': '27 Feb 2023 13:20:33+01:00'                         │ │
│ │            │   │   │   │   }                                                                 │ │
│ │            │   │   │   },                                                                    │ │
│ │            │   │   │   '1': {                                                                │ │
│ │            │   │   │   │   'provider-id': '58b1f1a2-3231-4e08-8cc8-99974845721b',            │ │
│ │            │   │   │   │   'volume': '1',                                                    │ │
│ │            │   │   │   │   'storage': 'database/1',                                          │ │
│ │            │   │   │   │   'Attachments': {                                                  │ │
│ │            │   │   │   │   │   'containers': {                                               │ │
│ │            │   │   │   │   │   │   'mysql-k8s/0': {                                          │ │
│ │            │   │   │   │   │   │   │   'mount-point': '/var/lib/juju/storage/database/0',    │ │
│ │            │   │   │   │   │   │   │   'read-only': False,                                   │ │
│ │            │   │   │   │   │   │   │   'life': 'alive'                                       │ │
│ │            │   │   │   │   │   │   }                                                         │ │
│ │            │   │   │   │   │   },                                                            │ │
│ │            │   │   │   │   │   'units': {'mysql-k8s/0': {'life': 'alive'}}                   │ │
│ │            │   │   │   │   },                                                                │ │
│ │            │   │   │   │   'pool': 'kubernetes',                                             │ │
│ │            │   │   │   │   'size': 1024,                                                     │ │
│ │            │   │   │   │   'life': 'alive',                                                  │ │
│ │            │   │   │   │   'status': {                                                       │ │
│ │            │   │   │   │   │   'current': 'attached',                                        │ │
│ │            │   │   │   │   │   'since': '24 Feb 2023 17:59:27+01:00'                         │ │
│ │            │   │   │   │   }                                                                 │ │
│ │            │   │   │   }                                                                     │ │
│ │            │   │   },                                                                        │ │
│ │            │   │   'volumes': {                                                              │ │
│ │            │   │   │   '0': {                                                                │ │
│ │            │   │   │   │   'provider-id': 'pvc-c2e37220-1122-4a68-9f7e-c63c03e52b70',        │ │
│ │            │   │   │   │   'storage': 'pgdata/0',                                            │ │
│ │            │   │   │   │   'pool': 'kubernetes',                                             │ │
│ │            │   │   │   │   'size': 1024,                                                     │ │
│ │            │   │   │   │   'persistent': False,                                              │ │
│ │            │   │   │   │   'life': 'alive',                                                  │ │
│ │            │   │   │   │   'status': {                                                       │ │
│ │            │   │   │   │   │   'current': 'detached',                                        │ │
│ │            │   │   │   │   │   'since': '27 Feb 2023 13:20:33+01:00'                         │ │
│ │            │   │   │   │   }                                                                 │ │
│ │            │   │   │   },                                                                    │ │
│ │            │   │   │   '1': {                                                                │ │
│ │            │   │   │   │   'provider-id': 'pvc-58b1f1a2-3231-4e08-8cc8-99974845721b',        │ │
│ │            │   │   │   │   'storage': 'database/1',                                          │ │
│ │            │   │   │   │   'attachments': {                                                  │ │
│ │            │   │   │   │   │   'containers': {                                               │ │
│ │            │   │   │   │   │   │   'mysql-k8s/0': {'read-only': False, 'life': 'alive'}      │ │
│ │            │   │   │   │   │   },                                                            │ │
│ │            │   │   │   │   │   'units': {'mysql-k8s/0': {'life': 'alive'}}                   │ │
│ │            │   │   │   │   },                                                                │ │
│ │            │   │   │   │   'pool': 'kubernetes',                                             │ │
│ │            │   │   │   │   'size': 1024,                                                     │ │
│ │            │   │   │   │   'persistent': False,                                              │ │
│ │            │   │   │   │   'life': 'alive',                                                  │ │
│ │            │   │   │   │   'status': {                                                       │ │
│ │            │   │   │   │   │   'current': 'attached',                                        │ │
│ │            │   │   │   │   │   'since': '24 Feb 2023 11:53:27+01:00'                         │ │
│ │            │   │   │   │   }                                                                 │ │
│ │            │   │   │   }                                                                     │ │
│ │            │   │   }                                                                         │ │
│ │            │   },                                                                            │ │
│ │            │   'controller': {'timestamp': '13:29:46+01:00'}                                 │ │
│ │            }                                                                                 │ │
│ │     unit = 's3-integrator/0'                                                                 │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /snap/jhack/186/lib/python3.8/site-packages/jhack/helpers.py:226 in fetch_file                   │
│                                                                                                  │
│   223 │   try:                                                                                   │
│   224 │   │   raw = check_output(cmd.split())                                                    │
│   225 │   except CalledProcessError as e:                                                        │
│ ❱ 226 │   │   raise RuntimeError(                                                                │
│   227 │   │   │   f"Failed to fetch {remote_path} from {unit_sanitized}."                        │
│   228 │   │   ) from e                                                                           │
│   229                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │            cmd = 'juju ssh s3-integrator/0 cat                                               │ │
│ │                  /var/lib/juju/agents/unit-s3-integrator-0/charm/met'+10                     │ │
│ │     local_path = None                                                                        │ │
│ │          model = None                                                                        │ │
│ │      model_arg = ''                                                                          │ │
│ │    remote_path = 'metadata.yaml'                                                             │ │
│ │           unit = 's3-integrator/0'                                                           │ │
│ │ unit_sanitized = 's3-integrator-0'                                                           │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
RuntimeError: Failed to fetch metadata.yaml from s3-integrator-0.

PietroPasotti commented 1 year ago

Mmm yea I've seen this happen also if the application isn't ready yet, i.e. if you run imatrix before the charm container has been provisioned by juju. In this specific case the obvious solution is to exclude dying applications from the matrix. Will fix.

PietroPasotti commented 1 year ago

could you try it out and see if it works? https://github.com/PietroPasotti/jhack/pull/57