Commit f3dd528
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 d9f5a3b commit f3dd528
1 file changed
Lines changed: 13 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| 85 | + | |
| 86 | + | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
| |||
0 commit comments