Skip to content

Commit adbd3b2

Browse files
authored
make sure warnings go to stderr instead of stdout in taskqueue commands (#1000)
More correct in general but also in particular for structured output ## What was changed We have a warning printed for stopping all task queues that was being incorrectly being sent to stdout, even with structured output suggested. This fixes that. ## Why? To not mess up structured output. ## Checklist 1. How was this tested: Tested locally against a dev server.
1 parent dff669d commit adbd3b2

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

internal/temporalcli/commands.taskqueue_config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ const (
6363
)
6464

6565
// printZeroRateLimitWarning prints a warning when a rate limit is set to 0
66-
func printZeroRateLimitWarning(p *printer.Printer, limitType string) {
67-
p.Printlnf("WARNING: Setting %s to 0 will STOP ALL TRAFFIC on this task queue.", limitType)
68-
p.Println(" This will prevent any tasks from being dispatched until the limit is changed.")
66+
func printZeroRateLimitWarning(cctx *CommandContext, limitType string) {
67+
fmt.Fprintf(cctx.Options.Stderr, "WARNING: Setting %s to 0 will STOP ALL TRAFFIC on this task queue.\n", limitType)
68+
fmt.Fprintln(cctx.Options.Stderr, " This will prevent any tasks from being dispatched until the limit is changed.")
6969
}
7070

7171
// parseFairnessKeyWeights parses "key=weight" or "key=default" format strings
@@ -200,7 +200,7 @@ func (c *TemporalTaskQueueConfigSetCommand) run(cctx *CommandContext, args []str
200200

201201
// Warn about zero rate limit (stops all traffic)
202202
if queueRateLimitIsZero {
203-
printZeroRateLimitWarning(cctx.Printer, "queue rate limit")
203+
printZeroRateLimitWarning(cctx, "queue rate limit")
204204
}
205205
}
206206

@@ -216,7 +216,7 @@ func (c *TemporalTaskQueueConfigSetCommand) run(cctx *CommandContext, args []str
216216

217217
// Warn about zero rate limit
218218
if fairnessRateLimitIsZero {
219-
printZeroRateLimitWarning(cctx.Printer, "fairness key rate limit default")
219+
printZeroRateLimitWarning(cctx, "fairness key rate limit default")
220220
}
221221
}
222222

internal/temporalcli/commands.taskqueue_config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ func (s *SharedServerSuite) TestTaskQueue_Config_Validation() {
332332
"--queue-rps-limit-reason", "emergency stop",
333333
)
334334
s.NoError(res.Err)
335-
s.Contains(res.Stdout.String(), "WARNING")
336-
s.Contains(res.Stdout.String(), "STOP ALL TRAFFIC")
335+
s.Contains(res.Stderr.String(), "WARNING")
336+
s.Contains(res.Stderr.String(), "STOP ALL TRAFFIC")
337337

338338
// Duplicate fairness keys - should fail
339339
res = s.Execute(

0 commit comments

Comments
 (0)