From b8e963595e47c697756855b381430c5534d945e5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 4 Oct 2022 15:32:49 +0200 Subject: [PATCH] libnetwork: sbState: rename ExtDNS2 back to ExtDNS The ExtDNS2 field was added in https://github.com/moby/libnetwork/commit/aad1632c1594970360da89790637d5e7ec1bffaf to migrate existing state from < 1.14 to a new type. As it's unlikely that installations still have state from before 1.14, rename ExtDNS2 back to ExtDNS and drop the migration code. Signed-off-by: Sebastiaan van Stijn Co-authored-by: Cory Snider Signed-off-by: Cory Snider --- libnetwork/sandbox_store.go | 39 +++++++++---------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/libnetwork/sandbox_store.go b/libnetwork/sandbox_store.go index b71549a1c2..92eaf7a155 100644 --- a/libnetwork/sandbox_store.go +++ b/libnetwork/sandbox_store.go @@ -28,10 +28,12 @@ type sbState struct { EpPriority map[string]int // external servers have to be persisted so that on restart of a live-restore // enabled daemon we get the external servers for the running containers. - // We have two versions of ExtDNS to support upgrade & downgrade of the daemon - // between >=1.14 and <1.14 versions. - ExtDNS []string - ExtDNS2 []extDNSEntry + // + // It is persisted as "ExtDNS2" for historical reasons. ExtDNS2 was used to + // handle migration between docker < 1.14 and >= 1.14. Before version 1.14 we + // used ExtDNS but with a []string. As it's unlikely that installations still + // have state from before 1.14, we've dropped the migration code. + ExtDNS []extDNSEntry `json:"ExtDNS2"` } func (sbs *sbState) Key() []string { @@ -112,18 +114,7 @@ func (sbs *sbState) CopyTo(o datastore.KVObject) error { dstSbs.EpPriority = sbs.EpPriority dstSbs.Eps = append(dstSbs.Eps, sbs.Eps...) - - if len(sbs.ExtDNS2) > 0 { - for _, dns := range sbs.ExtDNS2 { - dstSbs.ExtDNS2 = append(dstSbs.ExtDNS2, dns) - dstSbs.ExtDNS = append(dstSbs.ExtDNS, dns.IPStr) - } - return nil - } - for _, dns := range sbs.ExtDNS { - dstSbs.ExtDNS = append(dstSbs.ExtDNS, dns) - dstSbs.ExtDNS2 = append(dstSbs.ExtDNS2, extDNSEntry{IPStr: dns}) - } + dstSbs.ExtDNS = append(dstSbs.ExtDNS, sbs.ExtDNS...) return nil } @@ -138,11 +129,7 @@ func (sb *Sandbox) storeUpdate() error { ID: sb.id, Cid: sb.containerID, EpPriority: sb.epPriority, - ExtDNS2: sb.extDNS, - } - - for _, ext := range sb.extDNS { - sbs.ExtDNS = append(sbs.ExtDNS, ext.IPStr) + ExtDNS: sb.extDNS, } retry: @@ -211,21 +198,13 @@ func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) { id: sbs.ID, controller: sbs.c, containerID: sbs.Cid, + extDNS: sbs.ExtDNS, endpoints: []*Endpoint{}, populatedEndpoints: map[string]struct{}{}, dbIndex: sbs.dbIndex, isStub: true, dbExists: true, } - // If we are restoring from a older version extDNSEntry won't have the - // HostLoopback field - if len(sbs.ExtDNS2) > 0 { - sb.extDNS = sbs.ExtDNS2 - } else { - for _, dns := range sbs.ExtDNS { - sb.extDNS = append(sb.extDNS, extDNSEntry{IPStr: dns}) - } - } msg := " for cleanup" create := true