Skip to content

Commit

Permalink
#65 Debug /opt/kafka/config/ not writable
Browse files Browse the repository at this point in the history
  • Loading branch information
cer committed Aug 20, 2024
1 parent 89bc149 commit e0fbe50
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,28 @@ public void registerProperties(BiConsumer<String, Supplier<Object>> registry) {

@Override
protected void containerIsStarting(InspectContainerResponse containerInfo) {
execInContainerAndPrint("ls", "-ltd", "/opt/kafka/config/");
execInContainerAndPrint("id");
execInContainerAndPrint("touch", "/opt/kafka/config/foo");

String writeableTest = "[[ -w /opt/kafka/config/ ]] && echo yes";
execInContainerAndPrint("sh", "-c", writeableTest);
execInContainerAndPrint("bash", "-c", writeableTest);

super.containerIsStarting(containerInfo);
}

private void execInContainerAndPrint(String... args) {
try {
ExecResult result = execInContainer("ls", "-ltd", "/opt/kafka/config/");
printExecResult(result, "ls -ltd /opt/kafka/config/: ");
result = execInContainer("id");
printExecResult(result, "id");
result = execInContainer("touch", "/opt/kafka/config/foo");
printExecResult(result, "touch /opt/kafka/config/foo");
result = execInContainer("sh", "-c", "[[ -w /opt/kafka/config/ ]] && echo yes");
printExecResult(result, "sh -c '[[ -w /opt/kafka/config/ ]] && echo yes'");
} catch (IOException | InterruptedException e) {
ExecResult result = execInContainer(args);
String command = String.join(" ", args) + " : ";
System.out.println("======== Command " + command + " -> ");
System.out.println("ExitCode=" + result.getExitCode());
System.out.println("Stdout=" + result.getStdout());
System.out.println("Stderr=" + result.getStderr());
} catch (UnsupportedOperationException | InterruptedException | IOException e) {
throw new RuntimeException(e);
}
super.containerIsStarting(containerInfo);
}

private static void printExecResult(ExecResult result, String command) {
System.out.println(command + result.getExitCode());
System.out.println(command + result.getStdout());
System.out.println(command + result.getStderr());
}
}

0 comments on commit e0fbe50

Please sign in to comment.