Commit 53a5d14
Fix truncated stdin backups by closing pipe before signaling done
Application-aware backups (stdin backups from pod exec) were being
truncated because the pipe writer was closed after signaling done
to the backup trigger. This created a race condition:
1. StreamWithContext finishes writing data to the pipe
2. done <- true signals the backup trigger to call cmd.Wait()
3. defer stdoutWriter.Close() hasn't executed yet
4. restic finishes before all data flows through the pipe
Fix: close the pipe writer before signaling done, ensuring restic's
stdin receives all data and EOF before the backup command exits.
Also improved error handling: use CloseWithError on stream failure
instead of os.Exit(1), propagating the error through the pipe to
the reader.
Fixes #1109
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Aarno Aukia <aarno.aukia@vshn.ch>1 parent 2a90b53 commit 53a5d14
1 file changed
Lines changed: 14 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | | - | |
| 64 | + | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
80 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| |||
0 commit comments