Show some IPAM status at /status/ipam
This commit is contained in:
1 parent
f2d7a28258
commit
34e7996f2f
3 files changed
+132
-3
No files matched your search
@@ -316,6 +316,26 @@ func (r *Ring) OwnedRanges() (result []address.Range) {
|
||||
return r.splitRangesOverZero(result)
|
||||
}
|
||||
|
||||
func (r *Ring) OwnedRangesByPeer() map[mesh.PeerName][]address.Range {
|
||||
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)
|
||||
}
|
||||
}
|
||||
for peer, resultPeer := range result {
|
||||
result[peer] = r.splitRangesOverZero(resultPeer)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// ClaimForPeers claims the entire ring for the array of peers passed
|
||||
// in. Only works for empty rings.
|
||||
func (r *Ring) ClaimForPeers(peers []mesh.PeerName) {
|
||||
|
||||
@@ -2,13 +2,23 @@ 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"
|
||||
)
|
||||
|
||||
type Status struct {
|
||||
Paxos *paxos.Status
|
||||
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
|
||||
@@ -40,7 +50,14 @@ func NewStatus(allocator *Allocator, defaultSubnet address.CIDR) *Status {
|
||||
resultChan <- &Status{
|
||||
paxosStatus,
|
||||
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)}
|
||||
|
||||
Reference in new issue
Block a user