From 336d8c3eea884c90dbc899ab7b99cb163a27bb5b Mon Sep 17 00:00:00 2001 From: Vidit Bhat Date: Mon, 13 May 2024 13:44:32 +0530 Subject: [PATCH] roachtest: prefix all logs with worker tags Previously, many of the runner logs didn't have the worker tags. This was inadequate because we couldn't break up the logs by wX tags to see what each worker is doing. This PR prefixes the worker tags to logs that were missing them. Epic: none Fixes: #114045 Release note: None --- pkg/cmd/roachtest/cluster.go | 2 +- pkg/cmd/roachtest/test_runner.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/roachtest/cluster.go b/pkg/cmd/roachtest/cluster.go index cec6b8365e54..3d29ac8e6b51 100644 --- a/pkg/cmd/roachtest/cluster.go +++ b/pkg/cmd/roachtest/cluster.go @@ -1927,7 +1927,7 @@ func (c *clusterImpl) Get( return errors.Wrap(roachprod.Get(ctx, l, c.MakeNodes(opts...), src, dest), "cluster.Get") } -// Put a string into the specified file on the remote(s). +// PutString into the specified file on the remote(s). func (c *clusterImpl) PutString( ctx context.Context, content, dest string, mode os.FileMode, nodes ...option.Option, ) error { diff --git a/pkg/cmd/roachtest/test_runner.go b/pkg/cmd/roachtest/test_runner.go index fbd44ba4af64..4eab88fafa3a 100644 --- a/pkg/cmd/roachtest/test_runner.go +++ b/pkg/cmd/roachtest/test_runner.go @@ -363,8 +363,17 @@ func (r *testRunner) Run( if err := r.stopper.RunAsyncTask(ctx, "worker", func(ctx context.Context) { defer wg.Done() + name := fmt.Sprintf("w%d", i) + formattedPrefix := fmt.Sprintf("[%s] ", name) + childLogger, e := l.ChildLogger(name, logger.LogPrefix(formattedPrefix)) + if e != nil { + l.Printf("unable to create logger %s: %s", name, e) + return + } + l = childLogger + err := r.runWorker( - ctx, fmt.Sprintf("w%d", i) /* name */, r.work, qp, + ctx, name, r.work, qp, r.stopper.ShouldQuiesce(), clusterFactory, clustersOpt,