From 77c4222249bd777ec2b23c97dc1a4f0b3a352a35 Mon Sep 17 00:00:00 2001 From: Darin Date: Fri, 26 Apr 2019 13:24:05 -0700 Subject: [PATCH] server: ensure first node status written within Server.Start() 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 --- pkg/server/node.go | 6 +++--- pkg/server/server.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/server/node.go b/pkg/server/node.go index 766dd4160753..f6833b3997a9 100644 --- a/pkg/server/node.go +++ b/pkg/server/node.go @@ -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 { diff --git a/pkg/server/server.go b/pkg/server/server.go index b6cf19a41f86..b8d1bd286422 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -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) != "" { @@ -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 {