Use cancelable contexts for cloud provider plugin refreshes (#4226)
This commit uses a cancelable context to spawn goroutines that refresh records from a cloud DNS provider. The Caddy shutdown routine uses the returned cancel function to terminate existing goroutines when a USR1 reload signal is received. Signed-off-by: Matt Kulka <mkulka@parchment.com>
This commit is contained in:
parent
054c9ae1fb
commit
3168a722ca
6 changed files with 12 additions and 11 deletions
|
@ -85,11 +85,11 @@ func (h *CloudDNS) Run(ctx context.Context) error {
|
|||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Infof("Breaking out of CloudDNS update loop: %v", ctx.Err())
|
||||
log.Debugf("Breaking out of CloudDNS update loop for %v: %v", h.zoneNames, ctx.Err())
|
||||
return
|
||||
case <-time.After(1 * time.Minute):
|
||||
if err := h.updateZones(ctx); err != nil && ctx.Err() == nil /* Don't log error if ctx expired. */ {
|
||||
log.Errorf("Failed to update zones: %v", err)
|
||||
log.Errorf("Failed to update zones %v: %v", h.zoneNames, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue