Repository navigation
pin vncserver and vncpasswd to paths and adds vnc tests - #1006
Conversation
vncserver and vncpasswd to paths and vnc testsvncserver and vncpasswd to paths and adds vnc tests
|
Ensure this is merged before #1013 and i will rebase that PR after this is merged. |
Bubballoo3
left a comment
There was a problem hiding this comment.
In trying to test this in practice, but with OSC being pretty slow at the moment I think I'm gonna have to wait for next week. I did encounter something though, and would be curious if you can replicate the issue or if I am doing something wrong
| # awk's system() runs a new shell, so expand the command here | ||
| # and hand it to awk; an unexported $VNCSERVER_CMD would | ||
| # otherwise be lost in that shell. | ||
| %(#{vncserver_cmd} -list | awk -v vncserver_cmd="#{vncserver_cmd}" '/^:/{system("kill -0 "$2" 2>/dev/null || " vncserver_cmd " -kill "$1)}') |
There was a problem hiding this comment.
On an OSC compute node with a desktop running, I ran
[bsingleton@a0347 ~]$ vncserver -list
WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:11 2926002
[bsingleton@a0347 ~]$ vncserver -list | awk -v vncserver_cmd="vncserver" '/^:/{system("kill -0 "$2" 2>/dev/null || " vncserver_cmd " -kill "$1)}'
[bsingleton@a0347 ~]$ vncserver -list
WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:11 2926002Which seems to suggest that the process was not actually killed. Are you able to replicate this or is this line of testing faulty somehow?
Note: I made this a comment because I did the same line of testing on the previous version and found the same result. So I am mostly wondering if I have encountered something legit that I should make an issue for.
There was a problem hiding this comment.
Thanks for digging into this, Braeden. I think what you saw is expected rather than a bug: the cleanup line only runs vncserver -kill when kill -0 <pid> fails, i.e. when the session's PID is already dead. With a desktop running, :11 is live, so it's left alone. The old version behaved the same way, since the awk -v change only affects which binary gets called.
I checked on OSC compute nodes (tigervnc-server-1.14.1-10.el9_6, same deprecated wrapper):
- Live session:
kill -0 <pid>exits 0, the cleanup line runs, and the session is still listed afterward. - Crashed session (
kill -9on the Xvnc process): the entry drops out ofvncserver -liston its own, so the cleanup line gets empty input and does nothing, with no errors.
What I haven't exercised with the real binary is the dead-PID branch actually calling vncserver -kill, since I couldn't get a stale entry to stay listed on 1.14. Only the fake-vncserver test in vnc_test.rb covers that.
If you want to reproduce this yourself, use an interactive job rather than an OOD desktop (killing Xvnc under a desktop ends the job):
srun -A <project> -N 1 -n 1 -t 00:30:00 --pty /bin/bash
vncserver :77 -geometry 800x600 -SecurityTypes None -localhost # only if you have no ~/.vnc/passwd
vncserver -list
P=$(vncserver -list 2>/dev/null | awk -v d=":77" '$1==d{print $2}')
kill -0 "$P"; echo $? # 0 -> live; run the cleanup one-liner, session stays listed
kill -9 "$P"; sleep 2
vncserver -list # entry gone; cleanup one-liner is a no-opUnrelated to this PR: vncserver on these nodes prints a deprecation warning saying it's replaced by a systemd unit, so it may be worth checking whether -kill keeps working there long-term.
There was a problem hiding this comment.
Notice that that's tigervnc that's installed on the machine - you need to load a module for turbovnc.
that said, that expression doesn't work and the script just works by coincidence because after it executes that (that doesn't work) it then executes the next line that does work.
ood_core/lib/ood_core/batch_connect/templates/vnc.rb
Lines 201 to 202 in 88deb05
Unrelated to this PR: vncserver on these nodes prints a deprecation warning saying it's replaced by a systemd unit, so it may be worth checking whether -kill keeps working there long-term.
For that reason above, I think -kill ${display} is actually the only reliable way we should be killing these servers. Not only does that awk expression not work, when it issues -list it could list out other vncservers from your other jobs on the same compute node and kill them. Display on the other hand is unique to this current job.
There was a problem hiding this comment.
I am happy to move forward with this as I have been able to test it out in the wild and confirm both that the default state remains the same (previous apps continue to work unchanged) and that individual apps can set the commands in submit.yml.
I have not been able to find the a way to propagate environment variables to the template script (I've tried exporting from before.sh and setting job_environment in submit.yml with no success.) Throwing it out there not because I suspect anything is wrong, just not sure what the env variable case looks like in practice.
- the up-front check and the TigerVNC message use vncserver_cmd, so a vncserver pinned outside PATH (#1006) isn't reported as missing - messages say 'VNC server' so no bare vncserver lands in the script - tests write the script to a file instead of a giant bash -c argument - tests prepend the fake commands to PATH instead of symlinking the real ones; the two missing-vncserver tests skip if a real one is installed - add tests for a pinned vncserver outside PATH, found and missing
* show clear errors for missing vnc * check vncserver_cmd, not PATH, and address review on tests - the up-front check and the TigerVNC message use vncserver_cmd, so a vncserver pinned outside PATH (#1006) isn't reported as missing - messages say 'VNC server' so no bare vncserver lands in the script - tests write the script to a file instead of a giant bash -c argument - tests prepend the fake commands to PATH instead of symlinking the real ones; the two missing-vncserver tests skip if a real one is installed - add tests for a pinned vncserver outside PATH, found and missing
What does this PR do?
Lets sites pin
vncserverandvncpasswdto full paths in the VNC template, the same waywebsockifyalready works. A user's.bashrc(a conda env, for example) can put other binaries ahead of the site's onPATH.vncserver_cmdandvncpasswd_cmd, defaulting to${VNCSERVER_CMD:-vncserver}and${VNCPASSWD_CMD:-vncpasswd}. With neither set, the script runs the same bare commands as before.vnc.rbuse them.vncserver -killinside awk'ssystem(), which starts a new shell. The command is now expanded by bash and passed in withawk -v, so aVNCSERVER_CMDthat's set but not exported still takes effect there.Related issue
#208. This covers ood_core's side; see below.
Testing
New
test/batch_connect/vnc_test.rb, the first tests for the VNC template:vncserver/vncpasswdcalls remainvncserverscripts: it uses the configured command even whenVNCSERVER_CMDisn't exported, and kills only dead sessionsAll five tests fail against master's
vnc.rb. Reverting just theawk -vchange fails the not-exported test.Checklist
websockify_cmd; I can follow up there.Anything else?
openssl, which ood_core has never called. It's inbc_osc_jupyter/template/before.sh.erb, which still runs a bareopenssl dgst -sha1. That needs its own fix in that repo, so it may make sense to keep Make batch connect dependencies less dependent on $PATH #208 open for it or move it there.vnc_container.rbhas the same bare calls. I left it out becausevnc_containererror inclean_upfunction #931 changes itsvncserver -killline; I'll follow up once that merges.