Add missing error log statements.

When "markRunnerAsUsed" fails, we silently ignored it. Only, when additionally the return of the runner failed, we threw the error.

When a Runner is destroyed, we are only notified that Nomad removed the allocation, but cannot tell about the reason.

For "the execution did not stop after SIGQUIT" we did not log the belonging runner id.
This commit is contained in:
Maximilian Paß
2023-08-21 11:36:19 +02:00
parent 13cd19ed58
commit a7d27e8f65
3 changed files with 7 additions and 2 deletions

View File

@ -144,7 +144,7 @@ func (cw *codeOceanOutputWriter) startWritingLoop(writingLoopDone context.Cancel
done = sendMessage(cw.connection, message.data, cw.ctx)
}
if done || message.done {
log.Debug("Writing loop done")
log.WithContext(cw.ctx).Trace("Writing loop done")
writingLoopDone()
return
}

View File

@ -62,6 +62,7 @@ func (m *NomadRunnerManager) markRunnerAsUsed(runner Runner, timeoutDuration int
return
})
if err != nil {
log.WithError(err).WithField(dto.KeyRunnerID, runner.ID()).Error("cannot mark runner as used")
err := m.Return(runner)
if err != nil {
log.WithError(err).WithField(dto.KeyRunnerID, runner.ID()).Error("can't mark runner as used and can't return runner")

View File

@ -64,7 +64,8 @@ type NomadJob struct {
func NewNomadJob(id string, portMappings []nomadApi.PortMapping,
apiClient nomad.ExecutorAPI, onDestroy DestroyRunnerHandler,
) *NomadJob {
ctx, cancel := context.WithCancel(context.Background())
ctx := context.WithValue(context.Background(), dto.ContextKey(dto.KeyRunnerID), id)
ctx, cancel := context.WithCancel(ctx)
job := &NomadJob{
id: id,
portMappings: portMappings,
@ -237,6 +238,7 @@ func (r *NomadJob) GetFileContent(
func (r *NomadJob) Destroy(reason DestroyReason) (err error) {
r.ctx = context.WithValue(r.ctx, destroyReasonContextKey, reason)
log.WithContext(r.ctx).Debug("Destroying Runner")
r.cancel()
r.StopTimeout()
if r.onDestroy != nil {
@ -254,6 +256,8 @@ func (r *NomadJob) Destroy(reason DestroyReason) (err error) {
if err != nil {
err = fmt.Errorf("cannot destroy runner: %w", err)
} else {
log.WithContext(r.ctx).Trace("Runner destroyed")
}
return err
}