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
Léo-Paul Géneau
slapos.core
Commits
b03b0192
Commit
b03b0192
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.
parent
e46f3e6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
56 deletions
+63
-56
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+63
-56
No files found.
slapos/grid/slapgrid.py
View file @
b03b0192
...
@@ -809,62 +809,69 @@ class Slapgrid(object):
...
@@ -809,62 +809,69 @@ class Slapgrid(object):
#We loop on the different computer partitions
#We loop on the different computer partitions
computer_partition_list
=
slap_computer_usage
.
getComputerPartitionList
()
computer_partition_list
=
slap_computer_usage
.
getComputerPartitionList
()
for
computer_partition
in
computer_partition_list
:
for
computer_partition
in
computer_partition_list
:
computer_partition_id
=
computer_partition
.
getId
()
try
:
computer_partition_id
=
computer_partition
.
getId
()
#We want execute all the script in the report folder
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
#We want execute all the script in the report folder
computer_partition
.
getId
())
instance_path
=
os
.
path
.
join
(
self
.
instance_root
,
report_path
=
os
.
path
.
join
(
instance_path
,
'etc'
,
'report'
)
computer_partition
.
getId
())
if
os
.
path
.
isdir
(
report_path
):
report_path
=
os
.
path
.
join
(
instance_path
,
'etc'
,
'report'
)
script_list_to_run
=
os
.
listdir
(
report_path
)
if
os
.
path
.
isdir
(
report_path
):
else
:
script_list_to_run
=
os
.
listdir
(
report_path
)
script_list_to_run
=
[]
else
:
script_list_to_run
=
[]
#We now generate the pseudorandom name for the xml file
# and we add it in the invocation_list
#We now generate the pseudorandom name for the xml file
f
=
tempfile
.
NamedTemporaryFile
()
# and we add it in the invocation_list
name_xml
=
'%s.%s'
%
(
'slapreport'
,
os
.
path
.
basename
(
f
.
name
))
f
=
tempfile
.
NamedTemporaryFile
()
path_to_slapreport
=
os
.
path
.
join
(
instance_path
,
'var'
,
'xml_report'
,
name_xml
=
'%s.%s'
%
(
'slapreport'
,
os
.
path
.
basename
(
f
.
name
))
name_xml
)
path_to_slapreport
=
os
.
path
.
join
(
instance_path
,
'var'
,
'xml_report'
,
name_xml
)
failed_script_list
=
[]
for
script
in
script_list_to_run
:
failed_script_list
=
[]
for
script
in
script_list_to_run
:
invocation_list
=
[]
invocation_list
=
[]
invocation_list
.
append
(
os
.
path
.
join
(
instance_path
,
'etc'
,
'report'
,
invocation_list
.
append
(
os
.
path
.
join
(
instance_path
,
'etc'
,
'report'
,
script
))
script
))
#We add the xml_file name in the invocation_list
#We add the xml_file name in the invocation_list
#f = tempfile.NamedTemporaryFile()
#f = tempfile.NamedTemporaryFile()
#name_xml = '%s.%s' % ('slapreport', os.path.basename(f.name))
#name_xml = '%s.%s' % ('slapreport', os.path.basename(f.name))
#path_to_slapreport = os.path.join(instance_path, 'var', name_xml)
#path_to_slapreport = os.path.join(instance_path, 'var', name_xml)
invocation_list
.
append
(
path_to_slapreport
)
invocation_list
.
append
(
path_to_slapreport
)
#Dropping privileges
#Dropping privileges
uid
,
gid
=
None
,
None
uid
,
gid
=
None
,
None
stat_info
=
os
.
stat
(
instance_path
)
stat_info
=
os
.
stat
(
instance_path
)
#stat sys call to get statistics informations
#stat sys call to get statistics informations
uid
=
stat_info
.
st_uid
uid
=
stat_info
.
st_uid
gid
=
stat_info
.
st_gid
gid
=
stat_info
.
st_gid
kw
=
dict
()
kw
=
dict
()
if
not
self
.
console
:
if
not
self
.
console
:
kw
.
update
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
kw
.
update
(
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
process_handler
=
SlapPopen
(
invocation_list
,
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
os
.
path
.
join
(
instance_path
,
'etc'
,
'report'
),
cwd
=
os
.
path
.
join
(
instance_path
,
'etc'
,
'report'
),
env
=
None
,
**
kw
)
env
=
None
,
**
kw
)
result
=
process_handler
.
communicate
()[
0
]
result
=
process_handler
.
communicate
()[
0
]
if
self
.
console
:
if
self
.
console
:
result
=
'Please consult messages above'
result
=
'Please consult messages above'
if
process_handler
.
returncode
is
None
:
if
process_handler
.
returncode
is
None
:
process_handler
.
kill
()
process_handler
.
kill
()
if
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
!=
0
:
clean_run
=
False
clean_run
=
False
failed_script_list
.
append
(
"Script %r failed with %s."
%
(
script
,
failed_script_list
.
append
(
"Script %r failed with %s."
%
(
script
,
result
))
result
))
logger
.
warning
(
"Failed to run %r, the result was.
\
n
%s"
%
logger
.
warning
(
"Failed to run %r, the result was.
\
n
%s"
%
(
invocation_list
,
result
))
(
invocation_list
,
result
))
if
len
(
failed_script_list
):
if
len
(
failed_script_list
):
computer_partition
.
error
(
'
\
n
'
.
join
(
failed_script_list
))
computer_partition
.
error
(
'
\
n
'
.
join
(
failed_script_list
))
# 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
)
#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
=
[]
...
...
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