File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -79,11 +79,28 @@ func parseCmdLine(cmdLines []string) (cfg tinkConfig) {
7979// downloadFile will download a url to a local file. It's efficient because it will
8080// write as it downloads and not load the whole file into memory.
8181func downloadFile (filepath string , url string ) error {
82+ // As all functions in the LinuxKit services run in parallel, ensure that we can fail
83+ // successfully until we accept that networking is actually broken
84+
85+ var maxRetryCount int
86+ var timeOut time.Duration
87+ maxRetryCount = 10
88+ timeOut = time .Millisecond * 500 // 0.5 seconds
89+ var resp * http.Response
90+ var err error
91+
92+ // Retry this task
93+ for retries := 0 ; retries < maxRetryCount ; retries ++ {
8294 // Get the data
83- resp , err := http .Get (url )
84- if err != nil {
95+ resp , err = http .Get (url )
96+ if err == nil {
97+ break
98+ }
99+ if retries == maxRetryCount - 1 {
85100 return err
86101 }
102+ time .Sleep (timeOut )
103+ }
87104 defer resp .Body .Close ()
88105
89106 // Create the file
You can’t perform that action at this time.
0 commit comments