Skip to content

Commit

Permalink
store: Tiny logging improvements. (#370)
Browse files Browse the repository at this point in the history
Signed-off-by: Bartek Plotka <[email protected]>
  • Loading branch information
bwplotka authored Jun 7, 2018
1 parent 1e4e80c commit 35d7e10
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 10 additions & 0 deletions cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"math"
"net"
"net/http"
Expand Down Expand Up @@ -143,6 +144,10 @@ func runQuery(
) error {
var staticSpecs []query.StoreSpec
for _, addr := range storeAddrs {
if addr == "" {
return errors.New("static store address cannot be empty")
}

staticSpecs = append(staticSpecs, query.NewGRPCStoreSpec(addr))
}
var (
Expand All @@ -153,6 +158,11 @@ func runQuery(
specs = append(staticSpecs)

for id, ps := range peer.PeerStates(cluster.PeerTypesStoreAPIs()...) {
if ps.StoreAPIAddr == "" {
level.Error(logger).Log("msg", "Gossip found peer that propagates empty address, ignoring.", "lset", fmt.Sprintf("%v", ps.Metadata.Labels))
continue
}

specs = append(specs, &gossipSpec{id: id, addr: ps.StoreAPIAddr, peer: peer})
}
return specs
Expand Down
11 changes: 7 additions & 4 deletions cmd/thanos/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,13 @@ func runStore(
ctx, cancel := context.WithCancel(context.Background())
g.Add(func() error {
// New gossip cluster.
if err := peer.Join(cluster.PeerTypeStore, cluster.PeerMetadata{
MinTime: math.MinInt64,
MaxTime: math.MaxInt64,
}); err != nil {
if err := peer.Join(
cluster.PeerTypeStore,
cluster.PeerMetadata{
MinTime: math.MinInt64,
MaxTime: math.MaxInt64,
},
); err != nil {
return errors.Wrap(err, "join cluster")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (p *Peer) Join(peerType PeerType, initialMetadata PeerMetadata) error {
}

n, _ := ml.Join(p.knownPeers)
level.Debug(p.logger).Log("msg", "joined cluster", "peers", n, "peerType", peerType)
level.Debug(p.logger).Log("msg", "joined cluster", "peerType", peerType)

if n > 0 {
go warnIfAlone(p.logger, 10*time.Second, p.stopc, ml.NumMembers)
Expand All @@ -204,6 +204,7 @@ func (p *Peer) Join(peerType PeerType, initialMetadata PeerMetadata) error {
QueryAPIAddr: p.advertiseQueryAPIAddress,
Metadata: initialMetadata,
})

return nil
}

Expand Down Expand Up @@ -302,7 +303,6 @@ func (p *Peer) PeerStates(types ...PeerType) map[string]PeerState {
ps[o.Name] = os
continue
}

for _, t := range types {
if os.Type == t {
ps[o.Name] = os
Expand Down

0 comments on commit 35d7e10

Please sign in to comment.