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
321a6bca
authored
Nov 22, 2018
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated logging for tests
parent
efdbf7ed
Pipeline
#681
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
circle/manager/scheduler.py
+26
-12
No files found.
circle/manager/scheduler.py
View file @
321a6bca
...
...
@@ -15,18 +15,18 @@
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
import
random
import
datetime
import
json
import
random
from
logging
import
getLogger
from
django.conf
import
settings
from
django.core.cache
import
cache
from
django.utils.translation
import
ugettext_noop
from
django.utils
import
timezone
from
django.
conf
import
settings
from
django.
utils.translation
import
ugettext_noop
from
common.models
import
HumanReadableException
from
logging
import
getLogger
from
circle.settings.base
import
SCHEDULER_METHOD
from
common.models
import
HumanReadableException
logger
=
getLogger
(
__name__
)
...
...
@@ -93,7 +93,9 @@ def common_random(instance, nodes):
def
advanced_with_time_stamp
(
instance
,
nodes
):
nodes
=
common_select
(
instance
,
nodes
)
nodes
.
sort
(
key
=
sorting_key
,
reverse
=
True
)
logger
.
info
(
'SCHEDLOG:
%
s'
,
nodes
)
logger
.
info
(
"SCHEDLOG: {}"
.
format
(
json
.
dumps
({
"event"
:
"after_sort"
,
"list"
:
map
(
lambda
node
:
unicode
(
node
),
nodes
)})))
result
=
nodes
[
0
]
return
result
...
...
@@ -110,8 +112,10 @@ def select_node(instance, nodes):
else
:
# Default method is the random
result
=
common_random
(
instance
,
nodes
)
logger
.
info
(
'SCHEDLOG: Scheduler method:
%
s selected'
,
unicode
(
SCHEDULER_METHOD
))
logger
.
info
(
'SCHEDLOG: select_node:
%
s for
%
s'
,
unicode
(
result
),
unicode
(
instance
))
logger
.
info
(
"SCHEDLOG: {}"
.
format
(
json
.
dumps
(
{
"event"
:
"select"
,
"node"
:
unicode
(
result
),
"vm"
:
unicode
(
instance
)})))
set_time_stamp
(
result
)
...
...
@@ -127,17 +131,26 @@ def sorting_key(node):
key
=
free_cpu_time
(
node
)
*
corr
else
:
key
=
free_ram
(
node
)
*
corr
logger
.
info
(
'SCHEDLOG: node:
%
s score:
%
s freecpu:
%
s freeram:
%
s'
,
unicode
(
node
),
unicode
(
key
),
unicode
(
free_cpu_time
(
node
)),
unicode
(
free_ram
(
node
)))
logger
.
info
(
"SCHEDLOG: {}"
.
format
(
json
.
dumps
({
"event"
:
"sort"
,
"node"
:
unicode
(
node
),
"sorting_key"
:
unicode
(
key
),
"free_cpu_time"
:
unicode
(
free_cpu_time
(
node
)),
"free_ram"
:
unicode
(
free_ram
(
node
)),
"last_scheduled_correction_factor"
:
unicode
(
last_scheduled_correction_factor
(
node
))})))
return
key
def
set_time_stamp
(
node
):
cache
.
set
(
'time_stamp{}'
.
format
(
node
.
id
),
timezone
.
now
())
def
get_time_stamp
(
node
):
time_stamp
=
cache
.
get
(
'time_stamp{}'
.
format
(
node
.
id
))
if
time_stamp
:
return
time_stamp
return
datetime
.
datetime
(
1970
,
1
,
1
,
tzinfo
=
timezone
.
get_current_timezone
())
return
datetime
.
datetime
(
1970
,
1
,
1
,
tzinfo
=
timezone
.
get_current_timezone
())
def
last_scheduled_correction_factor
(
node
):
"""Returns the time correction factor for a node.
...
...
@@ -149,7 +162,8 @@ def last_scheduled_correction_factor(node):
factor
=
0
max_time_diff
=
settings
.
SCHEDULER_TIME_SENSITIVITY_IN_SECONDS
current_time
=
timezone
.
now
()
time_difference_in_seconds
=
(
current_time
-
get_time_stamp
(
node
))
.
total_seconds
()
time_difference_in_seconds
=
(
current_time
-
get_time_stamp
(
node
))
.
total_seconds
()
factor
=
time_difference_in_seconds
/
float
(
max_time_diff
)
if
factor
>
1
:
factor
=
1
...
...
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