canonical / jhack

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

`jhack fire` cannot access the agent socket #63

Closed simondeziel closed 1 year ago

simondeziel commented 1 year ago

I tried firing an event and it failed:

$ jhack fire lxd-cloud-cell/77 cluster-relation-changed
ERROR:jhack.simulate_event:cmd juju ssh lxd-cloud-cell/77 /usr/bin/juju-exec -u lxd-cloud-cell/77 JUJU_DISPATCH_PATH=hooks/cluster-relation-changed JUJU_MODEL_NAME=test JUJU_UNIT_NAME=lxd-cloud-cell/77 JUJU_RELATION=cluster JUJU_RELATION_ID=29 ./dispatch terminated with 1
ERROR:jhack.simulate_event:stdout=b'\x1b[91mERROR\x1b[0m dialing juju run socket: dial unix /var/lib/juju/agents/unit-lxd-cloud-cell-77/run.socket: connect: permission denied\r\n'
ERROR:jhack.simulate_event:stderr=b'Connection to 10.184.166.67 closed.\r\n'
Fired cluster-relation-changed on lxd-cloud-cell/77.

The socket is only accessible by root:

$ juju ssh lxd-cloud-cell/77 ls -l /var/lib/juju/agents/unit-lxd-cloud-cell-77/run.socket
srwx------ 1 root root 0 Mar 10 14:49 /var/lib/juju/agents/unit-lxd-cloud-cell-77/run.socket
Connection to 10.184.166.67 closed.

And at least here, juju ssh uses ubuntu:

$ juju ssh lxd-cloud-cell/77 whoami
ubuntu
Connection to 10.184.166.67 closed.

Additional information:

$ snap list juju jhack
Name   Version  Rev    Tracking     Publisher   Notes
jhack  0.3.14   198    latest/edge  ppasotti    -
juju   3.1.0    22136  3.1/stable   canonical✓  -
PietroPasotti commented 1 year ago

Hey, thanks for the report! It should be fixable by adding a 'sudo' to the command if get_substrate == lxd. Will give it a shot on monday.

simondeziel commented 1 year ago

Thanks! I'm surprised that's LXD specific because it uses the same Ubuntu image as other clouds. Anyway, I'll leave that into your expert hands ;)

simondeziel commented 1 year ago

Thanks!