Skip to content

Copy.copyFileToPod() breaks on WebSocket #2309

@imilos

Description

@imilos

Describe the bug
A trivial example of copying a file larger than ~17MB to a pod using Copy.copyFileToPod breaks with:

Exception in thread "main" java.io.IOException: WebSocket has closed.
	at io.kubernetes.client.util.WebSocketStreamHandler$WebSocketOutputStream.write(WebSocketStreamHandler.java:270)
	at org.apache.commons.codec.binary.BaseNCodecOutputStream.flush(BaseNCodecOutputStream.java:124)
	at org.apache.commons.codec.binary.BaseNCodecOutputStream.write(BaseNCodecOutputStream.java:177)
	at org.apache.commons.compress.utils.CountingOutputStream.write(CountingOutputStream.java:48)
	at org.apache.commons.compress.utils.FixedLengthBlockOutputStream$BufferAtATimeOutputChannel.write(FixedLengthBlockOutputStream.java:244)
	at org.apache.commons.compress.utils.FixedLengthBlockOutputStream.writeBlock(FixedLengthBlockOutputStream.java:92)
	at org.apache.commons.compress.utils.FixedLengthBlockOutputStream.maybeFlush(FixedLengthBlockOutputStream.java:86)
	at org.apache.commons.compress.utils.FixedLengthBlockOutputStream.write(FixedLengthBlockOutputStream.java:122)
	at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.write(TarArchiveOutputStream.java:454)
	at io.kubernetes.client.util.Streams.copy(Streams.java:28)
	at io.kubernetes.client.Copy.copyFileToPodAsync(Copy.java:374)
	at io.kubernetes.client.Copy.copyFileToPod(Copy.java:350)
	at rs.kg.ac.k8sclient.K8sclient.main(K8sclient.java:35)
	Suppressed: java.io.IOException: This archive contains unclosed entries.
		at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.finish(TarArchiveOutputStream.java:289)
		at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.close(TarArchiveOutputStream.java:307)
		at io.kubernetes.client.Copy.copyFileToPodAsync(Copy.java:378)
		... 2 more

The code is trivial:

...
    public static void main(String[] args)
            throws IOException, ApiException, InterruptedException, CopyNotSupportedException {
        String podName = "oip-robotics-blackfox-5c4f57dc87-k29wk";
        String namespace = "default";
        ApiClient client = Config.defaultClient();
        Configuration.setDefaultApiClient(client);
        Copy copy = new Copy();
        copy.copyFileToPod(namespace, podName, null, Paths.get("Inputs-Djerdap-500k/300kscenarija.csv"), Paths.get("/tmp/300kscenarija.csv"));
        System.out.println("Done!");
}

Even with small files it hangs waiting for the process to complete as reported in #1822 .

Client Version
15.0.1

Kubernetes Version
1.22.9

Java Version
Java 8

Server (please complete the following information):

  • OS: CentOS 7.8 Linux
  • Environment MicroK8s cluster of 7 physical nodes

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions