Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lu Xu
slapos.core
Commits
8b34994e
Commit
8b34994e
authored
Aug 09, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't stop reporting/Destroying, even if something bad happens to an instance.
Do it as well for the reporting loop.
parent
b03b0192
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
38 deletions
+47
-38
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+47
-38
No files found.
slapos/grid/slapgrid.py
View file @
8b34994e
...
@@ -876,46 +876,55 @@ class Slapgrid(object):
...
@@ -876,46 +876,55 @@ class Slapgrid(object):
#Now we loop through the different computer partitions to report
#Now we loop through the different computer partitions to report
report_usage_issue_cp_list
=
[]
report_usage_issue_cp_list
=
[]
for
computer_partition
in
computer_partition_list
:
for
computer_partition
in
computer_partition_list
:
filename_delete_list
=
[]
try
:
computer_partition_id
=
computer_partition
.
getId
()
filename_delete_list
=
[]
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition_id
)
computer_partition_id
=
computer_partition
.
getId
()
dir_reports
=
os
.
path
.
join
(
instance_path
,
'var'
,
'xml_report'
)
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
computer_partition_id
)
#The directory xml_report contain a number of files equal
dir_reports
=
os
.
path
.
join
(
instance_path
,
'var'
,
'xml_report'
)
#to the number of software instance running inside the same partition
#The directory xml_report contain a number of files equal
if
os
.
path
.
isdir
(
dir_reports
):
#to the number of software instance running inside the same partition
filename_list
=
os
.
listdir
(
dir_reports
)
if
os
.
path
.
isdir
(
dir_reports
):
else
:
filename_list
=
os
.
listdir
(
dir_reports
)
filename_list
=
[]
#logger.debug('name List %s' % filename_list)
usage
=
''
for
filename
in
filename_list
:
file_path
=
os
.
path
.
join
(
dir_reports
,
filename
)
if
os
.
path
.
exists
(
file_path
):
usage_file
=
open
(
file_path
,
'r'
)
usage
=
usage_file
.
read
()
usage_file
.
close
()
#We check the validity of xml content of each reports
if
not
self
.
validateXML
(
usage
,
partition_consumption_model
):
logger
.
info
(
'WARNING: The XML file %s generated by slapreport is '
'not valid - This report is left as is at %s where you can '
'inspect what went wrong '
%
(
filename
,
dir_reports
))
# Warn the SlapOS Master that a partition generates corrupted xml
# report
else
:
computer_partition_usage
=
self
.
slap
.
registerComputerPartition
(
self
.
computer_id
,
computer_partition_id
)
computer_partition_usage
.
setUsage
(
usage
)
computer_partition_usage_list
.
append
(
computer_partition_usage
)
filename_delete_list
.
append
(
filename
)
else
:
else
:
logger
.
debug
(
"Usage report %r not found, ignored"
%
file_path
)
filename_list
=
[]
#logger.debug('name List %s' % filename_list)
usage
=
''
for
filename
in
filename_list
:
file_path
=
os
.
path
.
join
(
dir_reports
,
filename
)
if
os
.
path
.
exists
(
file_path
):
usage_file
=
open
(
file_path
,
'r'
)
usage
=
usage_file
.
read
()
usage_file
.
close
()
#We check the validity of xml content of each reports
if
not
self
.
validateXML
(
usage
,
partition_consumption_model
):
logger
.
info
(
'WARNING: The XML file %s generated by slapreport is '
'not valid - This report is left as is at %s where you can '
'inspect what went wrong '
%
(
filename
,
dir_reports
))
# Warn the SlapOS Master that a partition generates corrupted xml
# report
else
:
computer_partition_usage
=
self
.
slap
.
registerComputerPartition
(
self
.
computer_id
,
computer_partition_id
)
computer_partition_usage
.
setUsage
(
usage
)
computer_partition_usage_list
.
append
(
computer_partition_usage
)
filename_delete_list
.
append
(
filename
)
else
:
logger
.
debug
(
"Usage report %r not found, ignored"
%
file_path
)
#After sending the aggregated file we remove all the valid xml reports
#After sending the aggregated file we remove all the valid xml reports
for
filename
in
filename_delete_list
:
for
filename
in
filename_delete_list
:
os
.
remove
(
os
.
path
.
join
(
dir_reports
,
filename
))
os
.
remove
(
os
.
path
.
join
(
dir_reports
,
filename
))
# Whatever happens, don't stop processing other instances
except
Exception
:
computer_partition_id
=
computer_partition
.
getId
()
exception
=
traceback
.
format_exc
()
issue
=
"Cannot run usage script(s) for %r: %s"
%
(
computer_partition_id
,
exception
)
logger
.
info
(
issue
)
for
computer_partition_usage
in
computer_partition_usage_list
:
for
computer_partition_usage
in
computer_partition_usage_list
:
logger
.
info
(
'computer_partition_usage_list : %s - %s'
%
\
logger
.
info
(
'computer_partition_usage_list : %s - %s'
%
\
...
...
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