Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e8684154
authored
6 years ago
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'configurable_scheduler' into 'master'
Configurable scheduler method See merge request !401
parents
14750235
2c2a1c71
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
circle/circle/settings/base.py
+2
-0
circle/manager/scheduler.py
+29
-3
No files found.
circle/circle/settings/base.py
View file @
e8684154
...
...
@@ -576,6 +576,8 @@ SESSION_COOKIE_NAME = "csessid%x" % (((getnode() // 139) ^
MAX_NODE_RAM
=
get_env_variable
(
"MAX_NODE_RAM"
,
1024
)
MAX_NODE_CPU_CORE
=
get_env_variable
(
"MAX_NODE_CPU_CORE"
,
10
)
SCHEDULER_METHOD
=
get_env_variable
(
"SCHEDULER_METHOD"
,
'random'
)
# Url to download the client: (e.g. http://circlecloud.org/client/download/)
CLIENT_DOWNLOAD_URL
=
get_env_variable
(
'CLIENT_DOWNLOAD_URL'
,
'http://circlecloud.org/client/download/'
)
...
...
This diff is collapsed.
Click to expand it.
circle/manager/scheduler.py
View file @
e8684154
...
...
@@ -21,6 +21,10 @@ from django.utils.translation import ugettext_noop
from
common.models
import
HumanReadableException
from
circle.settings.base
import
SCHEDULER_METHOD
import
random
logger
=
getLogger
(
__name__
)
...
...
@@ -50,9 +54,7 @@ class TraitsUnsatisfiableException(SchedulerError):
"new virtual machine currently."
)
def
select_node
(
instance
,
nodes
):
''' Select a node for hosting an instance based on its requirements.
'''
def
common_select
(
instance
,
nodes
):
# check required traits
nodes
=
[
n
for
n
in
nodes
if
n
.
schedule_enabled
and
n
.
online
and
...
...
@@ -70,8 +72,32 @@ def select_node(instance, nodes):
# sort nodes first by processor usage, then priority
nodes
.
sort
(
key
=
lambda
n
:
n
.
priority
,
reverse
=
True
)
nodes
.
sort
(
key
=
free_cpu_time
,
reverse
=
True
)
return
nodes
def
common_evenly
(
instance
,
nodes
):
nodes
=
common_select
(
instance
,
nodes
)
result
=
nodes
[
0
]
return
result
def
common_random
(
instance
,
nodes
):
nodes
=
common_select
(
instance
,
nodes
)
result
=
random
.
choice
(
nodes
)
return
result
def
select_node
(
instance
,
nodes
):
''' Select a node for hosting an instance based on its requirements.
'''
if
SCHEDULER_METHOD
==
'evenly'
:
result
=
common_evenly
(
instance
,
nodes
)
elif
SCHEDULER_METHOD
==
'random'
:
result
=
common_random
(
instance
,
nodes
)
else
:
# Default method is the random
result
=
common_random
(
instance
,
nodes
)
logger
.
info
(
'Scheduler method:
%
s selected'
,
unicode
(
SCHEDULER_METHOD
))
logger
.
info
(
'select_node:
%
s for
%
s'
,
unicode
(
result
),
unicode
(
instance
))
return
result
...
...
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