This repository was archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1248 from /issues/1025-enhanced-weave-status
Enhanced weave status
- Loading branch information
Showing
28 changed files
with
840 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
package common | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
// Assert test is true, panic otherwise | ||
func Assert(test bool) { | ||
if !test { | ||
panic("Assertion failure") | ||
} | ||
} | ||
|
||
func ErrorMessages(errors []error) string { | ||
var result []string | ||
for _, err := range errors { | ||
result = append(result, err.Error()) | ||
} | ||
return strings.Join(result, "\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package ipam | ||
|
||
import ( | ||
"github.com/weaveworks/weave/ipam/paxos" | ||
"github.com/weaveworks/weave/net/address" | ||
) | ||
|
||
type Status struct { | ||
Paxos *paxos.Status | ||
Range string | ||
DefaultSubnet string | ||
Entries []EntryStatus | ||
PendingClaims []ClaimStatus | ||
PendingAllocates []string | ||
} | ||
|
||
type EntryStatus struct { | ||
Token string | ||
Peer string | ||
Version uint32 | ||
} | ||
|
||
type ClaimStatus struct { | ||
Ident string | ||
Address address.Address | ||
} | ||
|
||
func NewStatus(allocator *Allocator, defaultSubnet address.CIDR) *Status { | ||
if allocator == nil { | ||
return nil | ||
} | ||
|
||
var paxosStatus *paxos.Status | ||
if allocator.paxosTicker != nil { | ||
paxosStatus = paxos.NewStatus(allocator.paxos) | ||
} | ||
|
||
resultChan := make(chan *Status) | ||
allocator.actionChan <- func() { | ||
resultChan <- &Status{ | ||
paxosStatus, | ||
allocator.universe.String(), | ||
defaultSubnet.String(), | ||
newEntryStatusSlice(allocator), | ||
newClaimStatusSlice(allocator), | ||
newAllocateIdentSlice(allocator)} | ||
} | ||
|
||
return <-resultChan | ||
} | ||
|
||
func newEntryStatusSlice(allocator *Allocator) []EntryStatus { | ||
var slice []EntryStatus | ||
|
||
if allocator.ring.Empty() { | ||
return slice | ||
} | ||
|
||
for _, entry := range allocator.ring.Entries { | ||
slice = append(slice, EntryStatus{entry.Token.String(), entry.Peer.String(), entry.Version}) | ||
} | ||
|
||
return slice | ||
} | ||
|
||
func newClaimStatusSlice(allocator *Allocator) []ClaimStatus { | ||
var slice []ClaimStatus | ||
for _, op := range allocator.pendingClaims { | ||
claim := op.(*claim) | ||
slice = append(slice, ClaimStatus{claim.ident, claim.addr}) | ||
} | ||
return slice | ||
} | ||
|
||
func newAllocateIdentSlice(allocator *Allocator) []string { | ||
var slice []string | ||
for _, op := range allocator.pendingAllocates { | ||
allocate := op.(*allocate) | ||
slice = append(slice, allocate.ident) | ||
} | ||
return slice | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package nameserver | ||
|
||
type Status struct { | ||
Domain string | ||
Address string | ||
TTL uint32 | ||
Entries []EntryStatus | ||
} | ||
|
||
type EntryStatus struct { | ||
Hostname string | ||
Origin string | ||
ContainerID string | ||
Address string | ||
Version int | ||
Tombstone int64 | ||
} | ||
|
||
func NewStatus(ns *Nameserver, dnsServer *DNSServer) *Status { | ||
if dnsServer == nil { | ||
return nil | ||
} | ||
|
||
ns.RLock() | ||
defer ns.RUnlock() | ||
|
||
var entryStatusSlice []EntryStatus | ||
for _, entry := range ns.entries { | ||
entryStatusSlice = append(entryStatusSlice, EntryStatus{ | ||
entry.Hostname, | ||
entry.Origin.String(), | ||
entry.ContainerID, | ||
entry.Addr.String(), | ||
entry.Version, | ||
entry.Tombstone}) | ||
} | ||
|
||
return &Status{ | ||
dnsServer.domain, | ||
dnsServer.address, | ||
dnsServer.ttl, | ||
entryStatusSlice} | ||
} |
Oops, something went wrong.