Commit 1bf7214
Add --request-timeout flag with TCP dial support for all commands
This commit adds a --request-timeout flag (following kubectl conventions)
to all OADP CLI commands, with full support for cluster unreachability:
- Add --request-timeout flag to nonadmin backup logs and describe commands
(takes precedence over OADP_CLI_REQUEST_TIMEOUT env var)
- Add timeoutFactory wrapper that applies dial timeout to all Velero
commands by overriding all client-creating methods (KubeClient,
DynamicClient, DiscoveryClient, KubebuilderClient, KubebuilderWatchClient)
- Add renameTimeoutFlag to rename Velero's --timeout to --request-timeout
for consistent kubectl-style CLI experience
- Set custom net.Dialer with timeout to handle TCP dial timeouts
- Add context-based timeout handling with proper cancellation detection
- Add FormatDownloadRequestTimeoutError for helpful timeout diagnostics
- Add tests for timeout functionality (global timeout, config application,
dialer timeout behavior)
The timeout now applies to both HTTP requests and TCP connection
attempts across all commands, ensuring the CLI times out quickly when
the cluster is unreachable instead of waiting for the default ~30s TCP
timeout.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: Michal Pryc <[email protected]>1 parent 2dc20a5 commit 1bf7214
File tree
7 files changed
+684
-59
lines changed- cmd
- non-admin/backup
7 files changed
+684
-59
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
33 | 42 | | |
34 | | - | |
| 43 | + | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
| 48 | + | |
39 | 49 | | |
40 | 50 | | |
41 | 51 | | |
42 | 52 | | |
43 | 53 | | |
44 | 54 | | |
45 | 55 | | |
46 | | - | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
50 | 67 | | |
51 | 68 | | |
52 | 69 | | |
| |||
55 | 72 | | |
56 | 73 | | |
57 | 74 | | |
58 | | - | |
| 75 | + | |
| 76 | + | |
59 | 77 | | |
60 | 78 | | |
| 79 | + | |
| 80 | + | |
61 | 81 | | |
62 | 82 | | |
63 | 83 | | |
| |||
349 | 369 | | |
350 | 370 | | |
351 | 371 | | |
352 | | - | |
353 | | - | |
354 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
355 | 382 | | |
356 | 383 | | |
357 | 384 | | |
| |||
401 | 428 | | |
402 | 429 | | |
403 | 430 | | |
404 | | - | |
405 | | - | |
406 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
407 | 435 | | |
408 | 436 | | |
409 | 437 | | |
410 | 438 | | |
411 | 439 | | |
412 | 440 | | |
413 | 441 | | |
414 | | - | |
415 | | - | |
416 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
417 | 446 | | |
418 | 447 | | |
419 | 448 | | |
420 | 449 | | |
421 | 450 | | |
422 | 451 | | |
423 | 452 | | |
424 | | - | |
425 | | - | |
426 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
427 | 457 | | |
428 | 458 | | |
429 | 459 | | |
430 | 460 | | |
431 | 461 | | |
432 | 462 | | |
433 | 463 | | |
434 | | - | |
435 | | - | |
436 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
437 | 468 | | |
438 | 469 | | |
439 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
| |||
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
62 | 81 | | |
63 | 82 | | |
64 | 83 | | |
| |||
97 | 116 | | |
98 | 117 | | |
99 | 118 | | |
100 | | - | |
| 119 | + | |
101 | 120 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
106 | 124 | | |
107 | 125 | | |
108 | 126 | | |
109 | 127 | | |
110 | 128 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
114 | 137 | | |
115 | 138 | | |
116 | 139 | | |
117 | 140 | | |
118 | 141 | | |
119 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
120 | 147 | | |
121 | 148 | | |
122 | 149 | | |
| |||
141 | 168 | | |
142 | 169 | | |
143 | 170 | | |
144 | | - | |
| 171 | + | |
| 172 | + | |
145 | 173 | | |
146 | 174 | | |
147 | 175 | | |
148 | 176 | | |
149 | 177 | | |
150 | | - | |
| 178 | + | |
| 179 | + | |
151 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
152 | 185 | | |
0 commit comments