-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
propagating compiler errors #116
propagating compiler errors #116
Conversation
ControllerErr: PreRunError, | ||
RunOutput: nil, | ||
CommandErr: nil, | ||
ControllerErr: nil, | ||
RunOutput: preRunOut, | ||
CommandErr: commandErr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, the PreRunError was being thrown when compile commands would fail. This would make handling compilation errors different from handling runtime errors; I changed it so that both could be handled the same way.
engine/process/main.go
Outdated
cmd.Stderr.Write([]byte(err.Error())) | ||
|
||
// signal exit code: 128 + signal code | ||
os.Exit(128 + int(ws.Signal())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error codes are being captured from the process
command, and luckily the error from exec.Command
already has a nice explanation of what caused the exit, so I just write that to the command's stderr
in the case of a signal, such as a segfault
@@ -22,5 +22,5 @@ type RunResponse struct { | |||
// Stderr is standard error stream from running program | |||
Stderr string `json:"stderr"` | |||
// Error result from either compilation or runtime errors. Will be nil if both compilation and runtime were successful. | |||
Error error `json:"error"` | |||
Error string `json:"error"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One big thing I noticed is that the internal json.Marshal
wasn't properly marshalling the error type. If I did something like
fmt.Println("%v", err)
I would get the right error message, but once it was marshaled, it was returned as an object like
{
...
error: {Stderr: null}
}
My solution was simply to call the .Error()
method on the propagated errors, to turn them into strings before they're marshaled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to turn into string. Good catch, sorry I should've noticed that if I was writing this before.
web-frontend/js/run-request.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually looking really great! Not sure if I'll get time to review much before Wednesday, but just wanted to leave that initial feedback!
@camerondurham I tried to implement an effective solution without modifying too much. The main idea right now is to capture the process exit code as well as the process signal, if any. I put a bunch of comments all over to explain my thought process; it's not as standardized of an error system as it could be, but I think that it should be able to communicate what's going wrong effectively enough. Let me know what you think; I'm also fairly sure these changes break a couple of test cases so let me know if you'd like me to change those or anything. |
This looks awesome! Glad Command includes the failed output in std error response. I think the other failing integration test is just extremely flakey, but will need to take a look into that in a bit. I know you've manually verified this, so I can be okay with merging if that's still failing. But your change to include errors should not be causing anything new to fail. I can work on fixing the flaky test later anyways. |
@@ -22,5 +22,5 @@ type RunResponse struct { | |||
// Stderr is standard error stream from running program | |||
Stderr string `json:"stderr"` | |||
// Error result from either compilation or runtime errors. Will be nil if both compilation and runtime were successful. | |||
Error error `json:"error"` | |||
Error string `json:"error"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to turn into string. Good catch, sorry I should've noticed that if I was writing this before.
err = cmd.Run() | ||
|
||
if err != nil { | ||
print.ProcDebug("error running process: %v\n", err) | ||
os.Exit(ERunningProc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linter is complaining about this, not being used, can remove lined 38 as no longer being used? ERunningProc = 20 // error code when running command
engine/process/main.go
Outdated
if ws, ok := cast.Sys().(syscall.WaitStatus); ok { | ||
if ws.Signaled() { | ||
// more verbose err message | ||
cmd.Stderr.Write([]byte(err.Error())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns a value we may want to sanity check and debug log if it fails. It's unlikely to fail, but we can add visibility there just in case.
@camerondurham apologies for the delay on this. My most recent push should fix all the linter issues, I added some more debug statements, got rid of the unused error code, and am passing earthly lints locally. Let me know what else I can do 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, no worries I meant to look at the other test failures.
I finally pushed a commit to fix some outdated tests after changes to pre-run commits.
Honestly the pre-run commit since it'll always be nil
should probably be removed all together but I'll not block on that.
ControllerErr: PreRunError, | ||
RunOutput: nil, | ||
CommandErr: nil, | ||
ControllerErr: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is nil should probably just remove altogether.
WIP
Meant to address #115
process
now propagates exit code of the command it's runningStill working on: