File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,27 @@ 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- // Get the data
83- resp , err := http .Get (url )
84- if err != nil {
85- return err
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 ++ {
94+ // Get the data
95+ resp , err = http .Get (url )
96+ if err == nil {
97+ break
98+ }
99+ if retries == maxRetryCount - 1 {
100+ return err
101+ }
102+ time .Sleep (timeOut )
86103 }
87104 defer resp .Body .Close ()
88105
You can’t perform that action at this time.
0 commit comments