Commit 05c0421d authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

cannon, op-program: Avoid logging errors during normal shutdown. (#12051)

Previously op-program host and cannon both logged an error message that the pre-image server couldn't be stopped after it stopped successfully.
parent d348c69e
......@@ -248,7 +248,8 @@ func (p *ProcessPreimageOracle) Close() error {
func (p *ProcessPreimageOracle) wait() {
err := p.cmd.Wait()
var waitErr error
if err, ok := err.(*exec.ExitError); !ok || !err.Success() {
var exitErr *exec.ExitError
if errors.As(err, &exitErr) && !exitErr.Success() {
waitErr = err
}
p.cancelIO(fmt.Errorf("%w: pre-image server has exited", waitErr))
......
......@@ -217,6 +217,10 @@ func PreimageServer(ctx context.Context, logger log.Logger, cfg *config.Config,
return err
case <-ctx.Done():
logger.Info("Shutting down")
if errors.Is(ctx.Err(), context.Canceled) {
// We were asked to shutdown by the context being cancelled so don't treat it as an error condition.
return nil
}
return ctx.Err()
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment