Repository navigation
console-proxy: stop busy-spinning in NoVncClient.waitForNoVNCReply - #14542
Daniel-Pereira-Linux wants to merge 1 commit into
Conversation
waitForNoVNCReply() looped on isWaitForNoVnc() with no sleep, timeout or check that the connection was still alive. If the VNC socket or the websocket was closed before noVNC replied (e.g. VM restarted while the console was connecting), the thread spun at 100% CPU forever. Wait on the existing lock instead, woken by setWaitForNoVnc() and close(), and fail with a CloudRuntimeException when the client is closed, the thread is interrupted, or no reply arrives within 30 seconds. Since the wait can now fail, the viewer thread closes the client and the session on any RuntimeException, and the wait flag is set before sending the message that noVNC replies to, so a fast reply is not missed. Fixes: apache#14538
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
b0bdff4 to
40d527c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14542 +/- ##
============================================
+ Coverage 18.30% 18.38% +0.07%
- Complexity 16629 16715 +86
============================================
Files 5939 5939
Lines 537751 537775 +24
Branches 65924 65926 +2
============================================
+ Hits 98460 98846 +386
+ Misses 428085 427677 -408
- Partials 11206 11252 +46
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19921 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
Description
This PR fixes console proxy threads spinning at 100% CPU in
NoVncClient.waitForNoVNCReply()when noVNC never replies.waitForNoVNCReply()looped onisWaitForNoVnc()with no sleep, no timeout and no check that the connection was still alive. If the VNC socket or the websocket was closed before noVNC replied (for example, the VM is stopped or rebooted while the console is connecting), nothing ever cleared the flag and the thread spun forever, until thecloudservice in the CPVM was restarted.Changes:
waitForNoVNCReply()now waits on the existing lock instead of spinning.setWaitForNoVnc()andclose()wake it up. It gives up with aCloudRuntimeExceptionwhen the client is closed, the thread is interrupted, or no reply arrives within 30 seconds.ConsoleProxyNoVncClientcatchesRuntimeExceptionas well asIOException, and closes the client and the session, so the VNC socket and the websocket are not left open.Fixes: #14538
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Unit tests only. I have not tested this on a real CPVM with a KVM VM being restarted during the console connection.
NoVncClientTestand extendedConsoleProxyNoVncClientTest: reply arrives, no wait pending, timeout, client closed, thread interrupted, handshake failure closes the session, and closing the viewer while waiting stops the worker.services/console-proxy/server(with checkstyle) on JDK 21: all pass.NoVncClient, the new tests fail (including the worker that never stops aftercloseClient()), which reproduces the issue at unit test level.How did you try to break this feature and the system with this change?
Not covered: TLS/VeNCrypt backends, the tunnel and websocket-proxy paths.