Add error for empty list file system execution.
Normally, the result of executing the `lsCommand` should never be empty. However, we have observed that CodeOcean sometimes receives an empty JSON result if the runner is being deleted while the list file system request is processed. Therefore, we add a check if something has been written to CodeOcean and otherwise report an error.
This commit is contained in:
@ -163,13 +163,20 @@ func (r *NomadJob) ListFileSystem(
|
|||||||
exitCode, err := r.api.ExecuteCommand(r.id, ctx, retrieveCommand, false, privilegedExecution,
|
exitCode, err := r.api.ExecuteCommand(r.id, ctx, retrieveCommand, false, privilegedExecution,
|
||||||
&nullio.Reader{Ctx: ctx}, ls2json, io.Discard)
|
&nullio.Reader{Ctx: ctx}, ls2json, io.Discard)
|
||||||
switch {
|
switch {
|
||||||
|
case ls2json.HasStartedWriting() && err == nil && exitCode == 0:
|
||||||
|
// Successful. Nothing to do.
|
||||||
case ls2json.HasStartedWriting():
|
case ls2json.HasStartedWriting():
|
||||||
|
// if HasStartedWriting the status code of the response is already sent.
|
||||||
|
// Therefore, we cannot notify CodeOcean about an error at this point anymore.
|
||||||
|
log.WithError(err).WithField("exitCode", exitCode).Warn("Ignoring error of listing the file system")
|
||||||
err = nil
|
err = nil
|
||||||
case err != nil:
|
case err != nil:
|
||||||
err = fmt.Errorf("%w: nomad error during retrieve file headers: %v",
|
err = fmt.Errorf("%w: nomad error during retrieve file headers: %v",
|
||||||
nomad.ErrorExecutorCommunicationFailed, err)
|
nomad.ErrorExecutorCommunicationFailed, err)
|
||||||
case exitCode != 0:
|
case exitCode != 0:
|
||||||
err = ErrFileNotFound
|
err = ErrFileNotFound
|
||||||
|
case !ls2json.HasStartedWriting():
|
||||||
|
err = fmt.Errorf("list file system failed silently: %w", nomad.ErrorExecutorCommunicationFailed)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user