[Bug]:

Đang mở
#10,713 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

  • #10787 của @JohnWill14 — đã đóng, không merge

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
docker, java
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu trong RyukResourceReaper.maybeStart tại log lỗi kết nối được hiển thị trong issue. Xem xét hành vi retry xung quanh và các test Core liên quan, sau đó xác minh rằng các retry kết nối được mong đợi không còn tạo ra stack trace ở mức warning, trong khi Ryuk vẫn khởi động và đăng ký tài nguyên bình thường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

type/bug
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

Ngôn ngữ chính
Java
Star
8.8k
Fork
2k
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của testcontainers/testcontainers-java

Tất cả issue của testcontainers/testcontainers-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.