Skip to content

Commit 6f56618

Browse files
committed
BACKPORT: Fix the data model inconsistency that breaks daemon upgrade to 1.14-dev
Upstream reference: moby/libnetwork#1620 Fix https://bugzilla.redhat.com/show_bug.cgi?id=1464790 Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent af23c1b commit 6f56618

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

vendor/src/github.com/docker/libnetwork/resolver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ const (
4848
)
4949

5050
type extDNSEntry struct {
51-
ipStr string
52-
hostLoopback bool
51+
IPStr string
52+
HostLoopback bool
5353
}
5454

5555
// resolver implements the Resolver interface
@@ -355,15 +355,15 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
355355
} else {
356356
for i := 0; i < maxExtDNS; i++ {
357357
extDNS := &r.extDNSList[i]
358-
if extDNS.ipStr == "" {
358+
if extDNS.IPStr == "" {
359359
break
360360
}
361361
extConnect := func() {
362-
addr := fmt.Sprintf("%s:%d", extDNS.ipStr, 53)
362+
addr := fmt.Sprintf("%s:%d", extDNS.IPStr, 53)
363363
extConn, err = net.DialTimeout(proto, addr, extIOTimeout)
364364
}
365365

366-
if extDNS.hostLoopback {
366+
if extDNS.HostLoopback {
367367
extConnect()
368368
} else {
369369
execErr := r.sb.execFunc(extConnect)
@@ -377,7 +377,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) {
377377
continue
378378
}
379379
log.Debugf("Query %s[%d] from %s, forwarding to %s:%s", name, query.Question[0].Qtype,
380-
extConn.LocalAddr().String(), proto, extDNS.ipStr)
380+
extConn.LocalAddr().String(), proto, extDNS.IPStr)
381381

382382
// Timeout has to be set for every IO operation.
383383
extConn.SetDeadline(time.Now().Add(extIOTimeout))

vendor/src/github.com/docker/libnetwork/sandbox_dns_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ func (sb *sandbox) setExternalResolvers(content []byte, addrType int, checkLoopb
168168
hostLoopback = dns.IsIPv4Localhost(ip)
169169
}
170170
sb.extDNS = append(sb.extDNS, extDNSEntry{
171-
ipStr: ip,
172-
hostLoopback: hostLoopback,
171+
IPStr: ip,
172+
HostLoopback: hostLoopback,
173173
})
174174
}
175175
}

vendor/src/github.com/docker/libnetwork/sandbox_store.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ type sbState struct {
2727
dbExists bool
2828
Eps []epState
2929
EpPriority map[string]int
30-
ExtDNS []extDNSEntry
30+
// external servers have to be persisted so that on restart of a live-restore
31+
// enabled daemon we get the external servers for the running containers.
32+
// We have two versions of ExtDNS to support upgrade & downgrade of the daemon
33+
// between >=1.14 and <1.14 versions.
34+
ExtDNS []string
35+
ExtDNS2 []extDNSEntry
3136
}
3237

3338
func (sbs *sbState) Key() []string {
@@ -114,8 +119,17 @@ func (sbs *sbState) CopyTo(o datastore.KVObject) error {
114119
dstSbs.Eps = append(dstSbs.Eps, eps)
115120
}
116121

122+
if len(sbs.ExtDNS2) > 0 {
123+
for _, dns := range sbs.ExtDNS2 {
124+
dstSbs.ExtDNS2 = append(dstSbs.ExtDNS2, dns)
125+
dstSbs.ExtDNS = append(dstSbs.ExtDNS, dns.IPStr)
126+
}
127+
return nil
128+
}
129+
117130
for _, dns := range sbs.ExtDNS {
118131
dstSbs.ExtDNS = append(dstSbs.ExtDNS, dns)
132+
dstSbs.ExtDNS2 = append(dstSbs.ExtDNS2, extDNSEntry{IPStr: dns})
119133
}
120134

121135
return nil
@@ -131,7 +145,11 @@ func (sb *sandbox) storeUpdate() error {
131145
ID: sb.id,
132146
Cid: sb.containerID,
133147
EpPriority: sb.epPriority,
134-
ExtDNS: sb.extDNS,
148+
ExtDNS2: sb.extDNS,
149+
}
150+
151+
for _, ext := range sb.extDNS {
152+
sbs.ExtDNS = append(sbs.ExtDNS, ext.IPStr)
135153
}
136154

137155
retry:
@@ -205,7 +223,16 @@ func (c *controller) sandboxCleanup(activeSandboxes map[string]interface{}) {
205223
dbIndex: sbs.dbIndex,
206224
isStub: true,
207225
dbExists: true,
208-
extDNS: sbs.ExtDNS,
226+
}
227+
228+
// If we are restoring from a older version extDNSEntry won't have the
229+
// HostLoopback field
230+
if len(sbs.ExtDNS2) > 0 {
231+
sb.extDNS = sbs.ExtDNS2
232+
} else {
233+
for _, dns := range sbs.ExtDNS {
234+
sb.extDNS = append(sb.extDNS, extDNSEntry{IPStr: dns})
235+
}
209236
}
210237

211238
msg := " for cleanup"

0 commit comments

Comments
 (0)