[Bug]:
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #10787 来自 @JohnWill14 —— 已关闭,未合并
评估
调研方向
从 Issue 中显示的连接失败日志开始,在 RyukResourceReaper.maybeStart 处进行检查。查看周围的重试行为和相关的 Core 测试,然后验证预期的连接重试不再产生 warning 级别的堆栈跟踪,同时 Ryuk 仍能正常启动并注册资源。
由索引模型根据 Issue 内容生成。
描述
Module
Core
Testcontainers version
1.21.0
Using the latest Testcontainers version?
Yes
Host OS
Windows 11 + WSL2(Ubuntu)
Host Arch
X86
Docker version
Client: Docker Engine - Community
Version: 28.1.1
API version: 1.49
Go version: go1.23.8
Git commit: 4eba377
Built: Fri Apr 18 09:52:14 2025
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 28.1.1
API version: 1.49 (minimum version 1.24)
Go version: go1.23.8
Git commit: 01f442b
Built: Fri Apr 18 09:52:14 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.27
GitCommit: 05044ec0a9a75232cad458027ca83437aae3f4da
runc:
Version: 1.2.5
GitCommit: v1.2.5-0-g59923ef
docker-init:
Version: 0.19.0
GitCommit: de40ad0
What happened?
This code in RyukResourceReaper :
@SneakyThrows(InterruptedException.class)
private synchronized void maybeStart() {
...
...
Thread kiraThread = new Thread(
DockerClientFactory.TESTCONTAINERS_THREAD_GROUP,
() -> {
while (true) {
RYUK_ACK_RATE_LIMITER.doWhenReady(() -> {
int index = 0;
// not set the read timeout, as Ryuk would not send anything unless a new filter is submitted, meaning that we would get a timeout exception pretty quick
try (Socket clientSocket = new Socket()) {
clientSocket.connect(new InetSocketAddress(host, ryukPort), 5 * 1000);
ResourceReaper.FilterRegistry registry = new ResourceReaper.FilterRegistry(
clientSocket.getInputStream(),
clientSocket.getOutputStream()
);
synchronized (ResourceReaper.DEATH_NOTE) {
while (true) {
if (ResourceReaper.DEATH_NOTE.size() <= index) {
try {
ResourceReaper.DEATH_NOTE.wait(1_000);
continue;
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
List<Map.Entry<String, String>> filters = ResourceReaper.DEATH_NOTE.get(index);
boolean isAcknowledged = registry.register(filters);
if (isAcknowledged) {
log.debug("Received 'ACK' from Ryuk");
ryukScheduledLatch.countDown();
index++;
} else {
log.debug("Didn't receive 'ACK' from Ryuk. Will retry to send filters.");
}
}
}
} catch (IOException e) {
log.warn("Can not connect to Ryuk at {}:{}", host, ryukPort, e);
}
});
}
},
"testcontainers-ryuk"
);
The problem is the line:
/log.warn("Can not connect to Ryuk at {}:{}", host, ryukPort, e);
Why?
It shouldn't be a warning since it is expected that this can happen. The situation fixes itself after 4-500 msecs (on my host).
IMO, warnings are for unexpected events or for things that requires the user's attention. This is logged with stack trace and all .. but it is really not something the user should be concerned with.
I suggest the following instead
/log.info("Attempt failed: Cannot connect to Ryuk at {}:{}. Will retry", host, ryukPort);
.. or something.
Relevant log output
13:35:24.175 [main] INFO tc.testcontainers/ryuk:0.11.0 -- Container testcontainers/ryuk:0.11.0 started in PT0.4782861S
13:35:24.179 [testcontainers-ryuk] WARN org.testcontainers.utility.RyukResourceReaper -- Can not connect to Ryuk at localhost:32790
java.net.ConnectException: Connection refused: getsockopt
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:628)
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:533)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:282)
at java.base/java.net.Socket.connect(Socket.java:665)
at org.testcontainers.utility.RyukResourceReaper.lambda$maybeStart$0(RyukResourceReaper.java:92)
at org.rnorth.ducttape.ratelimits.RateLimiter.doWhenReady(RateLimiter.java:27)
at org.testcontainers.utility.RyukResourceReaper.lambda$maybeStart$1(RyukResourceReaper.java:88)
at java.base/java.lang.Thread.run(Thread.java:1447)
13:35:24.432 [testcontainers-ryuk] WARN org.testcontainers.utility.RyukResourceReaper -- Can not connect to Ryuk at localhost:32790
java.net.ConnectException: Connection refused: getsockopt
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:628)
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:533)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:282)
at java.base/java.net.Socket.connect(Socket.java:665)
at org.testcontainers.utility.RyukResourceReaper.lambda$maybeStart$0(RyukResourceReaper.java:92)
at org.rnorth.ducttape.ratelimits.RateLimiter.doWhenReady(RateLimiter.java:27)
at org.testcontainers.utility.RyukResourceReaper.lambda$maybeStart$1(RyukResourceReaper.java:88)
at java.base/java.lang.Thread.run(Thread.java:1447)
13:35:24.688 [main] INFO org.testcontainers.utility.RyukResourceReaper -- Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
13:
Additional Information
No response
- 主要语言
- Java
- 星标
- 8.8k
- 派生
- 2k
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 11
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testcontainers/testcontainers-java 的其他 Issue
-
[Bug]: WaitStrategyTarget Handles Multiple Ports Differently to Documentation可能已有人在做 @suvvvv 于 2 天前认领。 未关闭type/bug
难度 2/5 1-3 小时 新手友好度 68/100
testcontainers/testcontainers-java#12196 ·
维护者通常 1 天内回复
-
[Bug]: DockerImageName treats uppercase registry names as repository paths可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
testcontainers/testcontainers-java#12186 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: withStartupTimeout() changes the startup timeout of all containers that use the default wait strategy可能已有人在做 @aymenjamaaoui 于 18 天前认领。 未关闭type/bug
难度 2/5 1-3 小时 新手友好度 64/100
testcontainers/testcontainers-java#12171 · 1 条评论 ·
维护者通常 1 天内回复
-
[Enhancement]: Document why singleton containers are required under Spring's test context caching可能已有人在做 @zakaullah075 于 111 天前认领。 未关闭type/enhancement
难度 1/5 1 小时以内 新手友好度 85/100
testcontainers/testcontainers-java#11967 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under Linux可能已有人在做 @kdelay 于 132 天前认领。 未关闭type/bug
难度 2/5 1-3 小时 新手友好度 78/100
testcontainers/testcontainers-java#11941 ·
维护者通常 1 天内回复
查看 testcontainers/testcontainers-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 88/100
erkamyaman/rust-anything#1381 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
java-native-access/jna#1757 ·