Better log and status messages for Paxos observer

This commit is contained in:
Bryan Boreham committed 2016-04-07 12:50:52 +01:00
1 parent 0c59de40e7
commit c12a52d20e
4 files changed
+11 -2

No files matched your search

+3 -1
View File
@@ -887,8 +887,10 @@ func (alloc *Allocator) loadPersistedData() {
if len(alloc.seed) != 0 {
alloc.infof("Initialising with supplied IPAM seed")
alloc.createRing(alloc.seed)
} else {
} else if alloc.paxos.IsElector() {
alloc.infof("Initialising via deferred consensus")
} else {
alloc.infof("Initialising as observer - awaiting IPAM data from another peer")
}
}
+2 -1
View File
@@ -262,10 +262,11 @@ func (node *Node) IsElector() bool {
}
type Status struct {
Elector bool
KnownNodes int
Quorum uint
}
func NewStatus(node *Node) *Status {
return &Status{len(node.knows), node.quorum}
return &Status{true, len(node.knows), node.quorum}
}
+2
View File
@@ -41,6 +41,8 @@ func NewStatus(allocator *Allocator, defaultSubnet address.CIDR) *Status {
if node, ok := allocator.paxos.(*paxos.Node); ok {
paxosStatus = paxos.NewStatus(node)
}
} else {
paxosStatus = &paxos.Status{Elector: false}
}
}
+4
View File
@@ -166,7 +166,11 @@ var statusTemplate = defTemplate("status", `\
Status: ready
{{end}}\
{{else if .IPAM.Paxos}}\
{{if .IPAM.Paxos.Elector}}\
Status: awaiting consensus (quorum: {{.IPAM.Paxos.Quorum}}, known: {{.IPAM.Paxos.KnownNodes}})
{{else}}\
Status: awaiting consensus (observer)
{{end}}\
{{else}}\
Status: idle
{{end}}\