Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
11d0ec42
authored
7 years ago
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added time factor to the scheduling algorithm
parent
cec0fef7
Pipeline
#644
passed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
circle/circle/settings/base.py
+4
-0
circle/manager/scheduler.py
+28
-4
No files found.
circle/circle/settings/base.py
View file @
11d0ec42
...
@@ -592,3 +592,7 @@ TWO_FACTOR_ISSUER = get_env_variable("TWO_FACTOR_ISSUER", "CIRCLE")
...
@@ -592,3 +592,7 @@ TWO_FACTOR_ISSUER = get_env_variable("TWO_FACTOR_ISSUER", "CIRCLE")
AUTO_MIGRATION_CRONTAB
=
get_env_variable
(
"AUTO_MIGRATION_CRONTAB"
,
"0 0 * * *"
)
AUTO_MIGRATION_CRONTAB
=
get_env_variable
(
"AUTO_MIGRATION_CRONTAB"
,
"0 0 * * *"
)
AUTO_MIGRATION_TIME_LIMIT_IN_HOURS
=
(
AUTO_MIGRATION_TIME_LIMIT_IN_HOURS
=
(
get_env_variable
(
"AUTO_MIGRATION_TIME_LIMIT_IN_HOURS"
,
"2"
))
get_env_variable
(
"AUTO_MIGRATION_TIME_LIMIT_IN_HOURS"
,
"2"
))
# Maximum time difference until the monitor's values get valid
SCHEDULER_TIME_SENSITIVITY_IN_SECONDS
=
(
get_env_variable
(
"SCHEDULER_TIME_SENSITIVITY_IN_SECONDS"
,
"60"
))
This diff is collapsed.
Click to expand it.
circle/manager/scheduler.py
View file @
11d0ec42
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
from
logging
import
getLogger
from
logging
import
getLogger
from
django.utils.translation
import
ugettext_noop
from
django.utils.translation
import
ugettext_noop
from
django.utils
import
timezone
from
django.conf
import
settings
from
common.models
import
HumanReadableException
from
common.models
import
HumanReadableException
...
@@ -73,16 +75,38 @@ def select_node(instance, nodes):
...
@@ -73,16 +75,38 @@ def select_node(instance, nodes):
result
=
nodes
[
0
]
result
=
nodes
[
0
]
logger
.
info
(
'select_node:
%
s for
%
s'
,
unicode
(
result
),
unicode
(
instance
))
logger
.
info
(
'select_node:
%
s for
%
s'
,
unicode
(
result
),
unicode
(
instance
))
result
.
time_stamp
=
timezone
.
now
()
return
result
return
result
def
sorting_key
(
node
):
def
sorting_key
(
node
):
"""Determines how valuable a node is for scheduling.
"""Determines how valuable a node is for scheduling.
"""
"""
key
=
0
if
free_cpu_time
(
node
)
<
free_ram
(
node
):
if
free_cpu_time
(
node
)
<
free_ram
(
node
):
return
free_cpu_time
(
node
)
key
=
free_cpu_time
(
node
)
return
free_ram
(
node
)
else
:
key
=
free_ram
(
node
)
return
key
def
last_scheduled_correction_factor
(
node
):
"""Returns the time correction factor for a node.
The monitor data may be outdated, because of recent scheduling for a given node.
The return value is between 0 and 1, higher value indicates more time since the
last scheduling for the given node.
"""
factor
=
0
max_time_diff
=
settings
.
SCHEDULER_TIME_SENSITIVITY_IN_SECONDS
current_time
=
timezone
.
now
()
factor
=
(
current_time
-
node
.
time_stamp
)
/
max_time_diff
if
factor
>
1
:
factor
=
1
elif
factor
<
0
:
factor
=
0
return
factor
def
has_traits
(
traits
,
node
):
def
has_traits
(
traits
,
node
):
"""True, if the node has all specified traits; otherwise, false.
"""True, if the node has all specified traits; otherwise, false.
...
@@ -131,7 +155,7 @@ def free_cpu_time(node):
...
@@ -131,7 +155,7 @@ def free_cpu_time(node):
except
TypeError
as
e
:
except
TypeError
as
e
:
logger
.
warning
(
'Got incorrect monitoring data for node
%
s.
%
s'
,
logger
.
warning
(
'Got incorrect monitoring data for node
%
s.
%
s'
,
unicode
(
node
),
unicode
(
e
))
unicode
(
node
),
unicode
(
e
))
return
False
# monitoring data is incorrect
return
0
# will result lowest priority
def
free_ram
(
node
):
def
free_ram
(
node
):
...
@@ -147,4 +171,4 @@ def free_ram(node):
...
@@ -147,4 +171,4 @@ def free_ram(node):
except
TypeError
as
e
:
except
TypeError
as
e
:
logger
.
exception
(
'Got incorrect monitoring data for node
%
s.
%
s'
,
logger
.
exception
(
'Got incorrect monitoring data for node
%
s.
%
s'
,
unicode
(
node
),
unicode
(
e
))
unicode
(
node
),
unicode
(
e
))
return
0
return
0
# will result lowest priority
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