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
3
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
83fb50b9
Commit
83fb50b9
authored
6 years ago
by
Martin Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
bots/instance.py: Improve debug logging
#160
parent
fbae1c15
No related branches found
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/server/bots/instance.py
+24
-9
24 additions, 9 deletions
buildgrid/server/bots/instance.py
with
24 additions
and
9 deletions
buildgrid/server/bots/instance.py
+
24
−
9
View file @
83fb50b9
...
...
@@ -32,6 +32,8 @@ class BotsInterface:
def
__init__
(
self
,
scheduler
):
self
.
__logger
=
logging
.
getLogger
(
__name__
)
# Turn on debug mode based on log verbosity level:
self
.
__debug
=
self
.
__logger
.
getEffectiveLevel
()
<=
logging
.
DEBUG
self
.
_scheduler
=
scheduler
self
.
_instance_name
=
None
...
...
@@ -65,13 +67,11 @@ class BotsInterface:
register with the service, the old one should be closed along
with all its jobs.
"""
bot_id
=
bot_session
.
bot_id
if
bot_id
==
""
:
raise
InvalidArgumentError
(
"
bot_id needs to be set by client
"
)
if
not
bot_session
.
bot_id
:
raise
InvalidArgumentError
(
"
Bot
'
s id must be set by client.
"
)
try
:
self
.
_check_bot_ids
(
bot_id
)
self
.
_check_bot_ids
(
bot_
session
.
bot_
id
)
except
InvalidArgumentError
:
pass
...
...
@@ -79,21 +79,27 @@ class BotsInterface:
name
=
"
{}/{}
"
.
format
(
parent
,
str
(
uuid
.
uuid4
()))
bot_session
.
name
=
name
self
.
_bot_ids
[
name
]
=
bot_id
self
.
__logger
.
info
(
"
Created bot session name=[%s] with bot_id=[%s]
"
,
name
,
bot_id
)
self
.
_bot_ids
[
name
]
=
bot_session
.
bot_id
# We want to keep a copy of lease ids we have assigned
self
.
_assigned_leases
[
name
]
=
set
()
self
.
_request_leases
(
bot_session
)
if
self
.
__debug
:
self
.
__logger
.
info
(
"
Opened session name=[%s] for bot=[%s], leases=[%s]
"
,
bot_session
.
name
,
bot_session
.
bot_id
,
"
,
"
.
join
([
lease
.
id
[:
8
]
for
lease
in
bot_session
.
leases
]))
else
:
self
.
__logger
.
info
(
"
Opened session, name=[%s] for bot=[%s]
"
,
bot_session
.
name
,
bot_session
.
bot_id
)
return
bot_session
def
update_bot_session
(
self
,
name
,
bot_session
):
"""
Client updates the server. Any changes in state to the Lease should be
registered server side. Assigns available leases with work.
"""
self
.
__logger
.
debug
(
"
Updating bot session name=[%s]
"
,
name
)
self
.
_check_bot_ids
(
bot_session
.
bot_id
,
name
)
self
.
_check_assigned_leases
(
bot_session
)
...
...
@@ -111,6 +117,15 @@ class BotsInterface:
bot_session
.
leases
.
remove
(
lease
)
self
.
_request_leases
(
bot_session
)
if
self
.
__debug
:
self
.
__logger
.
info
(
"
Sending session update, name=[%s], for bot=[%s], leases=[%s]
"
,
bot_session
.
name
,
bot_session
.
bot_id
,
"
,
"
.
join
([
lease
.
id
[:
8
]
for
lease
in
bot_session
.
leases
]))
else
:
self
.
__logger
.
info
(
"
Sending session update, name=[%s], for bot=[%s]
"
,
bot_session
.
name
,
bot_session
.
bot_id
)
return
bot_session
# --- Private API ---
...
...
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