diff --git a/internal/api/ws/codeocean_writer.go b/internal/api/ws/codeocean_writer.go index 5063b86..cbe70a6 100644 --- a/internal/api/ws/codeocean_writer.go +++ b/internal/api/ws/codeocean_writer.go @@ -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 } diff --git a/internal/runner/nomad_manager.go b/internal/runner/nomad_manager.go index b8c3c50..ffc3236 100644 --- a/internal/runner/nomad_manager.go +++ b/internal/runner/nomad_manager.go @@ -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") diff --git a/internal/runner/nomad_runner.go b/internal/runner/nomad_runner.go index 5573693..f2161cf 100644 --- a/internal/runner/nomad_runner.go +++ b/internal/runner/nomad_runner.go @@ -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 }