From 1d6f1f75617af065bfa41cf685e9a9217a13a976 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 29 May 2015 17:34:17 +0100 Subject: [PATCH 1/2] Improve ipam status message before and after pending consensus --- ipam/allocator.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ipam/allocator.go b/ipam/allocator.go index d7ec53cb..00f068de 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -456,10 +456,12 @@ func (alloc *Allocator) actorLoop(actionChan <-chan func()) { func (alloc *Allocator) string() string { var buf bytes.Buffer - fmt.Fprintf(&buf, "Allocator subnet %s/%d\n", alloc.subnetStart.String(), alloc.prefixLen) + fmt.Fprintf(&buf, "Allocator subnet %s/%d", alloc.subnetStart.String(), alloc.prefixLen) if alloc.ring.Empty() { - fmt.Fprintf(&buf, "Awaiting consensus: %s", alloc.paxos.String()) + if alloc.paxosTicker != nil { + fmt.Fprintf(&buf, " awaiting consensus: %s", alloc.paxos.String()) + } } else { localFreeSpace := alloc.space.NumFreeAddresses() remoteFreeSpace := alloc.ring.TotalRemoteFree() @@ -469,14 +471,14 @@ func (alloc *Allocator) string() string { fmt.Fprint(&buf, "Owned Ranges:") alloc.ring.FprintWithNicknames(&buf, alloc.nicknames) - if len(alloc.pendingAllocates)+len(alloc.pendingClaims) > 0 { - fmt.Fprintf(&buf, "\nPending requests for ") - for _, op := range alloc.pendingAllocates { - fmt.Fprintf(&buf, "%s, ", op.String()) - } - for _, op := range alloc.pendingClaims { - fmt.Fprintf(&buf, "%s, ", op.String()) - } + } + if len(alloc.pendingAllocates)+len(alloc.pendingClaims) > 0 { + fmt.Fprintf(&buf, "\nPending requests for ") + for _, op := range alloc.pendingAllocates { + fmt.Fprintf(&buf, "%s, ", op.String()) + } + for _, op := range alloc.pendingClaims { + fmt.Fprintf(&buf, "%s, ", op.String()) } } return buf.String() From cd1cca3df26f93ce36199858a7a252f51e0b3b18 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 1 Jun 2015 10:55:01 +0100 Subject: [PATCH 2/2] Reformat output of pending ipam requests --- ipam/allocator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipam/allocator.go b/ipam/allocator.go index 00f068de..1fa2a0e8 100644 --- a/ipam/allocator.go +++ b/ipam/allocator.go @@ -473,12 +473,12 @@ func (alloc *Allocator) string() string { alloc.ring.FprintWithNicknames(&buf, alloc.nicknames) } if len(alloc.pendingAllocates)+len(alloc.pendingClaims) > 0 { - fmt.Fprintf(&buf, "\nPending requests for ") + fmt.Fprintf(&buf, "\nPending requests:") for _, op := range alloc.pendingAllocates { - fmt.Fprintf(&buf, "%s, ", op.String()) + fmt.Fprintf(&buf, "\n %s", op.String()) } for _, op := range alloc.pendingClaims { - fmt.Fprintf(&buf, "%s, ", op.String()) + fmt.Fprintf(&buf, "\n %s", op.String()) } } return buf.String()