Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
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
a6e93b0b
authored
Mar 13, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix garbage collector
parent
c369ff1e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
circle/vm/models/instance.py
+8
-6
circle/vm/tasks/local_periodic_tasks.py
+2
-2
No files found.
circle/vm/models/instance.py
View file @
a6e93b0b
...
@@ -616,21 +616,23 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -616,21 +616,23 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
interval what the Lease allows. This rate is configurable with the
interval what the Lease allows. This rate is configurable with the
only parameter, threshold (0.1 = 10
%
by default).
only parameter, threshold (0.1 = 10
%
by default).
"""
"""
return
(
self
.
_is_suspend_expiring
(
self
,
threshold
)
or
return
(
self
.
_is_suspend_expiring
(
threshold
)
or
self
.
_is_delete_expiring
(
self
,
threshold
))
self
.
_is_delete_expiring
(
threshold
))
def
_is_suspend_expiring
(
self
,
threshold
=
0.1
):
def
_is_suspend_expiring
(
self
,
threshold
=
0.1
):
interval
=
self
.
lease
.
suspend_interval
interval
=
self
.
lease
.
suspend_interval
if
interval
is
not
None
:
if
self
.
time_of_suspend
is
not
None
and
interval
is
not
None
:
limit
=
timezone
.
now
()
+
threshold
*
self
.
lease
.
suspend_interval
limit
=
timezone
.
now
()
+
timedelta
(
seconds
=
(
threshold
*
self
.
lease
.
suspend_interval
.
total_seconds
()))
return
limit
>
self
.
time_of_suspend
return
limit
>
self
.
time_of_suspend
else
:
else
:
return
False
return
False
def
_is_delete_expiring
(
self
,
threshold
=
0.1
):
def
_is_delete_expiring
(
self
,
threshold
=
0.1
):
interval
=
self
.
lease
.
delete_interval
interval
=
self
.
lease
.
delete_interval
if
interval
is
not
None
:
if
self
.
time_of_delete
is
not
None
and
interval
is
not
None
:
limit
=
timezone
.
now
()
+
threshold
*
self
.
lease
.
delete_interval
limit
=
timezone
.
now
()
+
timedelta
(
seconds
=
(
threshold
*
self
.
lease
.
delete_interval
.
total_seconds
()))
return
limit
>
self
.
time_of_delete
return
limit
>
self
.
time_of_delete
else
:
else
:
return
False
return
False
...
...
circle/vm/tasks/local_periodic_tasks.py
View file @
a6e93b0b
...
@@ -26,7 +26,7 @@ def garbage_collector(timeout=15):
...
@@ -26,7 +26,7 @@ def garbage_collector(timeout=15):
"""
"""
now
=
timezone
.
now
()
now
=
timezone
.
now
()
for
i
in
Instance
.
objects
.
filter
(
destroyed
=
None
)
.
all
():
for
i
in
Instance
.
objects
.
filter
(
destroyed
=
None
)
.
all
():
if
i
.
time_of_delete
and
now
<
i
.
time_of_delete
:
if
i
.
time_of_delete
and
now
>
i
.
time_of_delete
:
i
.
destroy_async
()
i
.
destroy_async
()
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
try
:
try
:
...
@@ -37,7 +37,7 @@ def garbage_collector(timeout=15):
...
@@ -37,7 +37,7 @@ def garbage_collector(timeout=15):
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
debug
(
'Could not notify owner of instance
%
d .
%
s'
,
logger
.
debug
(
'Could not notify owner of instance
%
d .
%
s'
,
i
.
pk
,
unicode
(
e
))
i
.
pk
,
unicode
(
e
))
elif
(
i
.
time_of_suspend
and
now
<
i
.
time_of_suspend
and
elif
(
i
.
time_of_suspend
and
now
>
i
.
time_of_suspend
and
i
.
state
==
'RUNNING'
):
i
.
state
==
'RUNNING'
):
i
.
sleep_async
()
i
.
sleep_async
()
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
...
...
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