Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ protected void containerIsStarting(InspectContainerResponse containerInfo) {

command += "/etc/kafka/docker/run \n";
copyFileToContainer(Transferable.of(command, 0777), STARTER_SCRIPT);
// Marker file: created after the starter script copy has fully released its
// writer, so the wait loop in KafkaHelper.COMMAND only proceeds when the
// script is safe to execve. Without this, on busy hosts the loop can see the
// starter script entry before docker-cp has closed it and fail with
// "Text file busy" (exit 126).
copyFileToContainer(Transferable.of(""), KafkaHelper.STARTER_SCRIPT_READY_FLAG);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class KafkaHelper {

static final String STARTER_SCRIPT = "/tmp/testcontainers_start.sh";

static final String STARTER_SCRIPT_READY_FLAG = "/tmp/testcontainers_start.ready";

static final String[] COMMAND = {
"sh",
"-c",
"while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; " + STARTER_SCRIPT,
"while [ ! -f " + STARTER_SCRIPT_READY_FLAG + " ]; do sleep 0.1; done; " + STARTER_SCRIPT,
};

static final WaitStrategy WAIT_STRATEGY = Wait.forLogMessage(".*Transitioning from RECOVERY to RUNNING.*", 1);
Expand Down