Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachtest: prefix all logs with worker tags #124027

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/cmd/roachtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ go_library(
"//pkg/util/timeutil",
"//pkg/util/version",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_logtags//:logtags",
"@com_github_datadog_datadog_go//statsd",
"@com_github_lib_pq//:pq",
"@com_github_petermattis_goid//:goid",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
vidit-bhat marked this conversation as resolved.
Show resolved Hide resolved
func (c *clusterImpl) PutString(
ctx context.Context, content, dest string, mode os.FileMode, nodes ...option.Option,
) error {
Expand Down
18 changes: 12 additions & 6 deletions pkg/cmd/roachtest/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/version"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/logtags"
"github.com/petermattis/goid"
)

Expand Down Expand Up @@ -363,21 +362,29 @@ func (r *testRunner) Run(
if err := r.stopper.RunAsyncTask(ctx, "worker", func(ctx context.Context) {
defer wg.Done()

err := r.runWorker(
ctx, fmt.Sprintf("w%d", i) /* name */, r.work, qp,
name := fmt.Sprintf("w%d", i)
formattedPrefix := fmt.Sprintf("[%s] ", name)
childLogger, err := l.ChildLogger(name, logger.LogPrefix(formattedPrefix))
if err != nil {
l.ErrorfCtx(ctx, "unable to create logger %s: %s", name, err)
childLogger = l
}

err = r.runWorker(
ctx, name, r.work, qp,
vidit-bhat marked this conversation as resolved.
Show resolved Hide resolved
r.stopper.ShouldQuiesce(),
clusterFactory,
clustersOpt,
lopt,
topt,
l,
childLogger,
n*count,
)

if err != nil {
// A worker returned an error. Let's shut down.
msg := fmt.Sprintf("Worker %d returned with error. Quiescing. Error: %v", i, err)
shout(ctx, l, lopt.stdout, msg)
shout(ctx, childLogger, lopt.stdout, msg)
errs.AddErr(err)
// Stop the stopper. This will cause all workers to not pick up more
// tests after finishing the currently running one. We add one to the
Expand Down Expand Up @@ -557,7 +564,6 @@ func (r *testRunner) runWorker(
) error {
stdout := lopt.stdout

ctx = logtags.AddTag(ctx, name, nil /* value */)
wStatus := r.addWorker(ctx, name)
defer func() {
r.removeWorker(ctx, name)
Expand Down
Loading