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
0bd5e524
authored
Feb 26, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: fix coding style
parent
18b4e814
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
circle/storage/tasks/periodic_tasks.py
+11
-9
No files found.
circle/storage/tasks/periodic_tasks.py
View file @
0bd5e524
...
...
@@ -12,6 +12,7 @@ logger = logging.getLogger(__name__)
@celery.task
def
garbage_collector
(
timeout
=
15
):
""" Garbage collector for disk images.
Moves 1 day old deleted images to trash folder.
If there is not enough free space on datastore (default 10
%
)
deletes oldest images from trash.
...
...
@@ -40,6 +41,7 @@ def garbage_collector(timeout=15):
@celery.task
def
list_orphan_disks
(
timeout
=
15
):
"""List disk image files without Disk object in the database.
Exclude cloud-xxxxxxxx.dump format images.
:param timeout: Seconds before TimeOut exception
...
...
@@ -48,10 +50,10 @@ def list_orphan_disks(timeout=15):
import
re
for
ds
in
DataStore
.
objects
.
all
():
queue_name
=
ds
.
get_remote_queue_name
(
'storage'
)
file
_list
=
remote_tasks
.
list_files
.
apply_async
(
args
=
[
ds
.
path
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
disk
_list
=
[
disk
.
filename
for
disk
in
ds
.
disk_set
.
all
()]
for
i
in
set
(
file_list
)
.
difference
(
disk_list
)
:
file
s
=
set
(
remote_tasks
.
list_files
.
apply_async
(
args
=
[
ds
.
path
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
)
disk
s
=
set
([
disk
.
filename
for
disk
in
ds
.
disk_set
.
all
()])
for
i
in
files
-
disks
:
if
not
re
.
match
(
'cloud-[0-9]*
\
.dump'
,
i
):
logging
.
warning
(
"Orphan disk:
%
s"
%
i
)
...
...
@@ -65,10 +67,10 @@ def list_missing_disks(timeout=15):
"""
for
ds
in
DataStore
.
objects
.
all
():
queue_name
=
ds
.
get_remote_queue_name
(
'storage'
)
file
_list
=
remote_tasks
.
list_files
.
apply_async
(
args
=
[
ds
.
path
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
disk
_list
=
[
disk
.
filename
for
disk
in
ds
.
disk_set
.
filter
(
destroyed__isnull
=
True
)]
for
i
in
set
(
disk_list
)
.
difference
(
file_list
)
:
file
s
=
set
(
remote_tasks
.
list_files
.
apply_async
(
args
=
[
ds
.
path
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
)
disk
s
=
set
(
[
disk
.
filename
for
disk
in
ds
.
disk_set
.
filter
(
destroyed__isnull
=
True
)]
)
for
i
in
disks
-
files
:
logging
.
critical
(
"Image:
%
s is missing from
%
s datastore."
%
(
i
,
ds
.
path
))
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