Skip to content

Conversation

@ono-max
Copy link
Contributor

@ono-max ono-max commented May 30, 2025

Background

Ruby team reported that Launchable CLI sometimes took so long time as follows:

One of the potential causes is that the timeout is not configured in our HTTP client. According to the following documentation, the system default will be used if no timeout is configured. I'm not sure what that default behavior actually means, but when I tested it in my local environment, it waited indefinitely for a response. So, I introduced the environment variable 'LAUNCHABLE_COMMIT_TIMEOUT', which sets a timeout for the commit collection process. We might modify the API later, such as by adding a CLI option. But for now, this environment variable should be sufficient for the Ruby team.

Screenshot 2025-05-30 at 16 19 12

https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/client/config/RequestConfig.html

Example

$ LAUNCHABLE_COMMIT_TIMEOUT=1 launchable record build --name 105   
Exception in thread "main" java.net.SocketTimeoutException: Read timed out
        at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:278)
        at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:304)
        at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:346)
        at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:796)
        at java.base/java.net.Socket$SocketInputStream.implRead(Socket.java:1116)
        at java.base/java.net.Socket$SocketInputStream.read(Socket.java:1103)
        at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
        at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
        at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
        at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
        at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
        at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
        at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
        at com.launchableinc.ingest.commits.CommitGraphCollector.transfer(CommitGraphCollector.java:136)
        at com.launchableinc.ingest.commits.CommitIngester.run(CommitIngester.java:148)
        at com.launchableinc.ingest.commits.CommitIngester.main(CommitIngester.java:75)
Couldn't get commit history from `/Users/ono-max/src/github.com/launchableinc/cli`. Do you run command root of git-controlled directory? If not, please set a directory use by --source option.
Command '['java', '-jar', '/Users/ono-max/.local/share/virtualenvs/cli-tPknK2Me/lib/python3.12/site-packages/launchable/jar/exe_deploy.jar', 'ingest:commit', '-endpoint', 'http://localhost:8080/intake/', '-max-days', '30', '-scrub-pii', '-enable-timeout', '/Users/ono-max/src/github.com/launchableinc/cli']' returned non-zero exit status 1.
Launchable recorded build 105 to workspace launchableinc/mothership with commits from 1 repository:

| Name   | Path   | HEAD Commit                              |
|--------|--------|------------------------------------------|
| .      | .      | 717ebeca10d565d9beca9c95ca971ee8e7b65b8b |

Visit https://app.launchableinc.com/organizations/launchableinc/workspaces/mothership/data/builds/157 to view this build and its test sessions

@ono-max ono-max changed the title Add request configuration with socket timeout to CommitGraphCollector [AIENG-73] Fix Ruby timeout issue by setting HTTP timeouts May 30, 2025
@ono-max ono-max force-pushed the AIENG-73-3 branch 2 times, most recently from 1857f5a to 6a70455 Compare May 30, 2025 07:01
@ono-max ono-max requested a review from kohsuke May 30, 2025 07:24
@ono-max
Copy link
Contributor Author

ono-max commented May 30, 2025

@kohsuke

Can you review Java code? I'm not familiar with the collection logic, so I'd like to make sure that it's okay.

@ono-max ono-max marked this pull request as ready for review May 30, 2025 07:43
Copy link
Contributor

@kohsuke kohsuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can ship this as-is, if you want to, but the following changes would make this even better:

I don't see the need for a switch to change timeout. Especially if it's only affecting commit collection, but not build/test recording, etc. Python code already uses (5,60) and (5,15) timeout combo depending on the HTTP method (see http_client.py), and there's no way to control this. So more natural, consistent thing to do is to use the same values.

(Speaking of http_client.py, the way it's dealing with the default value is just a mess.)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 2, 2025

@ono-max ono-max merged commit a383a12 into main Jun 4, 2025
16 checks passed
@ono-max ono-max deleted the AIENG-73-3 branch June 4, 2025 07:32
@github-actions github-actions bot mentioned this pull request Jun 4, 2025
ono-max added a commit to ruby/ruby that referenced this pull request Jun 4, 2025
When Launchable in unstable, the round trip time takes a long time, which slows down CI execution. In this PR I configured the environment variable `LAUNCHABLE_COMMIT_TIMEOUT` to configure the timeout.

cloudbees-oss/smart-tests-cli#1015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants