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
479d230f
authored
Feb 08, 2021
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Garbage collector fix
parent
616472ae
Pipeline
#1394
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
circle/vm/tasks/local_periodic_tasks.py
+8
-5
No files found.
circle/vm/tasks/local_periodic_tasks.py
View file @
479d230f
...
...
@@ -44,10 +44,13 @@ def garbage_collector(offset=timezone.timedelta(seconds=20)):
:type timeout: int
"""
now
=
timezone
.
now
()
grace_period
=
timezone
.
timedelta
(
hours
=
1
)
grace_period
=
timezone
.
timedelta
(
hours
=
0
)
work_package
=
20
logger
.
debug
(
"Garbage_collector START"
)
for
i
in
Instance
.
objects
.
filter
(
destroyed_at
=
None
)
.
all
():
logger
.
debug
(
"Garbage_collector work_package:
%
d
%
s:
%
s:"
,
work_package
,
i
.
pk
,
now
>
i
.
time_of_delete
)
if
i
.
time_of_delete
and
now
>
i
.
time_of_delete
+
grace_period
and
work_package
>
0
:
logger
.
debug
(
"Garbage_collector delete"
)
work_package
-=
1
i
.
destroy
.
async
(
system
=
True
)
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
...
...
@@ -61,9 +64,9 @@ def garbage_collector(offset=timezone.timedelta(seconds=20)):
except
Exception
as
e
:
logger
.
debug
(
'Could not notify owner of instance
%
d .
%
s'
,
i
.
pk
,
unicode
(
e
))
elif
(
i
.
time_of_suspend
and
now
>
i
.
time_of_suspend
and
i
.
state
==
'RUNNING'
)
and
work_package
>
0
:
elif
i
.
time_of_suspend
and
now
>
i
.
time_of_suspend
and
i
.
state
==
'RUNNING'
and
work_package
>
0
:
work_package
-=
1
logger
.
debug
(
"Garbage_collector suspend"
)
logger
.
info
(
"Expired instance
%
d suspended."
%
i
.
pk
)
try
:
i
.
sleep
.
async
(
system
=
True
)
...
...
@@ -83,8 +86,8 @@ def garbage_collector(offset=timezone.timedelta(seconds=20)):
logger
.
debug
(
"Instance
%
d expires soon."
%
i
.
pk
)
i
.
notify_owners_about_expiration
()
else
:
logger
.
debug
(
"Instance
%
d didn't expire.
bw:
%
d"
,
i
.
pk
,
bw
)
logger
.
debug
(
"Instance
%
d didn't expire.
work_package:
%
d"
,
i
.
pk
,
work_package
)
logger
.
debug
(
"Garbage_collector END work_package:
%
d"
,
work_package
)
@celery.task
(
ignore_result
=
True
)
def
auto_migrate
():
...
...
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