Visualizing relation databags for development and debugging

I am working on a charm library to implement a relation interface, and I soon discovered the pain of constantly running juju show-unit unitA/0 to check the relation databag contents. In particular my library does some back and forth between the related units exchanging application and unit data on both sides, so that means running juju show-unit unitB/0 as well to see what’s going on over there.

I thought, wouldn’t it be nice to see all databags (application, unit) side by side, updating live as the related charms β€˜talk’?

Well, it would. So here is show-relation:

$ jhack utils show-relation prometheus-k8s/0:ingress traefik-k8s/0:ingress-per-unit --watch
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ category         ┃     keys ┃ prometheus-k8s/0                                 ┃ traefik-k8s/0      ┃
┑━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
β”‚ metadata         β”‚ endpoint β”‚ 'ingress'                                        β”‚ 'ingress-per-unit' β”‚
β”‚                  β”‚   leader β”‚ True                                             β”‚ True               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ application data β”‚     data β”‚ ingress:                                         β”‚                    β”‚
β”‚                  β”‚          β”‚   prometheus-k8s/0:                              β”‚                    β”‚
β”‚                  β”‚          β”‚     url: http://foo.bar:80/test-prometheus-k8s-0 β”‚                    β”‚
β”‚ unit data        β”‚     data β”‚ host: 10.1.232.174                               β”‚                    β”‚
β”‚                  β”‚          β”‚ model: test                                      β”‚                    β”‚
β”‚                  β”‚          β”‚ name: prometheus-k8s/0                           β”‚                    β”‚
β”‚                  β”‚          β”‚ port: 9090                                       β”‚                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

*(but then with colors)

Future work

  • showing more than two units (useful for e.g. peer relations)
  • figuring out how to handle large lists of units where the contents wouldn’t fit on the console.
7 Likes

This is very interesting! @hallback @joakimnyman @jamesbeedy @heitor @emcp

1 Like

Excellent tool! It’s making my current development a lot easier.

1 Like

fyi I fixed the presentation of the data: now the data shows solely under the unit that owns it. The new layout is now consistent:

Unit A                                     Unit B
Unit A's app databag contents              Unit B's app databag contents
Unit A's unit databag contents             Unit B's unit databag contents