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
ba6e96a6
authored
Apr 21, 2020
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grace period for deleting VMs
parent
a58577ec
Pipeline
#1083
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
circle/vm/tasks/local_periodic_tasks.py
+6
-2
No files found.
circle/vm/tasks/local_periodic_tasks.py
View file @
ba6e96a6
...
@@ -42,8 +42,11 @@ def garbage_collector(timeout=15):
...
@@ -42,8 +42,11 @@ def garbage_collector(timeout=15):
:type timeout: int
:type timeout: int
"""
"""
now
=
timezone
.
now
()
now
=
timezone
.
now
()
grace_period
=
timezone
.
timedelta
(
hours
=
1
)
work_package
=
20
for
i
in
Instance
.
objects
.
filter
(
destroyed_at
=
None
)
.
all
():
for
i
in
Instance
.
objects
.
filter
(
destroyed_at
=
None
)
.
all
():
if
i
.
time_of_delete
and
now
>
i
.
time_of_delete
:
if
i
.
time_of_delete
and
now
>
i
.
time_of_delete
+
grace_period
and
work_package
>
0
:
work_package
-=
1
i
.
destroy
.
async
(
system
=
True
)
i
.
destroy
.
async
(
system
=
True
)
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
try
:
try
:
...
@@ -57,7 +60,8 @@ def garbage_collector(timeout=15):
...
@@ -57,7 +60,8 @@ def garbage_collector(timeout=15):
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'
)
and
work_package
>
0
:
work_package
-=
1
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
try
:
try
:
i
.
sleep
.
async
(
system
=
True
)
i
.
sleep
.
async
(
system
=
True
)
...
...
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