summaryrefslogtreecommitdiff
path: root/pkg/worker
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-06-03 14:54:06 +0300
committerValery Piashchynski <[email protected]>2021-06-03 14:54:06 +0300
commit62bbde7936109d18bf1f727974719804dad4c105 (patch)
tree54fb8493840837294bbe84ba5e1d7663ed027cad /pkg/worker
parent9c01e7ab1548e1416598b702d63866fa6dc5707b (diff)
- Do not write an error into the responseWriter if this is internal
error - Handle SoftJob error Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/worker')
-rwxr-xr-xpkg/worker/sync_worker.go14
-rwxr-xr-xpkg/worker/worker.go7
2 files changed, 11 insertions, 10 deletions
diff --git a/pkg/worker/sync_worker.go b/pkg/worker/sync_worker.go
index 7a1f3131..3d049ba7 100755
--- a/pkg/worker/sync_worker.go
+++ b/pkg/worker/sync_worker.go
@@ -44,11 +44,11 @@ func (tw *SyncWorkerImpl) Exec(p payload.Payload) (payload.Payload, error) {
rsp, err := tw.execPayload(p)
if err != nil {
// just to be more verbose
- if errors.Is(errors.SoftJob, err) == false { //nolint:gosimple
+ if !errors.Is(errors.SoftJob, err) {
tw.process.State().Set(StateErrored)
tw.process.State().RegisterExec()
}
- return payload.Payload{}, err
+ return payload.Payload{}, errors.E(op, err)
}
tw.process.State().Set(StateReady)
@@ -152,21 +152,21 @@ func (tw *SyncWorkerImpl) execPayload(p payload.Payload) (payload.Payload, error
err := tw.Relay().Send(fr)
if err != nil {
- return payload.Payload{}, err
+ return payload.Payload{}, errors.E(op, errors.Network, err)
}
frameR := frame.NewFrame()
err = tw.process.Relay().Receive(frameR)
if err != nil {
- return payload.Payload{}, errors.E(op, err)
+ return payload.Payload{}, errors.E(op, errors.Network, err)
}
if frameR == nil {
- return payload.Payload{}, errors.E(op, errors.Str("nil fr received"))
+ return payload.Payload{}, errors.E(op, errors.Network, errors.Str("nil fr received"))
}
if !frameR.VerifyCRC() {
- return payload.Payload{}, errors.E(op, errors.Str("failed to verify CRC"))
+ return payload.Payload{}, errors.E(op, errors.Network, errors.Str("failed to verify CRC"))
}
flags := frameR.ReadFlags()
@@ -177,7 +177,7 @@ func (tw *SyncWorkerImpl) execPayload(p payload.Payload) (payload.Payload, error
options := frameR.ReadOptions()
if len(options) != 1 {
- return payload.Payload{}, errors.E(op, errors.Str("options length should be equal 1 (body offset)"))
+ return payload.Payload{}, errors.E(op, errors.Decode, errors.Str("options length should be equal 1 (body offset)"))
}
pl := payload.Payload{}
diff --git a/pkg/worker/worker.go b/pkg/worker/worker.go
index 69c438b0..2044d0e7 100755
--- a/pkg/worker/worker.go
+++ b/pkg/worker/worker.go
@@ -181,12 +181,13 @@ func (w *Process) closeRelay() error {
// Stop sends soft termination command to the Process and waits for process completion.
func (w *Process) Stop() error {
- var err error
+ const op = errors.Op("process_stop")
w.state.Set(StateStopping)
- err = multierr.Append(err, internal.SendControl(w.relay, &internal.StopCommand{Stop: true}))
+ err := internal.SendControl(w.relay, &internal.StopCommand{Stop: true})
if err != nil {
w.state.Set(StateKilling)
- return multierr.Append(err, w.cmd.Process.Signal(os.Kill))
+ _ = w.cmd.Process.Signal(os.Kill)
+ return errors.E(op, errors.Network, err)
}
w.state.Set(StateStopped)
return nil