Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
9ad97b07
Commit
9ad97b07
authored
6 years ago
by
finnball
Browse files
Options
Downloads
Patches
Plain Diff
Added exception handling to bot_session.
Will also return the stderr and stdout to user.
parent
ef9fb33c
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/bot/bot_session.py
+34
-3
34 additions, 3 deletions
buildgrid/bot/bot_session.py
with
34 additions
and
3 deletions
buildgrid/bot/bot_session.py
+
34
−
3
View file @
9ad97b07
...
...
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Disable broad exception catch
# pylint: disable=broad-except
"""
Bot Session
...
...
@@ -23,10 +26,14 @@ import asyncio
import
logging
import
platform
import
uuid
from
enum
import
Enum
import
grpc
from
google.protobuf
import
any_pb2
from
buildgrid._protos.google.devtools.remoteworkers.v1test2
import
bots_pb2
,
worker_pb2
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
from
buildgrid._exceptions
import
BotError
class
BotStatus
(
Enum
):
...
...
@@ -142,13 +149,37 @@ class BotSession:
async
def
create_work
(
self
,
lease
):
self
.
logger
.
debug
(
"
Work created: [{}]
"
.
format
(
lease
.
id
))
input_lease
=
lease
loop
=
asyncio
.
get_event_loop
()
lease
=
await
loop
.
run_in_executor
(
None
,
self
.
_work
,
self
.
_context
,
lease
)
try
:
lease
=
await
loop
.
run_in_executor
(
None
,
self
.
_work
,
self
.
_context
,
lease
)
except
BotError
as
e
:
self
.
logger
.
error
(
"
Bot error thrown: [{}]
"
.
format
(
e
))
lease
=
self
.
_lease_error
(
input_lease
,
e
)
except
grpc
.
RpcError
as
e
:
self
.
logger
.
error
(
"
Connection error thrown: [{}]
"
.
format
(
e
))
lease
=
self
.
_lease_error
(
input_lease
,
e
)
except
Exception
as
e
:
self
.
logger
.
error
(
"
Connection error thrown: [{}]
"
.
format
(
e
))
lease
=
self
.
_lease_error
(
input_lease
,
e
)
self
.
logger
.
debug
(
"
Work complete: [{}]
"
.
format
(
lease
.
id
))
self
.
lease_completed
(
lease
)
def
_lease_error
(
self
,
lease
,
error
):
action_result
=
remote_execution_pb2
.
ActionResult
()
action_result
.
stderr_raw
=
str
(
error
)
action_result
.
exit_code
=
-
1
action_result_any
=
any_pb2
.
Any
()
action_result_any
.
Pack
(
action_result
)
lease
.
result
.
CopyFrom
(
action_result_any
)
return
lease
class
Worker
:
def
__init__
(
self
,
properties
=
None
,
configs
=
None
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment