mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -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:
@@ -124,7 +124,7 @@ func setup(c *caddy.Controller) error {
|
||||
Client: ec2metadata.New(session),
|
||||
})
|
||||
client := f(credentials.NewChainCredentials(providers))
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
h, err := New(ctx, client, keys, refresh)
|
||||
if err != nil {
|
||||
return plugin.Error("route53", c.Errf("failed to create route53 plugin: %v", err))
|
||||
@@ -137,7 +137,7 @@ func setup(c *caddy.Controller) error {
|
||||
h.Next = next
|
||||
return h
|
||||
})
|
||||
c.OnShutdown(func() error { ctx.Done(); return nil })
|
||||
c.OnShutdown(func() error { cancel(); return nil })
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user