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
Enhanced weave status #1248
Merged
Merged
Enhanced weave status #1248
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as abuse.
Sorry, something went wrong.