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
939d3763
Commit
939d3763
authored
6 years ago
by
Martin Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
scheduler.py: Respect priority when scheduling jobs
#75
parent
a05de331
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/server/scheduler.py
+18
-6
18 additions, 6 deletions
buildgrid/server/scheduler.py
with
18 additions
and
6 deletions
buildgrid/server/scheduler.py
+
18
−
6
View file @
939d3763
...
...
@@ -43,7 +43,7 @@ class Scheduler:
self
.
_action_cache
=
action_cache
self
.
jobs
=
{}
self
.
queue
=
deque
()
self
.
__
queue
=
deque
()
self
.
_is_instrumented
=
monitor
...
...
@@ -76,6 +76,18 @@ class Scheduler:
self
.
__leases_by_state
[
LeaseState
.
COMPLETED
].
discard
(
job_name
)
def
queue_job
(
self
,
job
,
skip_cache_lookup
=
False
):
def
__queue_job
(
jobs_queue
,
new_job
):
index
=
0
for
queued_job
in
reversed
(
jobs_queue
):
if
new_job
.
priority
<
queued_job
.
priority
:
index
+=
1
else
:
break
index
=
len
(
jobs_queue
)
-
index
jobs_queue
.
insert
(
index
,
new_job
)
self
.
jobs
[
job
.
name
]
=
job
operation_stage
=
None
...
...
@@ -84,7 +96,7 @@ class Scheduler:
action_result
=
self
.
_action_cache
.
get_action_result
(
job
.
action_digest
)
except
NotFoundError
:
operation_stage
=
OperationStage
.
QUEUED
self
.
queue
.
append
(
job
)
__queue_job
(
self
.
__
queue
,
job
)
else
:
job
.
set_cached_result
(
action_result
)
...
...
@@ -95,7 +107,7 @@ class Scheduler:
else
:
operation_stage
=
OperationStage
.
QUEUED
self
.
queue
.
append
(
job
)
__queue_job
(
self
.
__
queue
,
job
)
self
.
_update_job_operation_stage
(
job
.
name
,
operation_stage
)
...
...
@@ -111,7 +123,7 @@ class Scheduler:
else
:
operation_stage
=
OperationStage
.
QUEUED
job
.
update_lease_state
(
LeaseState
.
PENDING
)
self
.
queue
.
append
(
job
)
self
.
__
queue
.
append
(
job
)
self
.
_update_job_operation_stage
(
job_name
,
operation_stage
)
...
...
@@ -126,10 +138,10 @@ class Scheduler:
worker properties, configuration and state at the time of the
request.
"""
if
not
self
.
queue
:
if
not
self
.
__
queue
:
return
[]
job
=
self
.
queue
.
popleft
()
job
=
self
.
__
queue
.
popleft
()
lease
=
job
.
lease
...
...
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