Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8aaa4d14
authored
Jun 04, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
node: set tasks to user fast queues
parent
0e85c19a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
circle/vm/models/node.py
+16
-8
No files found.
circle/vm/models/node.py
View file @
8aaa4d14
...
...
@@ -76,7 +76,7 @@ class Node(OperatedMixin, TimeStampedModel):
Check if node is online by queue is available.
"""
try
:
self
.
get_remote_queue_name
(
"vm"
)
self
.
get_remote_queue_name
(
"vm"
,
"fast"
)
except
:
return
False
else
:
...
...
@@ -88,6 +88,7 @@ class Node(OperatedMixin, TimeStampedModel):
@method_cache
(
300
)
def
get_info
(
self
):
return
self
.
remote_query
(
vm_tasks
.
get_info
,
priority
=
'fast'
,
default
=
{
'core_num'
:
''
,
'ram_size'
:
'0'
,
'architecture'
:
''
})
...
...
@@ -146,16 +147,19 @@ class Node(OperatedMixin, TimeStampedModel):
return
self
.
ram_size
*
self
.
overcommit
@method_cache
(
30
)
def
get_remote_queue_name
(
self
,
queue_id
):
def
get_remote_queue_name
(
self
,
queue_id
,
priority
=
None
):
"""Returns the name of the remote celery queue for this node.
Throws Exception if there is no worker on the queue.
The result may include dead queues because of caching.
"""
if
vm_tasks
.
check_queue
(
self
.
host
.
hostname
,
queue_id
):
if
vm_tasks
.
check_queue
(
self
.
host
.
hostname
,
queue_id
,
priority
):
queue_name
=
self
.
host
.
hostname
+
"."
+
queue_id
if
priority
is
not
None
:
queue_name
=
queue_name
+
"."
+
priority
self
.
node_online
()
return
self
.
host
.
hostname
+
"."
+
queue_id
return
queue_name
else
:
if
self
.
enabled
:
self
.
node_offline
()
...
...
@@ -205,7 +209,8 @@ class Node(OperatedMixin, TimeStampedModel):
", but enabled"
if
self
.
enabled
else
""
)
# TODO: check if we should reschedule any VMs?
def
remote_query
(
self
,
task
,
timeout
=
30
,
raise_
=
False
,
default
=
None
):
def
remote_query
(
self
,
task
,
timeout
=
30
,
priority
=
None
,
raise_
=
False
,
default
=
None
):
"""Query the given task, and get the result.
If the result is not ready or worker not reachable
...
...
@@ -214,7 +219,8 @@ class Node(OperatedMixin, TimeStampedModel):
"""
try
:
r
=
task
.
apply_async
(
queue
=
self
.
get_remote_queue_name
(
'vm'
),
expires
=
timeout
+
60
)
queue
=
self
.
get_remote_queue_name
(
'vm'
,
priority
),
expires
=
timeout
+
60
)
return
r
.
get
(
timeout
=
timeout
)
except
(
TimeoutError
,
WorkerNotFound
):
if
raise_
:
...
...
@@ -227,7 +233,8 @@ class Node(OperatedMixin, TimeStampedModel):
try
:
handler
=
GraphiteHandler
()
except
RuntimeError
:
return
self
.
remote_query
(
vm_tasks
.
get_node_metrics
,
30
)
return
self
.
remote_query
(
vm_tasks
.
get_node_metrics
,
timeout
=
30
,
priority
=
"fast"
)
query
=
Query
()
query
.
set_target
(
self
.
host
.
hostname
+
".circle"
)
...
...
@@ -276,7 +283,8 @@ class Node(OperatedMixin, TimeStampedModel):
vm_state_changed hook.
"""
domains
=
{}
domain_list
=
self
.
remote_query
(
vm_tasks
.
list_domains_info
,
timeout
=
5
)
domain_list
=
self
.
remote_query
(
vm_tasks
.
list_domains_info
,
timeout
=
5
,
priority
=
"fast"
)
if
domain_list
is
None
:
logger
.
info
(
"Monitoring failed at:
%
s"
,
self
.
name
)
return
...
...
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