canonical / jhack

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

jhack tail doesn't like subordinates #15

Closed sabaini closed 2 years ago

sabaini commented 2 years ago

Afaict jhack tail parsing of juju status chokes on subordinates.

When running jhack tail against a model full of machine charms (OpenStack) I'm getting this traceback

Traceback (most recent call last):
  File "/home/peter/src/juju/jhack/jhack/main.py", line 108, in <module>
    main()
  File "/home/peter/src/juju/jhack/jhack/main.py", line 104, in main
    app()
  File "/home/peter/venv/devtools/lib/python3.10/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/home/peter/venv/devtools/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/peter/venv/devtools/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/peter/venv/devtools/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/peter/venv/devtools/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/peter/venv/devtools/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/peter/venv/devtools/lib/python3.10/site-packages/typer/main.py", line 500, in wrapper
    return callback(**use_params)  # type: ignore
  File "/home/peter/src/juju/jhack/jhack/utils/tail_charms.py", line 964, in tail_events
    return _tail_events(
  File "/home/peter/src/juju/jhack/jhack/utils/tail_charms.py", line 1013, in _tail_events
    targets = parse_targets(targets)
  File "/home/peter/src/juju/jhack/jhack/utils/tail_charms.py", line 87, in parse_targets
    return get_all_units()
  File "/home/peter/src/juju/jhack/jhack/utils/tail_charms.py", line 80, in get_all_units
    target = Target.from_name(first_part)
  File "/home/peter/src/juju/jhack/jhack/utils/tail_charms.py", line 48, in from_name
    app, unit_ = name.split("/")
ValueError: not enough values to unpack (expected 2, got 1)
PietroPasotti commented 2 years ago

Thanks for reporting @sabaini! To help me repro (and to add to the itests), could you dump the juju debug-log --replay to a file and attach it here?

sabaini commented 2 years ago

Sure -- here you go: juju-log-replay.txt.gz

PietroPasotti commented 2 years ago

Humm, there are several odd things about that log trace. Firstly, I can only see 'update-status', secondly the log formatting is not one I'm familiar with. I see the uniter event log line goes: "(via explicit, bespoke hook script)", which I've never seen before. That is not a format that jhack tail supports ATM, so even if it didn't crash there, I doubt it would pick any logs up.

Did you set model-config logging-config="<root>=WARNING;unit=DEBUG"? (you should)

I managed to reproduce the issue deploying ceilometer + prometheus-node-exporter as a subordinate, there is indeed an issue there. Troubleshooting...

PietroPasotti commented 2 years ago

Fixed it! It was indeed an issue with parsing the status when it included subordinate charms.

PietroPasotti commented 2 years ago

@sabaini could you verify that #17 solves the issue?

sabaini commented 2 years ago

Indeed it does, thank you!