Skip to content

Commit

Permalink
fix(hatchery): log level for hatchery book model (#6190)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
yesnault and jqueguiner authored Jun 9, 2022
1 parent 37fc0d4 commit a302813
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions engine/api/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ func ResetEventIntegration(ctx context.Context, db gorp.SqlExecutor, eventIntegr
kafkaCfg := getKafkaConfig(projInt.Config)
kafkaBroker, err := getBroker(ctx, "kafka", kafkaCfg)
if err != nil {
return sdk.WrapError(sdk.ErrBadBrokerConfiguration, "cannot get broker for %s and user %s : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
return sdk.WrapError(sdk.ErrBadBrokerConfiguration, "cannot get broker for %q and user %q : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
}
if err := brokersConnectionCache.Add(brokerConnectionKey, kafkaBroker, gocache.DefaultExpiration); err != nil {
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)
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)
}
return nil
}
Expand Down Expand Up @@ -213,11 +213,11 @@ func DequeueEvent(ctx context.Context, db *gorp.DbMap) {
kafkaCfg := getKafkaConfig(projInt.Config)
kafkaBroker, err := getBroker(ctx, "kafka", kafkaCfg)
if err != nil {
log.Error(ctx, "Event.DequeueEvent> cannot get broker for %s and user %s : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
log.Error(ctx, "Event.DequeueEvent> cannot get broker for %q and user %q : %v", projInt.Config["broker url"].Value, projInt.Config["username"].Value, err)
continue
}
if err := brokersConnectionCache.Add(brokerConnectionKey, kafkaBroker, gocache.DefaultExpiration); err != nil {
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)
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)
continue
}
brokerConnection = kafkaBroker
Expand Down
6 changes: 5 additions & 1 deletion sdk/hatchery/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ loopModels:

if err := h.CDSClient().WorkerModelBook(models[k].Group.Name, models[k].Name); err != nil {
ctx := log.ContextWithStackTrace(ctx, err)
log.Error(ctx, "cannot book model %s with id %d: %v", models[k].Path(), models[k].ID, err)
if sdk.ErrorIs(err, sdk.ErrWorkerModelAlreadyBooked) {
log.Info(ctx, "worker model already booked. model %s with id %d: %v", models[k].Path(), models[k].ID, err)
} else {
log.Error(ctx, "cannot book model %s with id %d: %v", models[k].Path(), models[k].ID, err)
}
continue
}

Expand Down

0 comments on commit a302813

Please sign in to comment.