Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
corteza
corteza-server
Commits
f66a9ce7
Commit
f66a9ce7
authored
5 years ago
by
Denis Arh
Browse files
Options
Download
Email Patches
Plain Diff
Better corredor error handling
parent
3db9368a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
compose/internal/service/automation_runner.go
compose/internal/service/automation_runner.go
+24
-9
No files found.
compose/internal/service/automation_runner.go
View file @
f66a9ce7
...
...
@@ -7,6 +7,8 @@ import (
"github.com/pkg/errors"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/cortezaproject/corteza-server/compose/proto"
"github.com/cortezaproject/corteza-server/compose/types"
...
...
@@ -226,11 +228,28 @@ func (svc automationRunner) makeRecordScriptRunner(ctx context.Context, ns *type
rsp
,
err
:=
svc
.
runner
.
Record
(
ctx
,
req
,
grpc
.
WaitForReady
(
script
.
Critical
))
svc
.
logger
.
Debug
(
"call sent"
)
if
err
!=
nil
{
// @todo aborted?
svc
.
logger
.
Debug
(
"script executed, did not return record"
,
zap
.
Error
(
err
))
s
,
ok
:=
status
.
FromError
(
err
)
if
!
ok
{
svc
.
logger
.
Error
(
"unexpected error type"
,
zap
.
Error
(
err
))
return
err
}
switch
s
.
Code
()
{
case
codes
.
FailedPrecondition
:
// Sent on syntax errors:
err
=
errors
.
New
(
s
.
Message
())
case
codes
.
Aborted
:
err
=
errors
.
New
(
s
.
Message
())
case
codes
.
InvalidArgument
:
err
=
errors
.
New
(
"invalid argument"
)
case
codes
.
Internal
:
err
=
errors
.
New
(
"internal corredor error"
)
default
:
}
svc
.
logger
.
Info
(
"script executed with errors"
,
zap
.
Error
(
err
))
if
!
script
.
Critical
{
// This was not a critical call and we do not care about
// errors from script running service.
...
...
@@ -245,19 +264,15 @@ func (svc automationRunner) makeRecordScriptRunner(ctx context.Context, ns *type
//
// Backend is still returning, so we do not
// need to handle multiple gRPC endpoints
svc
.
logger
.
Debug
(
"script executed / async"
)
return
nil
}
if
rsp
.
Record
==
nil
{
// Script did not return any results
// This means we should stop with the execution
// @todo aborted
return
nil
return
errors
.
New
(
"aborted"
)
}
svc
.
logger
.
Debug
(
"script executed"
,
zap
.
Any
(
"record"
,
rsp
.
Record
))
// Convert from proto and copy record owner & values from the result
result
:=
proto
.
ToRecord
(
rsp
.
Record
)
r
.
OwnedBy
,
r
.
Values
=
result
.
OwnedBy
,
result
.
Values
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment