1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Make o/p of ipam DumpDatabase() consistent

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch 2016-04-15 17:28:59 -07:00
parent 83d261fd47
commit 04f5343139

View file

@ -3,6 +3,7 @@ package ipam
import ( import (
"fmt" "fmt"
"net" "net"
"sort"
"sync" "sync"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
@ -554,13 +555,18 @@ func (a *Allocator) getAddress(nw *net.IPNet, bitmask *bitseq.Handle, prefAddres
func (a *Allocator) DumpDatabase() string { func (a *Allocator) DumpDatabase() string {
a.Lock() a.Lock()
aspaces := make(map[string]*addrSpace, len(a.addrSpaces)) aspaces := make(map[string]*addrSpace, len(a.addrSpaces))
orderedAS := make([]string, 0, len(a.addrSpaces))
for as, aSpace := range a.addrSpaces { for as, aSpace := range a.addrSpaces {
orderedAS = append(orderedAS, as)
aspaces[as] = aSpace aspaces[as] = aSpace
} }
a.Unlock() a.Unlock()
sort.Strings(orderedAS)
var s string var s string
for as, aSpace := range aspaces { for _, as := range orderedAS {
aSpace := aspaces[as]
s = fmt.Sprintf("\n\n%s Config", as) s = fmt.Sprintf("\n\n%s Config", as)
aSpace.Lock() aSpace.Lock()
for k, config := range aSpace.subnets { for k, config := range aSpace.subnets {