Skip to content

Commit 579b672

Browse files
committed
lower job succeeded & triggered logs to debug; renamed triggered to added
1 parent 1275925 commit 579b672

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

robot/impl/jobmanager_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func TestJobManagerDurationAndCronFromJson(t *testing.T) {
6262
tb.Helper()
6363
// the jobs in the config are on 4-5s schedules so after 6-7 seconds, all of them
6464
// should run at least once
65-
test.That(tb, logs.FilterMessage("Job triggered").Len(),
65+
test.That(tb, logs.FilterMessage("Job added").Len(),
6666
test.ShouldBeGreaterThanOrEqualTo, 3)
6767
test.That(tb, logs.FilterMessage("Job succeeded").Len(),
6868
test.ShouldBeGreaterThanOrEqualTo, 3)
@@ -898,7 +898,7 @@ func TestJobManagerComponents(t *testing.T) {
898898
tb.Helper()
899899
// we will test for succeeded jobs to be the amount we started,
900900
// and that there are no failed jobs
901-
test.That(tb, logs.FilterMessage("Job triggered").Len(),
901+
test.That(tb, logs.FilterMessage("Job added").Len(),
902902
test.ShouldBeGreaterThanOrEqualTo, 18)
903903
test.That(tb, logs.FilterMessage("Job succeeded").Len(),
904904
test.ShouldBeGreaterThanOrEqualTo, 18)
@@ -1227,7 +1227,7 @@ func TestJobManagerServices(t *testing.T) {
12271227

12281228
testutils.WaitForAssertionWithSleep(t, time.Second, 5, func(tb testing.TB) {
12291229
tb.Helper()
1230-
test.That(tb, logs.FilterMessage("Job triggered").Len(),
1230+
test.That(tb, logs.FilterMessage("Job added").Len(),
12311231
test.ShouldBeGreaterThanOrEqualTo, 8)
12321232
test.That(tb, logs.FilterMessage("Job succeeded").Len(),
12331233
test.ShouldBeGreaterThanOrEqualTo, 8)
@@ -1262,7 +1262,7 @@ func TestJobManagerErrors(t *testing.T) {
12621262

12631263
testutils.WaitForAssertionWithSleep(t, time.Second, 5, func(tb testing.TB) {
12641264
tb.Helper()
1265-
test.That(tb, logs.FilterMessage("Job triggered").Len(),
1265+
test.That(tb, logs.FilterMessage("Job added").Len(),
12661266
test.ShouldBeGreaterThanOrEqualTo, 1)
12671267
test.That(tb, logs.FilterMessage("Job failed").Len(),
12681268
test.ShouldBeGreaterThanOrEqualTo, 1)

robot/jobmanager/jobmanager.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ func (jm *JobManager) createJobFunction(jc config.JobConfig) func(ctx context.Co
218218
return err
219219
}
220220
if jc.Method == "DoCommand" {
221-
jobLogger.CInfo(jm.ctx, "Job triggered")
221+
jobLogger.CDebugw(jm.ctx, "Job added", "name", jc.Name)
222222
response, err := res.DoCommand(jm.ctx, jc.Command)
223223
if err != nil {
224224
jobLogger.CWarnw(jm.ctx, "Job failed", "error", err.Error())
225225
return err
226226
}
227-
jobLogger.CInfow(jm.ctx, "Job succeeded", "response", response)
227+
jobLogger.CDebugw(jm.ctx, "Job succeeded", "name", jc.Name, "response", response)
228228
return nil
229229
}
230230

@@ -264,23 +264,25 @@ func (jm *JobManager) createJobFunction(jc config.JobConfig) func(ctx context.Co
264264
Formatter: formatter,
265265
VerbosityLevel: 0,
266266
}
267-
jobLogger.CInfo(jm.ctx, "Job triggered")
267+
// Job added for scheduling; may not immediately run.
268+
jobLogger.CDebugw(jm.ctx, "Job added", "name", jc.Name)
268269
grpcMethodCombined := grpcService + "." + grpcMethod
269270
err = grpcurl.InvokeRPC(jm.ctx, descSource, jm.conn, grpcMethodCombined, nil, h, rf.Next)
270271
if err != nil {
271-
jobLogger.CWarnw(jm.ctx, "Job failed", "error", err.Error())
272+
jobLogger.CWarnw(jm.ctx, "Job failed", "name", jc.Name, "error", err.Error())
272273
return err
273274
} else if h.Status != nil && h.Status.Err() != nil {
274-
jobLogger.CWarnw(jm.ctx, "Job failed", "error", h.Status.Err())
275+
jobLogger.CWarnw(jm.ctx, "Job failed", "name", jc.Name, "error", h.Status.Err())
275276
return h.Status.Err()
276277
}
277278
response := map[string]any{}
278279
err = json.Unmarshal(buffer.Bytes(), &response)
279280
if err != nil {
280-
jobLogger.CWarnw(jm.ctx, "Unmarshalling grpc response failed with error", "error", err.Error())
281+
jobLogger.CWarnw(jm.ctx, "Unmarshalling grpc response failed with error", "name", jc.Name,
282+
"error", err.Error())
281283
return err
282284
}
283-
jobLogger.CInfow(jm.ctx, "Job succeeded", "response", response)
285+
jobLogger.CDebugw(jm.ctx, "Job succeeded", "name", jc.Name, "response", response)
284286
return nil
285287
}
286288
}

0 commit comments

Comments
 (0)