File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
staging/src/k8s.io/kubectl/pkg/cmd/cp Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,13 @@ package cp
19
19
import (
20
20
"archive/tar"
21
21
"bytes"
22
+ "context"
22
23
"errors"
23
24
"fmt"
24
25
"io"
25
26
"os"
26
27
"strings"
28
+ "time"
27
29
28
30
"github.com/spf13/cobra"
29
31
@@ -279,7 +281,21 @@ func (o *CopyOptions) checkDestinationIsDir(dest fileSpec) error {
279
281
Executor : & exec.DefaultRemoteExecutor {},
280
282
}
281
283
282
- return o .execute (options )
284
+ ctx , cancel := context .WithTimeout (context .Background (), 3 * time .Second )
285
+ defer cancel ()
286
+
287
+ done := make (chan error )
288
+
289
+ go func () {
290
+ done <- o .execute (options )
291
+ }()
292
+
293
+ select {
294
+ case <- ctx .Done ():
295
+ return fmt .Errorf ("timeout exceeded while checking the destination" )
296
+ case err := <- done :
297
+ return err
298
+ }
283
299
}
284
300
285
301
func (o * CopyOptions ) copyToPod (src , dest fileSpec , options * exec.ExecOptions ) error {
You can’t perform that action at this time.
0 commit comments