mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1267 from sanimej/extdns
Setup external DNS servers after daemon restart with live-restore
This commit is contained in:
commit
0551112769
4 changed files with 21 additions and 8 deletions
|
@ -728,7 +728,7 @@ func (sb *sandbox) restoreOslSandbox() error {
|
|||
}
|
||||
}
|
||||
if ep.needResolver() {
|
||||
sb.startResolver()
|
||||
sb.startResolver(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
|
|||
ep.Unlock()
|
||||
|
||||
if ep.needResolver() {
|
||||
sb.startResolver()
|
||||
sb.startResolver(false)
|
||||
}
|
||||
|
||||
if i != nil && i.srcName != "" {
|
||||
|
|
|
@ -21,7 +21,7 @@ const (
|
|||
filePerm = 0644
|
||||
)
|
||||
|
||||
func (sb *sandbox) startResolver() {
|
||||
func (sb *sandbox) startResolver(restore bool) {
|
||||
sb.resolverOnce.Do(func() {
|
||||
var err error
|
||||
sb.resolver = NewResolver(sb)
|
||||
|
@ -31,10 +31,16 @@ func (sb *sandbox) startResolver() {
|
|||
}
|
||||
}()
|
||||
|
||||
err = sb.rebuildDNS()
|
||||
if err != nil {
|
||||
log.Errorf("Updating resolv.conf failed for container %s, %q", sb.ContainerID(), err)
|
||||
return
|
||||
// In the case of live restore container is already running with
|
||||
// right resolv.conf contents created before. Just update the
|
||||
// external DNS servers from the restored sandbox for embedded
|
||||
// server to use.
|
||||
if !restore {
|
||||
err = sb.rebuildDNS()
|
||||
if err != nil {
|
||||
log.Errorf("Updating resolv.conf failed for container %s, %q", sb.ContainerID(), err)
|
||||
return
|
||||
}
|
||||
}
|
||||
sb.resolver.SetExtServers(sb.extDNS)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
// Stub implementations for DNS related functions
|
||||
|
||||
func (sb *sandbox) startResolver() {
|
||||
func (sb *sandbox) startResolver(bool) {
|
||||
}
|
||||
|
||||
func (sb *sandbox) setupResolutionFiles() error {
|
||||
|
|
|
@ -27,6 +27,7 @@ type sbState struct {
|
|||
dbExists bool
|
||||
Eps []epState
|
||||
EpPriority map[string]int
|
||||
ExtDNS []string
|
||||
}
|
||||
|
||||
func (sbs *sbState) Key() []string {
|
||||
|
@ -113,6 +114,10 @@ func (sbs *sbState) CopyTo(o datastore.KVObject) error {
|
|||
dstSbs.Eps = append(dstSbs.Eps, eps)
|
||||
}
|
||||
|
||||
for _, dns := range sbs.ExtDNS {
|
||||
dstSbs.ExtDNS = append(dstSbs.ExtDNS, dns)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -126,6 +131,7 @@ func (sb *sandbox) storeUpdate() error {
|
|||
ID: sb.id,
|
||||
Cid: sb.containerID,
|
||||
EpPriority: sb.epPriority,
|
||||
ExtDNS: sb.extDNS,
|
||||
}
|
||||
|
||||
retry:
|
||||
|
@ -198,6 +204,7 @@ func (c *controller) sandboxCleanup(activeSandboxes map[string]interface{}) {
|
|||
dbIndex: sbs.dbIndex,
|
||||
isStub: true,
|
||||
dbExists: true,
|
||||
extDNS: sbs.ExtDNS,
|
||||
}
|
||||
|
||||
msg := " for cleanup"
|
||||
|
|
Loading…
Reference in a new issue