Skip to content

Commit

Permalink
server: ensure first node status written within Server.Start()
Browse files Browse the repository at this point in the history
The fix ensures that the status of the first node is written before
the end of `Server.Start`. Currently this is deferred
and sometimes the code doesn't execute by the time the tests start
running. For the rest of the nodes, the status is written as part of
the node bootstrap.

Fixes #33559 and #36990.

Release note: None
  • Loading branch information
darinpp committed Apr 26, 2019
1 parent 0fa3af2 commit 77c4222
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/server/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,12 @@ func (n *Node) startGraphiteStatsExporter(st *cluster.Settings) {
func (n *Node) startWriteNodeStatus(frequency time.Duration) {
ctx := logtags.AddTag(n.AnnotateCtx(context.Background()), "summaries", nil)
// Immediately record summaries once on server startup.
if err := n.writeNodeStatus(ctx, 0 /* alertTTL */); err != nil {
log.Warningf(ctx, "error recording initial status summaries: %s", err)
}
n.stopper.RunWorker(ctx, func(ctx context.Context) {
// Write a status summary immediately; this helps the UI remain
// responsive when new nodes are added.
if err := n.writeNodeStatus(ctx, 0 /* alertTTL */); err != nil {
log.Warningf(ctx, "error recording initial status summaries: %s", err)
}
ticker := time.NewTicker(frequency)
defer ticker.Stop()
for {
Expand Down
6 changes: 3 additions & 3 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1545,9 +1545,6 @@ func (s *Server) Start(ctx context.Context) error {
s.cfg.AmbientCtx, s.recorder, DefaultMetricsSampleInterval, ts.Resolution10s, s.stopper,
)

// Begin recording status summaries.
s.node.startWriteNodeStatus(DefaultMetricsSampleInterval)

var graphiteOnce sync.Once
graphiteEndpoint.SetOnChange(&s.st.SV, func() {
if graphiteEndpoint.Get(&s.st.SV) != "" {
Expand Down Expand Up @@ -1601,6 +1598,9 @@ func (s *Server) Start(ctx context.Context) error {
}
})

// Begin recording status summaries.
s.node.startWriteNodeStatus(DefaultMetricsSampleInterval)

{
var regLiveness jobs.NodeLiveness = s.nodeLiveness
if testingLiveness := s.cfg.TestingKnobs.RegistryLiveness; testingLiveness != nil {
Expand Down

0 comments on commit 77c4222

Please sign in to comment.