Skip to content

Commit 012b1ff

Browse files
authored
Continue using last successfully fetched config file if failed to refresh (#15)
1 parent 520b7bf commit 012b1ff

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

config/config.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,6 @@ func FetchRemoteList(
320320
}
321321
err := refreshRemoteList(gl, remotes, maxNumSrcTCPPorts, minBatchInterval, HTTPResponseHeaderTimeout,
322322
orchestratorRESTConf, kill, logger)
323-
// Do not proceed until we have attempted to download the config file at least once
324-
325-
if err != nil && len(gl.Remotes) != 0 {
326-
logger.Debug("Previously fetched target list will be re-used")
327-
return nil
328-
329-
}
330-
gl.Remotes = remotes
331323
return err
332324
}
333325

@@ -388,23 +380,31 @@ func refreshRemoteList(
388380
err = readRemoteList(raw, gl.RemoteConfig, remotes, maxNumSrcTCPPorts,
389381
minBatchInterval, logger)
390382
if err != nil {
391-
logger.Error("error parsing downloaded YAML configuration file",
383+
logger.Error("error parsing downloaded configuration file",
392384
zap.Error(err))
393-
goto cont
385+
goto contError
394386
}
387+
gl.Remotes = remotes
395388
logger.Info("Will poll Orchestrator again later",
396389
zap.String("retry_time",
397390
gl.RemoteConfig.PollOrchestratorInterval.Success.String()))
398391
return nil
399392

400393
case http.StatusNotFound:
401394
retryTime = gl.RemoteConfig.PollOrchestratorInterval.Success
402-
goto cont
395+
goto stayIdle
403396
}
404397
}
405398
logger.Info("Failed to download configuration file", zap.Error(err))
406399

407-
cont:
400+
contError:
401+
if len(gl.Remotes) != 0 {
402+
logger.Debug("last successfully fetched target list will be re-used")
403+
return nil
404+
405+
}
406+
stayIdle:
407+
// Do not proceed until we have attempted to download the config file at least once.
408408
logger.Info("Retrying configuration download", zap.String("retry_time", retryTime.String()))
409409
confRetry := time.NewTicker(retryTime)
410410

0 commit comments

Comments
 (0)