Skip to content

Commit

Permalink
fix(socat): handle ipv6 and ipv4 communication from socat to process …
Browse files Browse the repository at this point in the history
…runner

When trying to use Airbyte in an IPV6 enabled kubernetes cluster the socat process fails
with E TCP: wrong number of parameters (9 instead of 2).
This PR fixes that using the TCP6:[IP]:port syntax when identifying an IPV6 address for
the original process runner host.
  • Loading branch information
ogirardot committed Jun 13, 2024
1 parent fab6227 commit 77e001d
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ProcessHandle.Info;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.file.Path;
Expand Down Expand Up @@ -531,10 +534,17 @@ public KubePodProcess(final String processRunnerHost,
.withSecurityContext(containerSecurityContext())
.build();

String socatProcessRunnerAddress = "";
InetAddress inetAddress = InetAddress.getByName(processRunnerHost);
if (inetAddress instanceof Inet4Address) {
socatProcessRunnerAddress = String.format("TCP:%s:%s", processRunnerHost, stdoutLocalPort);
} else if (inetAddress instanceof Inet6Address) {
socatProcessRunnerAddress = String.format("TCP6:[%s]:%s", processRunnerHost, stdoutLocalPort);
}
final Container relayStdout = new ContainerBuilder()
.withName("relay-stdout")
.withImage(socatImage)
.withCommand("sh", "-c", String.format("cat %s | socat -d -d -t 60 - TCP:%s:%s", STDOUT_PIPE_FILE, processRunnerHost, stdoutLocalPort))
.withCommand("sh", "-c", String.format("cat %s | socat -d -d -t 60 - %s", STDOUT_PIPE_FILE, socatProcessRunnerAddress))
.withVolumeMounts(pipeVolumeMount, terminationVolumeMount)
.withResources(getResourceRequirementsBuilder(podResourceRequirements.stdOut()).build())
.withImagePullPolicy(sidecarImagePullPolicy)
Expand All @@ -544,7 +554,7 @@ public KubePodProcess(final String processRunnerHost,
final Container relayStderr = new ContainerBuilder()
.withName("relay-stderr")
.withImage(socatImage)
.withCommand("sh", "-c", String.format("cat %s | socat -d -d -t 60 - TCP:%s:%s", STDERR_PIPE_FILE, processRunnerHost, stderrLocalPort))
.withCommand("sh", "-c", String.format("cat %s | socat -d -d -t 60 - %s", STDERR_PIPE_FILE, socatProcessRunnerAddress))
.withVolumeMounts(pipeVolumeMount, terminationVolumeMount)
.withResources(getResourceRequirementsBuilder(podResourceRequirements.stdErr()).build())
.withImagePullPolicy(sidecarImagePullPolicy)
Expand Down

0 comments on commit 77e001d

Please sign in to comment.