Backport: Honour consoleproxy.session.timeout for noVNC console sessions - #13058
Backport: Honour consoleproxy.session.timeout for noVNC console sessions#13058dheeraj12347 wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to backport the fix to ensure consoleproxy.session.timeout is honored for noVNC console sessions on the 4.20 branch, so idle sessions are cleaned up and don’t linger indefinitely.
Changes:
- Updates the noVNC WebSocket handler with additional logging, parameter validation, and safer frame/error handling.
- Refactors the console proxy GC thread loop and related logging around idle session cleanup.
- Adjusts console proxy startup/authentication reflection and noVNC viewer creation/replacement logic.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVNCHandler.java | WebSocket connect/frame/error handling changes intended to support correct idle-session cleanup. |
| services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyGCThread.java | GC loop refactor and idle session timeout constant/comment updates. |
| services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java | Console proxy startup/auth reflection changes and noVNC viewer lifecycle adjustments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #13058 +/- ##
=============================================
- Coverage 16.26% 4.14% -12.12%
=============================================
Files 5667 405 -5262
Lines 500731 33025 -467706
Branches 60803 5898 -54905
=============================================
- Hits 81455 1370 -80085
+ Misses 410172 31479 -378693
+ Partials 9104 176 -8928
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:
|
|
Thanks for the detailed review and suggestions from Copilot. |
|
@dheeraj12347 , I set consoleproxy.session.timeout to 30000, expecting my consoles to get lost in half a minute. I restarted the MS. The consoles keep working until about the half an hour, the default setting. (I didn’t measure exactly) Can you have another look at this? |
|
@dheeraj12347 once this is merged into 4.20, it will be included in main as well after forward-merge |
Hi @DaanHoogland , I’ve updated the PR to address the consoleproxy.session.timeout behaviour you described: In ConsoleProxy.java I now read consoleproxy.session.timeout from the configuration (milliseconds), validate it, and store the effective value in ConsoleProxy.sessionTimeoutMillis, with a log line on startup showing the effective timeout. In ConsoleProxyGCThread.java I removed the hardcoded idle timeout and changed the GC logic to compute each viewer’s idle time in milliseconds and compare it against ConsoleProxy.sessionTimeoutMillis, logging the idle duration and configured timeout when a session is removed. To verify my changes, I built the console proxy server module with: bash I’m open to any feedback on this approach, and I’m happy to further adjust or iterate based on your results when you re-test with consoleproxy.session.timeout=30000. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: dahn <daan.hoogland@gmail.com>
Co-authored-by: dahn <daan.hoogland@gmail.com>
|
@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. |
|
@nvazquez , can you please review (and maybe test)? |
|
#13858 opened for possible follow-up for non-noVNC consoles. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (3)
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyGCThread.java:98
- Indentation around the connMap key snapshot loop is inconsistent (extra leading spaces on the assignment/brace/for lines), which is likely to violate checkstyle and makes the synchronization scope harder to read.
List<String> keys;
synchronized (connMap) {
keys = new ArrayList<>(connMap.keySet());
}
for (String key : keys) {
ConsoleProxyClient client;
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyGCThread.java:120
- Potential race: this code removes by key even if another thread has replaced the viewer for the same key between the earlier get() and this remove(). Since clientKey can be reused (e.g., per VM tag), this can drop an active session from the map. Remove only if the current map value is still the same client instance you evaluated as idle.
synchronized (connMap) {
connMap.remove(key);
bReportLoad = true;
}
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java:219
- New behavior (parsing and applying consoleproxy.session.timeout) isn’t covered by tests in this module. Adding unit tests for: (1) defaulting on missing/invalid/<=0 values, and (2) using the configured value when valid, would help prevent regressions in future backports.
// New: read consoleproxy.session.timeout (milliseconds)
s = conf != null ? conf.getProperty("consoleproxy.session.timeout") : null;
if (s != null) {
try {
long value = Long.parseLong(s);
if (value <= 0) {
LOGGER.warn("consoleproxy.session.timeout={} is <= 0, using default {} ms",
value, DEFAULT_SESSION_TIMEOUT_MILLIS);
sessionTimeoutMillis = DEFAULT_SESSION_TIMEOUT_MILLIS;
} else {
sessionTimeoutMillis = value;
}
} catch (NumberFormatException e) {
LOGGER.warn("Invalid value for consoleproxy.session.timeout: {}, using default {} ms",
s, DEFAULT_SESSION_TIMEOUT_MILLIS, e);
sessionTimeoutMillis = DEFAULT_SESSION_TIMEOUT_MILLIS;
}
}
LOGGER.info("Effective consoleproxy.session.timeout={} ms", sessionTimeoutMillis);
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18836 |
Description
This PR backports the console proxy/noVNC timeout fix to the 4.20 branch.
It ensures that
consoleproxy.session.timeoutis honoured for noVNC consolesessions, so idle sessions are cleaned up correctly and do not linger
indefinitely.
Key points:
consoleproxy.session.timeoutthrough the console proxy server fornoVNC-based console sessions.
are closed after the configured period.
newer
sessionRequiresNewViewerAPI onConsoleProxyClientParam, onlyremove the references that exist in later branches.
Related work
idle noVNC sessions not respecting
consoleproxy.session.timeout.Testing
Compiled the console proxy server module successfully:
Verified that the code builds cleanly with checkstyle on the 4.20 branch.
Fix Global setting "consoleproxy.session.timeout " is not honoured #12810