Skip to content

Commit

Permalink
roachtest: allow NoNodes to c.NewMonitor
Browse files Browse the repository at this point in the history
It can be helpful to spin up a `Monitor` that monitors only a set of
goroutines, without also watching the nodes in underlying cluster,
which is the default, and which could not be "narrowed down" to an
empty set of nodes.

This commit permits that.

Release note: None
  • Loading branch information
tbg committed Apr 12, 2022
1 parent d6a01b7 commit 36c3799
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,12 @@ func (c *clusterImpl) MakeNodes(opts ...option.Option) string {
if s, ok := o.(nodeSelector); ok {
r = s.Merge(r)
}
if _, ok := o.(*option.NoNodes); ok {
return ""
}
if _, ok := o.(option.NoNodes); ok {
return ""
}
}
return c.name + r.String()
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/roachtest/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ func (m *monitorImpl) wait() error {
wg.Done()
}()

if m.nodes == "" {
<-m.ctx.Done()
return
}
messagesChannel, err := roachprod.Monitor(m.ctx, m.l, m.nodes, install.MonitorOpts{})
if err != nil {
setErr(errors.Wrap(err, "monitor command failure"))
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/roachtest/option/node_list_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,9 @@ func (n NodeListOption) String() string {
}
return buf.String()
}

// NoNodes is an option that explicitly deselects all nodes.
type NoNodes struct{}

// Option implements option.Option.
func (n NoNodes) Option() {}

0 comments on commit 36c3799

Please sign in to comment.