Skip to content

Commit a302813

Browse files
yesnaultjqueguiner
andauthored
fix(hatchery): log level for hatchery book model (#6190)
* change log level for hatchery registration loop * fix(hatchery): log level for hatchery when looping over until finds the worker Signed-off-by: Yvonnick Esnault <[email protected]> Co-authored-by: Jean-Louis Queguiner <[email protected]>
1 parent 37fc0d4 commit a302813

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

engine/api/event/event.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ func ResetEventIntegration(ctx context.Context, db gorp.SqlExecutor, eventIntegr
9898
kafkaCfg := getKafkaConfig(projInt.Config)
9999
kafkaBroker, err := getBroker(ctx, "kafka", kafkaCfg)
100100
if err != nil {
101-
return sdk.WrapError(sdk.ErrBadBrokerConfiguration, "cannot get broker for %s and user %s : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
101+
return sdk.WrapError(sdk.ErrBadBrokerConfiguration, "cannot get broker for %q and user %q : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
102102
}
103103
if err := brokersConnectionCache.Add(brokerConnectionKey, kafkaBroker, gocache.DefaultExpiration); err != nil {
104-
return sdk.WrapError(sdk.ErrBadBrokerConfiguration, "cannot add broker in cache for %s and user %s : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
104+
return sdk.WrapError(sdk.ErrBadBrokerConfiguration, "cannot add broker in cache for %q and user %q : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
105105
}
106106
return nil
107107
}
@@ -213,11 +213,11 @@ func DequeueEvent(ctx context.Context, db *gorp.DbMap) {
213213
kafkaCfg := getKafkaConfig(projInt.Config)
214214
kafkaBroker, err := getBroker(ctx, "kafka", kafkaCfg)
215215
if err != nil {
216-
log.Error(ctx, "Event.DequeueEvent> cannot get broker for %s and user %s : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
216+
log.Error(ctx, "Event.DequeueEvent> cannot get broker for %q and user %q : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
217217
continue
218218
}
219219
if err := brokersConnectionCache.Add(brokerConnectionKey, kafkaBroker, gocache.DefaultExpiration); err != nil {
220-
log.Error(ctx, "Event.DequeueEvent> cannot add broker in cache for %s and user %s : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
220+
log.Error(ctx, "Event.DequeueEvent> cannot add broker in cache for %q and user %q : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
221221
continue
222222
}
223223
brokerConnection = kafkaBroker

sdk/hatchery/register.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ loopModels:
7474

7575
if err := h.CDSClient().WorkerModelBook(models[k].Group.Name, models[k].Name); err != nil {
7676
ctx := log.ContextWithStackTrace(ctx, err)
77-
log.Error(ctx, "cannot book model %s with id %d: %v", models[k].Path(), models[k].ID, err)
77+
if sdk.ErrorIs(err, sdk.ErrWorkerModelAlreadyBooked) {
78+
log.Info(ctx, "worker model already booked. model %s with id %d: %v", models[k].Path(), models[k].ID, err)
79+
} else {
80+
log.Error(ctx, "cannot book model %s with id %d: %v", models[k].Path(), models[k].ID, err)
81+
}
7882
continue
7983
}
8084

0 commit comments

Comments
 (0)