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() {
|
if ep.needResolver() {
|
||||||
sb.startResolver()
|
sb.startResolver(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,7 +761,7 @@ func (sb *sandbox) populateNetworkResources(ep *endpoint) error {
|
||||||
ep.Unlock()
|
ep.Unlock()
|
||||||
|
|
||||||
if ep.needResolver() {
|
if ep.needResolver() {
|
||||||
sb.startResolver()
|
sb.startResolver(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if i != nil && i.srcName != "" {
|
if i != nil && i.srcName != "" {
|
||||||
|
|
|
@ -21,7 +21,7 @@ const (
|
||||||
filePerm = 0644
|
filePerm = 0644
|
||||||
)
|
)
|
||||||
|
|
||||||
func (sb *sandbox) startResolver() {
|
func (sb *sandbox) startResolver(restore bool) {
|
||||||
sb.resolverOnce.Do(func() {
|
sb.resolverOnce.Do(func() {
|
||||||
var err error
|
var err error
|
||||||
sb.resolver = NewResolver(sb)
|
sb.resolver = NewResolver(sb)
|
||||||
|
@ -31,10 +31,16 @@ func (sb *sandbox) startResolver() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = sb.rebuildDNS()
|
// In the case of live restore container is already running with
|
||||||
if err != nil {
|
// right resolv.conf contents created before. Just update the
|
||||||
log.Errorf("Updating resolv.conf failed for container %s, %q", sb.ContainerID(), err)
|
// external DNS servers from the restored sandbox for embedded
|
||||||
return
|
// 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)
|
sb.resolver.SetExtServers(sb.extDNS)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
// Stub implementations for DNS related functions
|
// Stub implementations for DNS related functions
|
||||||
|
|
||||||
func (sb *sandbox) startResolver() {
|
func (sb *sandbox) startResolver(bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *sandbox) setupResolutionFiles() error {
|
func (sb *sandbox) setupResolutionFiles() error {
|
||||||
|
|
|
@ -27,6 +27,7 @@ type sbState struct {
|
||||||
dbExists bool
|
dbExists bool
|
||||||
Eps []epState
|
Eps []epState
|
||||||
EpPriority map[string]int
|
EpPriority map[string]int
|
||||||
|
ExtDNS []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sbs *sbState) Key() []string {
|
func (sbs *sbState) Key() []string {
|
||||||
|
@ -113,6 +114,10 @@ func (sbs *sbState) CopyTo(o datastore.KVObject) error {
|
||||||
dstSbs.Eps = append(dstSbs.Eps, eps)
|
dstSbs.Eps = append(dstSbs.Eps, eps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, dns := range sbs.ExtDNS {
|
||||||
|
dstSbs.ExtDNS = append(dstSbs.ExtDNS, dns)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +131,7 @@ func (sb *sandbox) storeUpdate() error {
|
||||||
ID: sb.id,
|
ID: sb.id,
|
||||||
Cid: sb.containerID,
|
Cid: sb.containerID,
|
||||||
EpPriority: sb.epPriority,
|
EpPriority: sb.epPriority,
|
||||||
|
ExtDNS: sb.extDNS,
|
||||||
}
|
}
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
|
@ -198,6 +204,7 @@ func (c *controller) sandboxCleanup(activeSandboxes map[string]interface{}) {
|
||||||
dbIndex: sbs.dbIndex,
|
dbIndex: sbs.dbIndex,
|
||||||
isStub: true,
|
isStub: true,
|
||||||
dbExists: true,
|
dbExists: true,
|
||||||
|
extDNS: sbs.ExtDNS,
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := " for cleanup"
|
msg := " for cleanup"
|
||||||
|
|
Loading…
Reference in a new issue