RFR: 7903730: Enhance the agentvm to be tolerant to unexpected connection on the port the Agent listens on for handshake with the AgentServer [v4]

Jaikiran Pai jpai at openjdk.org
Fri Jun 7 11:36:46 UTC 2024


> Can I please get a review of this change which proposes to implement the enhancement noted in https://bugs.openjdk.org/browse/CODETOOLS-7903730?
> 
> As noted in that enhancement request, in the agentvm mode, we establish a socket connection between the `Agent` and the `AgentServer`. In its current form, it can so happen that the `Agent` may end up expecting a connection from some unexpected process. That then leads to the agent vm launch failing and the test too failing.
> 
> The proposed change introduces a handshake where the `AgentServer` sends the `jtreg` "magic" bytes immediately after it connects to the `Agent`. The `Agent` verifies these bytes on the accepted connection and if it either doesn't receive these bytes (for the specified read timeout) or if it receives some other data than these handshake bytes, then it closes this accepted connection and then goes on to accept another connection and repeats the handshake verification. In the current proposed change, it reattempts only 2 times and I haven't seen a need to either configure this value or have a higher value for this. i.e. if we can't establish a connection and verify that the connection initiator is the `AgentServer` even after three attempts, then I think it's OK to fail the agent launch process.
> 
> tier1 through tier8 tests have been run with this change (a couple of times) over the past couple of months and I haven't noticed any regression, nor have I noticed the agentvm launch process to be failing due to unexpected connection initiator.

Jaikiran Pai has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:

 - Ludvig and Jon's suggestion - log the IOException failure
 - Daniel's suggestion - move assert after != check
 - Mark's suggestion - make static final MAX_ACCEPT_ATTEMPTS
 - merge latest from master branch
 - reduce the scope of the try/catch and fix potential short read() issue
 - fix comments
 - milliseconds instead of milli seconds
 - 7903730: Enhance the agentvm to be tolerant to unexpected connection on the port the Agent listens on for handshake with the AgentServer

-------------

Changes:
  - all: https://git.openjdk.org/jtreg/pull/195/files
  - new: https://git.openjdk.org/jtreg/pull/195/files/d2936d01..dd3406a1

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jtreg&pr=195&range=03
 - incr: https://webrevs.openjdk.org/?repo=jtreg&pr=195&range=02-03

  Stats: 768 lines in 50 files changed: 213 ins; 502 del; 53 mod
  Patch: https://git.openjdk.org/jtreg/pull/195.diff
  Fetch: git fetch https://git.openjdk.org/jtreg.git pull/195/head:pull/195

PR: https://git.openjdk.org/jtreg/pull/195


More information about the jtreg-dev mailing list