You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "nvazquez (via GitHub)" <gi...@apache.org> on 2026/07/24 03:04:41 UTC
[PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
nvazquez opened a new pull request, #13683:
URL: https://github.com/apache/cloudstack/pull/13683
### Description
This PR addresses 2 issues:
- In case of concurrent console proxy requests, 2 different threads could modify the allowedSessions set and cause problems accessing the console sessions (fix to be verified)
- After closing the browser tab for a VM console session, it was observed that the connection remained open on the KVM host's VNC port.
- Before the fix: After opening multiple sessions for the same VM, each new session opens a new socket connection on the KVM host on the VNC port but was not closed after closing the console browser tab.
````
[root@ref-trl-12127-k-Mol9-nicolas-vazquez-kvm2 ~]# ss -tnp | grep 5901
ESTAB 0 55 10.0.33.112:5901 10.0.39.91:43024 users:(("qemu-kvm",pid=77212,fd=38))
ESTAB 0 55 10.0.33.112:5901 10.0.39.91:51796 users:(("qemu-kvm",pid=77212,fd=36))
ESTAB 0 0 10.0.33.112:5901 10.0.39.91:43008 users:(("qemu-kvm",pid=77212,fd=37))
ESTAB 0 0 10.0.33.112:5901 10.0.39.91:60794 users:(("qemu-kvm",pid=77212,fd=35))
````
- After the fix: Each time a console session is acquired, then only one socket connection remains open per VM, and when it is closed then no connections remain open:
````
[root@ref-trl-12127-k-Mol9-nicolas-vazquez-kvm2 ~]# ss -tnp | grep 5901
[root@ref-trl-12127-k-Mol9-nicolas-vazquez-kvm2 ~]# ss -tnp | grep 5901
ESTAB 0 0 10.0.33.112:5901 10.0.39.99:41826 users:(("qemu-kvm",pid=77212,fd=35))
[root@ref-trl-12127-k-Mol9-nicolas-vazquez-kvm2 ~]# ss -tnp | grep 5901
[root@ref-trl-12127-k-Mol9-nicolas-vazquez-kvm2 ~]# ss -tnp | grep 5901
ESTAB 0 0 10.0.33.112:5901 10.0.39.99:36836 users:(("qemu-kvm",pid=77212,fd=35))
````
Fixes: #13422
<!--- ******************************************************************************* -->
<!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!--- ******************************************************************************* -->
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] Build/CI
- [ ] Test (unit or integration test code)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [ ] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
- Replaced the `agent.zip` file on `/usr/share/cloudstack-common/vms/` for each KVM host and recreated the CPVM
- Acquired multiple console sessions and verified the the established using the `ss -tnp` command for VM's VNC ports
#### How did you try to break this feature and the system with this change?
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5086363618
Marked on draft as still working on fixing the issues reported on: https://github.com/apache/cloudstack/issues/13422
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on code in PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#discussion_r3667346479
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java:
##########
@@ -83,12 +82,73 @@ public class ConsoleProxy {
static String encryptorPassword = "Dummy";
static final String[] skipProperties = new String[]{"certificate", "cacertificate", "keystore_password", "privatekey"};
- static Set<String> allowedSessions = new HashSet<>();
+ static Set<String> allowedSessions = ConcurrentHashMap.newKeySet();
+ private static final Object allowedSessionsLock = new Object();
+ private static final Map<String, ReconnectGrant> sessionReconnectGrants = new ConcurrentHashMap<>();
+ private static long sessionReconnectionWindowMs = 0L;
+
+ // Invoked through reflection
public static void addAllowedSession(String sessionUuid) {
allowedSessions.add(sessionUuid);
}
+ /**
+ * Grant the client IP a reconnection window of #{@link #sessionReconnectionWindowMs} ms to the same session UUID in case of a disconnection.
+ * The grant is bound to the client IP that was using the session so it cannot be redeemed by another client.
+ * @param sessionUuid session UUID to grant a reconnect window for
+ * @param clientIp source IP of the client the session was granted to
+ */
+ public static void grantReconnectWindowForSessionAndClientIp(String sessionUuid, String clientIp) {
+ if (sessionReconnectionWindowMs > 0) {
+ ReconnectGrant grant = new ReconnectGrant(System.currentTimeMillis() + sessionReconnectionWindowMs, clientIp);
+ sessionReconnectGrants.put(sessionUuid, grant);
+ }
+ }
+
+ /**
+ * True if the session UUID has been granted reconnection, within the reconnection window #{@link #sessionReconnectionWindowMs}.
+ */
+ private static boolean isSessionReconnectionGrantedForClientIp(String sessionUuid, String clientIp) {
+ ReconnectGrant grant = sessionReconnectGrants.remove(sessionUuid);
+ if (grant == null) {
+ return false;
+ }
+ if (grant.isExpired(System.currentTimeMillis())) {
+ LOGGER.warn("Rejecting reconnection for session {} as the reconnect window: {}ms is already expired",
+ sessionUuid, sessionReconnectionWindowMs);
+ return false;
+ }
+ if (grant.clientIp != null && !grant.clientIp.equals(clientIp)) {
+ LOGGER.warn("Rejecting reconnection for session {} as it was requested from IP {} " +
+ "but the session was granted to IP {}", sessionUuid, clientIp, grant.clientIp);
+ return false;
Review Comment:
Hi @weizhouapache not only client IPs match but also the reconnection attempt is within the reconnection window/timeframe
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5066117797
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18654
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5605848864
<b>[SF] Trillian test result (tid-16934)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 53722 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13683-t16934-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#discussion_r3667169880
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java:
##########
@@ -83,12 +82,73 @@ public class ConsoleProxy {
static String encryptorPassword = "Dummy";
static final String[] skipProperties = new String[]{"certificate", "cacertificate", "keystore_password", "privatekey"};
- static Set<String> allowedSessions = new HashSet<>();
+ static Set<String> allowedSessions = ConcurrentHashMap.newKeySet();
+ private static final Object allowedSessionsLock = new Object();
+ private static final Map<String, ReconnectGrant> sessionReconnectGrants = new ConcurrentHashMap<>();
+ private static long sessionReconnectionWindowMs = 0L;
+
+ // Invoked through reflection
public static void addAllowedSession(String sessionUuid) {
allowedSessions.add(sessionUuid);
}
+ /**
+ * Grant the client IP a reconnection window of #{@link #sessionReconnectionWindowMs} ms to the same session UUID in case of a disconnection.
+ * The grant is bound to the client IP that was using the session so it cannot be redeemed by another client.
+ * @param sessionUuid session UUID to grant a reconnect window for
+ * @param clientIp source IP of the client the session was granted to
+ */
+ public static void grantReconnectWindowForSessionAndClientIp(String sessionUuid, String clientIp) {
+ if (sessionReconnectionWindowMs > 0) {
+ ReconnectGrant grant = new ReconnectGrant(System.currentTimeMillis() + sessionReconnectionWindowMs, clientIp);
+ sessionReconnectGrants.put(sessionUuid, grant);
+ }
+ }
+
+ /**
+ * True if the session UUID has been granted reconnection, within the reconnection window #{@link #sessionReconnectionWindowMs}.
+ */
+ private static boolean isSessionReconnectionGrantedForClientIp(String sessionUuid, String clientIp) {
+ ReconnectGrant grant = sessionReconnectGrants.remove(sessionUuid);
+ if (grant == null) {
+ return false;
+ }
+ if (grant.isExpired(System.currentTimeMillis())) {
+ LOGGER.warn("Rejecting reconnection for session {} as the reconnect window: {}ms is already expired",
+ sessionUuid, sessionReconnectionWindowMs);
+ return false;
+ }
+ if (grant.clientIp != null && !grant.clientIp.equals(clientIp)) {
+ LOGGER.warn("Rejecting reconnection for session {} as it was requested from IP {} " +
+ "but the session was granted to IP {}", sessionUuid, clientIp, grant.clientIp);
+ return false;
Review Comment:
should "return true" only if client IPs match, and "return false" by default ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#discussion_r3658575050
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java:
##########
@@ -83,12 +82,62 @@ public class ConsoleProxy {
static String encryptorPassword = "Dummy";
static final String[] skipProperties = new String[]{"certificate", "cacertificate", "keystore_password", "privatekey"};
- static Set<String> allowedSessions = new HashSet<>();
+ static Set<String> allowedSessions = ConcurrentHashMap.newKeySet();
+ private static final Object allowedSessionsLock = new Object();
+ private static final Map<String, ReconnectGrant> sessionReconnectGrants = new ConcurrentHashMap<>();
+ static int sessionReconnectGraceSeconds = 1;
+
+ // Invoked through reflection
public static void addAllowedSession(String sessionUuid) {
allowedSessions.add(sessionUuid);
}
+ /**
+ * Grant a short, single-use window to reconnect with the same session UUID in case of a disconnection.
+ * The grant is bound to the client IP that was using the session so it cannot be redeemed by another client.
+ * @param sessionUuid session UUID to grant a reconnect window for
+ * @param clientIp source IP of the client the session was granted to
+ */
+ public static void grantReconnectWindow(String sessionUuid, String clientIp) {
+ sessionReconnectGrants.put(sessionUuid, new ReconnectGrant(System.currentTimeMillis() + sessionReconnectGraceSeconds * 1000L, clientIp));
+ }
+
+ private static boolean consumeReconnectGrant(String sessionUuid, String clientIp) {
+ ReconnectGrant grant = sessionReconnectGrants.remove(sessionUuid);
+ if (grant == null || grant.isExpired(System.currentTimeMillis())) {
+ return false;
+ }
+ if (grant.clientIp != null && !grant.clientIp.equals(clientIp)) {
+ LOGGER.warn("Rejecting reconnect for session " + sessionUuid + " as it was requested from IP " +
+ clientIp + " but the reconnect window was granted to IP " + grant.clientIp);
+ return false;
+ }
+ return true;
+ }
Review Comment:
The reconnect grant is removed from `sessionReconnectGrants` before validating the requesting IP. This allows a reconnect window to be consumed/invalidated by any request (e.g., a wrong-IP attempt), effectively preventing the legitimate client from reconnecting within the grace window. Fix by only removing the grant after it is validated (and unexpired), e.g., via `computeIfPresent`, or by doing a get-then-conditional-remove so mismatched-IP attempts do not consume the grant.
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/vnc/NoVncClient.java:
##########
@@ -129,6 +129,28 @@ public void proxyMsgOverWebSocketConnection(ByteBuffer msg) {
}
}
+ public void close() {
+ if (nioSocketConnection != null) {
+ nioSocketConnection.close();
+ }
+ if (webSocketReverseProxy != null) {
+ webSocketReverseProxy.close();
+ }
+ if (socket != null) {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ if (os != null) {
+ os.close();
+ }
+ socket.close();
+ } catch (IOException e) {
+ logger.debug("Error closing socket: " + e.getMessage(), e);
+ }
+ }
+ }
Review Comment:
All stream/socket closes are inside a single `try` block. If `is.close()` throws, `os.close()` and `socket.close()` will be skipped, which can leave resources open and reintroduce the leaked-connection problem this PR is trying to fix. Close each resource in its own try/catch (or use a close-quietly helper) so failures in one close do not prevent the others from running.
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/vnc/network/NioSocketHandler.java:
##########
@@ -41,4 +41,5 @@ public interface NioSocketHandler {
void flushWriteBuffer();
void startTLSConnection(NioSocketSSLEngineManager sslEngineManager);
boolean isTLSConnection();
+ void close();
}
Review Comment:
Since `NioSocketHandler` now defines `close()`, consider extending `AutoCloseable` (or `java.io.Closeable`) to integrate with try-with-resources and align with Java resource-lifecycle conventions. This makes correct cleanup easier to enforce at call sites.
##########
systemvm/agent/conf/consoleproxy.properties:
##########
@@ -22,3 +22,4 @@ consoleproxy.jarDir=./applet/
consoleproxy.viewerLinger=180
consoleproxy.reconnectMaxRetry=5
consoleproxy.defaultBufferSize=65536
+consoleproxy.sessionReconnectGraceSeconds=1
Review Comment:
The new `consoleproxy.sessionReconnectGraceSeconds` property is introduced without any inline comment explaining its purpose (IP-bound reconnect window after disconnect) and expected range/behavior. Add a brief comment in the properties file to make it discoverable for operators and reduce misconfiguration risk.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5106043652
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5106066048
@nvazquez 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5594258744
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5106772089
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18698
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "kiranchavala (via GitHub)" <gi...@apache.org>.
kiranchavala merged PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5592928678
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5593512919
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19156
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5592937729
@nvazquez 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#discussion_r3642688410
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/vnc/NoVncClient.java:
##########
@@ -129,6 +129,28 @@ public void proxyMsgOverWebSocketConnection(ByteBuffer msg) {
}
}
+ public void close() {
+ if (nioSocketConnection != null) {
+ nioSocketConnection.close();
+ }
+ if (webSocketReverseProxy != null) {
+ webSocketReverseProxy.close();
+ }
+ if (socket != null) {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ if (os != null) {
+ os.close();
+ }
+ socket.close();
+ } catch (IOException e) {
+ logger.debug("Error closing socket: " + e.getMessage(), e);
+ }
+ }
+ }
Review Comment:
The socket/stream close logic is wrapped in a single try/catch, so if closing `is` throws an IOException, `os` and `socket` won’t be closed (and the method exits early). For a close path, it’s better to attempt closing each resource independently (best-effort) so one failure doesn’t prevent releasing the rest.
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java:
##########
@@ -209,13 +210,15 @@ public static ConsoleProxyAuthenticationResult authenticateConsoleAccess(Console
}
String sessionUuid = param.getSessionUuid();
- if (allowedSessions.contains(sessionUuid)) {
- LOGGER.debug("Acquiring the session " + sessionUuid + " not available for future use");
- allowedSessions.remove(sessionUuid);
- } else {
- LOGGER.info("Session " + sessionUuid + " has already been used, cannot connect");
- authResult.setSuccess(false);
- return authResult;
+ synchronized (allowedSessionsLock) {
+ if (allowedSessions.contains(sessionUuid)) {
+ LOGGER.debug("Acquiring the session " + sessionUuid + " not available for future use");
+ allowedSessions.remove(sessionUuid);
+ } else {
+ LOGGER.info("Session " + sessionUuid + " has already been used, cannot connect");
+ authResult.setSuccess(false);
+ return authResult;
+ }
}
Review Comment:
Inside the one-time session block, doing `contains()` followed by `remove()` is both slower (two lookups) and easy to get wrong if the synchronization strategy changes later. `Set#remove` already returns whether the UUID was present, so you can do the “check-and-consume” in one operation.
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVncClient.java:
##########
@@ -374,6 +374,9 @@ public void closeClient() {
this.connectionAlive = false;
// Clear buffer reference to allow GC when client disconnects
this.readBuffer = null;
+ if (client != null) {
+ client.close();
+ }
ConsoleProxy.removeViewer(this);
Review Comment:
`closeClient()` now closes the underlying `NoVncClient` (which is the core fix for lingering VNC sockets), but there’s no unit test asserting that the client close is invoked. Given there are existing unit tests in this module, adding a test (e.g., via Mockito injecting a mocked `NoVncClient`) would help prevent regressions where sockets stop being closed again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5065778730
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/13683?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 3.69%. Comparing base ([`0339f31`](https://app.codecov.io/gh/apache/cloudstack/commit/0339f31fb5e94727a32aaeb1fdeb3c333ee5fd83?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`08a76ba`](https://app.codecov.io/gh/apache/cloudstack/commit/08a76bad20dd0e6fa219996dc4832ba341e6320f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
> :exclamation: There is a different number of reports uploaded between BASE (0339f31) and HEAD (08a76ba). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (0339f31) | HEAD (08a76ba) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 4.22 #13683 +/- ##
=============================================
- Coverage 17.69% 3.69% -14.01%
=============================================
Files 5925 449 -5476
Lines 533534 38176 -495358
Branches 65273 7072 -58201
=============================================
- Hits 94421 1409 -93012
+ Misses 428434 36580 -391854
+ Partials 10679 187 -10492
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/13683/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/13683/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `3.69% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/13683/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/cloudstack/pull/13683?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5107081222
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5115472382
<b>[SF] Trillian test result (tid-16643)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 54818 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13683-t16643-kvm-ol8.zip
Smoke tests completed. 148 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
test_01_ssl_offloading_isolated_network | `Failure` | 704.80 | test_ssl_offloading.py
test_02_ssl_offloading_project_vpc | `Failure` | 712.14 | test_ssl_offloading.py
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on code in PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#discussion_r3646658011
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java:
##########
@@ -209,13 +210,15 @@ public static ConsoleProxyAuthenticationResult authenticateConsoleAccess(Console
}
String sessionUuid = param.getSessionUuid();
- if (allowedSessions.contains(sessionUuid)) {
- LOGGER.debug("Acquiring the session " + sessionUuid + " not available for future use");
- allowedSessions.remove(sessionUuid);
- } else {
- LOGGER.info("Session " + sessionUuid + " has already been used, cannot connect");
- authResult.setSuccess(false);
- return authResult;
+ synchronized (allowedSessionsLock) {
+ if (allowedSessions.contains(sessionUuid)) {
+ LOGGER.debug("Acquiring the session " + sessionUuid + " not available for future use");
+ allowedSessions.remove(sessionUuid);
+ } else {
+ LOGGER.info("Session " + sessionUuid + " has already been used, cannot connect");
+ authResult.setSuccess(false);
+ return authResult;
+ }
Review Comment:
👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5065830974
@nvazquez 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5065825224
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5107098132
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on code in PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#discussion_r3669374400
##########
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/vnc/NoVncClient.java:
##########
@@ -129,6 +129,28 @@ public void proxyMsgOverWebSocketConnection(ByteBuffer msg) {
}
}
+ public void close() {
+ if (nioSocketConnection != null) {
+ nioSocketConnection.close();
+ }
+ if (webSocketReverseProxy != null) {
+ webSocketReverseProxy.close();
+ }
+ if (socket != null) {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ if (os != null) {
+ os.close();
+ }
+ socket.close();
+ } catch (IOException e) {
+ logger.debug("Error closing socket: " + e.getMessage(), e);
+ }
+ }
+ }
Review Comment:
Not relevant as `is` and `os` are only used along with `socket`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ConsoleProxy] Performance fixes on concurrency and closing console sessions sockets and introduce reconnection window for console sessions [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #13683:
URL: https://github.com/apache/cloudstack/pull/13683#issuecomment-5594268225
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org