mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
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:
@@ -25,7 +25,7 @@ func setup(c *caddy.Controller) error {
|
||||
if err != nil {
|
||||
return plugin.Error("azure", err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
publicDNSClient := publicAzureDNS.NewRecordSetsClient(env.Values[auth.SubscriptionID])
|
||||
if publicDNSClient.Authorizer, err = env.GetAuthorizer(); err != nil {
|
||||
@@ -50,6 +50,7 @@ func setup(c *caddy.Controller) error {
|
||||
h.Next = next
|
||||
return h
|
||||
})
|
||||
c.OnShutdown(func() error { cancel(); return nil })
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user