Skip to content

fix(k8s): copy volume move data pod to pod, not via API server #7408

Done

Description

@dan-petty

Problem

devops k8s volume move copies the data through two kubectl exec streams that a named pipe joins (copy_argv, src/devops_cli/k8s/volume_move.py). The data goes from the source node through the API server to the machine of the operator, and back through the API server to the target node. On the homelab, this copy stops for a volume of about 600 MiB.

Evidence of 2026-11-27, kubectl v1.37.3, from the devcontainer:

  • A move of a test claim (633,144,478 bytes: one random file of 600 MiB and 2000 small files) from a node without Longhorn to a Longhorn volume on another node. The copy stopped two times, each time about 61 s after its start, with "Copying stdout failed" err="read message: read tcp <client>-><api-server>:6443: i/o timeout". The move then undid every step, as it must.
  • A copy by hand of 532 MiB through kubectl exec ... | kubectl exec -i ... stopped in the same way after about 1 minute (dan-petty/homelab#461).
  • The same copy command with KUBECTL_REMOTE_COMMAND_WEBSOCKETS=false (SPDY): all 633,144,478 bytes arrived in /dst, but the pipe did not end within 600 s.
  • A copy from pod to pod inside the cluster moved 532 MiB in 7 s: the source pod served tar -c on a TCP port with Perl IO::Socket::INET, and the destination pod read it with bash /dev/tcp. Both tools are in the copy image debian:trixie-slim (dan-petty/homelab#461).

The 61 s are probably the read deadline of the heartbeat of the WebSocket exec client; a stream that gets no message in that time fails.

Impact

The homelab moves 16 claims to the class longhorn with this command (dan-petty/homelab#399, #7382). Each claim of more than about 1 minute of copy fails, after the workload stopped for that time. The failure is safe (the move undoes its steps), but the moves cannot finish.

Change

Copy from pod to pod inside the cluster, not through the API server. For example: the destination copy pod listens on a TCP port and extracts, and the source copy pod sends tar -c to the IP address of the destination pod. The exec streams then carry only the start and the result. The plan must make sure that the source pod can reach the destination pod (a NetworkPolicy can block it), or the move must refuse.

Acceptance criteria

  • A failing test first: the copy step sends no data through kubectl exec stdin or stdout.
  • A live move of a claim of at least 600 MiB ends with equal digests on the two sides.
  • devops ci checks pass.

Related: #7382, #3953, dan-petty/homelab#399.

Activity

  1. added
    type/bug
    scope/k8s
    source/agent
    status/new
    on Nov 27, 2026
  2. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor
    • Priority: Every move over ~600 MiB fails, blocking the 16-claim migration in #7382.
    • Related: fix(k8s): volume move loses the end of its copy #3695, which asks for a different change. Both change the copy step in devops k8s volume move; #3695 fixed a lost tail in the same pipe, the candidate replaces the pipe with pod-to-pod TCP.
  3. added
    effort/medium
    value/high
    priority/p1-high
    on Nov 27, 2026
  4. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor

    One more data point, 2026-11-27 13:35Z: a move of a test claim of 45,941,910 bytes (44 MiB, 2002 files) also lost its first copy with "Copying stderr failed" err="next reader: read tcp <client>-><api-server>:6443: i/o timeout". The retry passed, and the two sides were equal. So a small claim can fail too, not only a claim that needs more than 61 s.

  5. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor

    Which direction fails. Tests of 2026-11-27 13:40Z to 13:47Z, kubectl v1.37.3 from the devcontainer, one temporary pod on a worker node:

    Exec stream Result
    Idle, 150 s (sleep 150; echo idle-ok) Passed, 150 s
    One line each second, 150 s Passed, 151 s
    700 MiB down (pod stdout to kubectl: head -c 734003200 /dev/urandom) Failed after 13 s: 730,017,787 of 734,003,200 bytes arrived, then websocket: close 1006 (abnormal closure): unexpected EOF, exit 1
    700 MiB up (kubectl stdin to pod: ... | kubectl exec -i ... wc -c) Passed, 52 s, 734,003,200 bytes

    So a long exec stream lives, and stdin carries much data. The stdout of a pod at full speed fails, and that is the source side of the copy. A fix that sends the data from pod to pod, and keeps only an idle exec stream open for the result, avoids the failing direction.

  6. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 27, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 27, 2026
  8. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-27 18:39 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/k8ssource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions