Repository navigation
console-proxy: stop busy-spinning in NoVncClient.waitForNoVNCReply - #14542
Open
Daniel-Pereira-Linux wants to merge 1 commit into
Open
Daniel-Pereira-Linux wants to merge 1 commit into
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)
|
Daniel-Pereira-Linux
force-pushed
the
fix/novnc-wait-busy-spin
branch
from
October 30, 2026 16:02
b0bdff4 to
40d527c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.