Remove specialised knowledge of IPAM from weave status formatter
and unnecessary info from `weave report` output
This commit is contained in:
1 parent
e38018ab1e
commit
3a9bcbcf6b
3 files changed
+59
-72
No files matched your search
+13
-12
@@ -316,24 +316,25 @@ func (r *Ring) OwnedRanges() (result []address.Range) {
|
||||
return r.splitRangesOverZero(result)
|
||||
}
|
||||
|
||||
func (r *Ring) OwnedRangesByPeer() map[mesh.PeerName][]address.Range {
|
||||
// For printing status
|
||||
type RangeInfo struct {
|
||||
Peer mesh.PeerName
|
||||
address.Range
|
||||
Version uint32
|
||||
}
|
||||
|
||||
func (r *Ring) AllRangeInfo() (result []RangeInfo) {
|
||||
r.assertInvariants()
|
||||
|
||||
result := make(map[mesh.PeerName][]address.Range)
|
||||
for i, entry := range r.Entries {
|
||||
nextEntry := r.Entries.entry(i + 1)
|
||||
resultPeer, found := result[entry.Peer]
|
||||
r := address.Range{Start: entry.Token, End: nextEntry.Token}
|
||||
if !found {
|
||||
result[entry.Peer] = []address.Range{r}
|
||||
} else {
|
||||
result[entry.Peer] = append(resultPeer, r)
|
||||
ranges := []address.Range{{Start: entry.Token, End: nextEntry.Token}}
|
||||
ranges = r.splitRangesOverZero(ranges)
|
||||
for _, r := range ranges {
|
||||
result = append(result, RangeInfo{entry.Peer, r, entry.Version})
|
||||
}
|
||||
}
|
||||
for peer, resultPeer := range result {
|
||||
result[peer] = r.splitRangesOverZero(resultPeer)
|
||||
}
|
||||
return result
|
||||
return
|
||||
}
|
||||
|
||||
// ClaimForPeers claims the entire ring for the array of peers passed
|
||||
|
||||
+15
-20
@@ -2,9 +2,6 @@ package ipam
|
||||
|
||||
import (
|
||||
"github.com/weaveworks/weave/ipam/paxos"
|
||||
"github.com/weaveworks/weave/ipam/ring"
|
||||
"github.com/weaveworks/weave/ipam/space"
|
||||
"github.com/weaveworks/weave/mesh"
|
||||
"github.com/weaveworks/weave/net/address"
|
||||
)
|
||||
|
||||
@@ -13,21 +10,18 @@ type Status struct {
|
||||
Range string
|
||||
RangeNumIPs int
|
||||
DefaultSubnet string
|
||||
Ring *ring.Ring // information on ranges owned by all peers
|
||||
Space space.Space // more detail on ranges owned by us
|
||||
Owned map[string][]address.Address // addresses by container-ID
|
||||
OurName mesh.PeerName
|
||||
Nicknames map[mesh.PeerName]string `json:"-"`
|
||||
IsKnownPeer func(mesh.PeerName) bool `json:"-"`
|
||||
Entries []EntryStatus
|
||||
PendingClaims []ClaimStatus
|
||||
PendingAllocates []string
|
||||
}
|
||||
|
||||
type EntryStatus struct {
|
||||
Token string
|
||||
Peer string
|
||||
Version uint32
|
||||
Token string
|
||||
Size uint32
|
||||
Peer string
|
||||
Nickname string
|
||||
IsKnownPeer bool
|
||||
Version uint32
|
||||
}
|
||||
|
||||
type ClaimStatus struct {
|
||||
@@ -52,12 +46,6 @@ func NewStatus(allocator *Allocator, defaultSubnet address.CIDR) *Status {
|
||||
allocator.universe.String(),
|
||||
int(allocator.universe.Size()),
|
||||
defaultSubnet.String(),
|
||||
allocator.ring,
|
||||
allocator.space,
|
||||
allocator.owned,
|
||||
allocator.ourName,
|
||||
allocator.nicknames,
|
||||
allocator.isKnownPeer,
|
||||
newEntryStatusSlice(allocator),
|
||||
newClaimStatusSlice(allocator),
|
||||
newAllocateIdentSlice(allocator)}
|
||||
@@ -73,8 +61,15 @@ func newEntryStatusSlice(allocator *Allocator) []EntryStatus {
|
||||
return slice
|
||||
}
|
||||
|
||||
for _, entry := range allocator.ring.Entries {
|
||||
slice = append(slice, EntryStatus{entry.Token.String(), entry.Peer.String(), entry.Version})
|
||||
for _, r := range allocator.ring.AllRangeInfo() {
|
||||
slice = append(slice, EntryStatus{
|
||||
Token: r.Start.String(),
|
||||
Size: uint32(r.Size()),
|
||||
Peer: r.Peer.String(),
|
||||
Nickname: allocator.nicknames[r.Peer],
|
||||
IsKnownPeer: allocator.isKnownPeer(r.Peer),
|
||||
Version: r.Version,
|
||||
})
|
||||
}
|
||||
|
||||
return slice
|
||||
|
||||
Reference in new issue
Block a user