canonical / jhack

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

`jhack sync` is not syncing #122

Closed leopaul36 closed 8 months ago

leopaul36 commented 8 months ago

I did find issue (https://github.com/canonical/jhack/issues/73) but I figured I should open a new one.

jhack utils sync validator01

ready to sync to:
        validator01/0
watching:
        /home/leo/xxx/src/ansible_runner_helper.py
        /home/leo/xxx/src/charm.py
        /home/leo/xxx/src/ops_helper.py
        /home/leo/xxx/src/error_handler.py
        /home/leo/xxx/lib/charms/operator_libs_linux/v0/apt.py
        /home/leo/xxx/lib/charms/operator_libs_linux/v1/systemd.py
Ctrl+C to interrupt
synced /home/leo/xxx/src/charm.py -> validator01/0

I can then see that the /var/lib/juju/agents/unit-validator01-0/charm/src/charm.py file has not changed

I did re-install jhack a couple times, ran both sudo snap connect jhack:dot-local-share-juju snapd and sudo snap connect jhack:ssh-read snapd but still with no luck.

leopaul36 commented 8 months ago

Just noticed I have so weird ssl errors by trying to run jhack fire:

jhack fire validator01/0 update-status
ERROR:jhack.simulate_event:cmd juju ssh validator01/0 sudo /usr/bin/juju-exec -u validator01/0 JUJU_DISPATCH_PATH=hooks/update-status JUJU_MODEL_NAME=local-network JUJU_UNIT_NAME=validator01/0 ./dispatch terminated with 127
ERROR:jhack.simulate_event:stdout=b''
ERROR:jhack.simulate_event:stderr=b'ssh: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory\n'
Fired update-status on validator01/0.

I did tried this with no luck.

PietroPasotti commented 8 months ago

I'm assuming you're on a lxd model? I think there's something wrong with juju ssh. Can you shell into the unit? Can you juju scp to the unit? I'd start by debugging from there: if that doesn't work, it's not an issue with jhack (aside possibly some better error surfacing) you can set the LOGLEVEL envvar to DEBUG before your jhack commands to see if you catch some more error messages.

leopaul36 commented 8 months ago

Hey @PietroPasotti, thanks for helping

Both juju ssh and juju scp work:

juju ssh validator01/0 date

Wed Jan 17 10:50:08 UTC 2024
Connection to fd42:77c2:c77f:12a9:216:3eff:fe1d:5ab5 closed.
juju scp validator01/0:/var/log/syslog .

head -n2 syslog
Jan 17 10:42:38 juju-a50ad2-0 keyboard-setup.sh[63]: Couldn't get a file descriptor referring to the console.
Jan 17 10:42:38 juju-a50ad2-0 keyboard-setup.sh[65]: Couldn't get a file descriptor referring to the console

Here's the output of LOGLEVEL=DEBUG jhack fire validator01/0 update-status:

INFO:jhack:jhack running in snapped mode. Checking configuration...
INFO:jhack:juju command is b'/snap/jhack/277/bin/juju\n'
DEBUG:parse:format '{_}: {timestamp:ti} {_}' -> '(.+?): (?P<timestamp>(\\d{4}-\\d\\d-\\d\\d)((\\s+|T)(\\d{1,2}:\\d{1,2}(:\\d{1,2}(\\.\\d+)?)?))?(Z|\\s*[-+]\\d\\d:?\\d\\d)?) (.+?)'
DEBUG:parse:format '{_}: {timestamp:tt} {_}' -> '(.+?): (?P<timestamp>(\\d{1,2}:\\d{1,2}(:\\d{1,2}(\\.\\d+)?)?)?(\\s+[AP]M)?(\\s+[-+]\\d\\d?:?\\d\\d)?) (.+?)'
::= Verbose mode (DEBUG). =::
INFO:jhack.simulate_event:juju ssh validator01/0 sudo /usr/bin/juju-exec -u validator01/0 JUJU_DISPATCH_PATH=hooks/update-status JUJU_MODEL_NAME=local-network JUJU_UNIT_NAME=validator01/0 ./dispatch
ERROR:jhack.simulate_event:cmd juju ssh validator01/0 sudo /usr/bin/juju-exec -u validator01/0 JUJU_DISPATCH_PATH=hooks/update-status JUJU_MODEL_NAME=local-network JUJU_UNIT_NAME=validator01/0 ./dispatch terminated with 127
ERROR:jhack.simulate_event:stdout=b''
ERROR:jhack.simulate_event:stderr=b'ssh: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory\n'
Fired update-status on validator01/0.

What's weird is that running juju ssh validator01/0 sudo /usr/bin/juju-exec -u validator01/0 JUJU_DISPATCH_PATH=hooks/update-status JUJU_MODEL_NAME=local-network JUJU_UNIT_NAME=validator01/0 ./dispatch manually does work...

PietroPasotti commented 8 months ago

Yeah probably something to do with jhack snap confinement... I assume you're using jhack from snap. If you're willing to install it from sources you should be able to use all commands more freely until I figure out what's going on.

For me it doesn't actually work manually either, which is fun.

PietroPasotti commented 8 months ago

Rescoped #113; closing this as duplicate as it seems to be the same issue

leopaul36 commented 8 months ago

Yeah probably something to do with jhack snap confinement... I assume you're using jhack from snap. If you're willing to install it from sources you should be able to use all commands more freely until I figure out what's going on.

For me it doesn't actually work manually either, which is fun.

Installing via pip did the trick. sync is now working as expected.

Thanks again :+1:

PietroPasotti commented 8 months ago

It will also work again from snap once I release #123 which should be in a few minutes