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
Labels
Merge Requests
19
Merge Requests
19
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
18e83aa8
Commit
18e83aa8
authored
Oct 05, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly send to master, by mostly doing complicated things in logs, buildout errors.
parent
e63444fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
8 deletions
+46
-8
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+4
-2
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+31
-0
slapos/grid/utils.py
slapos/grid/utils.py
+11
-6
No files found.
slapos/grid/SlapObject.py
View file @
18e83aa8
...
...
@@ -379,7 +379,8 @@ class Partition(object):
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to bootstrap buildout in %r.'
%
(
self
.
instance_path
)
raise
BuildoutFailedError
(
message
)
self
.
logger
.
error
(
message
)
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
buildout_binary
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
'buildout'
)
if
not
os
.
path
.
exists
(
buildout_binary
):
...
...
@@ -479,7 +480,8 @@ class Partition(object):
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to destroy Computer Partition in %r.'
%
\
self
.
instance_path
raise
subprocess
.
CalledProcessError
(
message
)
self
.
logger
.
error
(
message
)
raise
subprocess
.
CalledProcessError
(
message
,
process_handler
.
output
)
# Manually cleans what remains
try
:
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
...
...
slapos/grid/slapgrid.py
View file @
18e83aa8
...
...
@@ -29,6 +29,7 @@
import
argparse
import
ConfigParser
from
exception
import
BuildoutFailedError
from
hashlib
import
md5
from
lxml
import
etree
import
logging
...
...
@@ -562,10 +563,25 @@ class Slapgrid(object):
logger
.
info
(
'Destroying %r...'
%
software_release_uri
)
software
.
destroy
()
logger
.
info
(
'Destroyed %r.'
%
software_release_uri
)
# Send log before exiting
except
(
SystemExit
,
KeyboardInterrupt
):
exception
=
traceback
.
format_exc
()
software_release
.
error
(
exception
)
raise
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
clean_run
=
False
try
:
software_release
.
error
(
exception
)
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
Exception
:
exception
=
traceback
.
format_exc
()
logger
.
error
(
'Problem during reporting error, continuing:
\
n
'
+
exception
)
# For everything else: log it, send it, continue.
except
Exception
:
exception
=
traceback
.
format_exc
()
logger
.
error
(
exception
)
...
...
@@ -800,10 +816,25 @@ class Slapgrid(object):
# Process the partition itself
self
.
processComputerPartition
(
computer_partition
)
# Send log before exiting
except
(
SystemExit
,
KeyboardInterrupt
):
exception
=
traceback
.
format_exc
()
computer_partition
.
error
(
exception
)
raise
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
,
exception
:
clean_run
=
False
try
:
computer_partition
.
error
(
exception
)
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
Exception
:
exception
=
traceback
.
format_exc
()
logger
.
error
(
'Problem during reporting error, continuing:
\
n
'
+
exception
)
# For everything else: log it, send it, continue.
except
Exception
as
exception
:
clean_run
=
False
logger
.
error
(
traceback
.
format_exc
())
...
...
slapos/grid/utils.py
View file @
18e83aa8
...
...
@@ -92,6 +92,8 @@ class AlreadyRunning(Exception):
class
SlapPopen
(
subprocess
.
Popen
):
"""
Almost normal subprocess with greedish features and logging.
Each line is logged "live", and self.output is a string containing the whole
log.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
kwargs
.
update
(
stdin
=
subprocess
.
PIPE
)
...
...
@@ -101,15 +103,17 @@ class SlapPopen(subprocess.Popen):
self
.
stdin
=
None
logger
=
logging
.
getLogger
(
'SlapProcessManager'
)
# XXX-Cedric: this algorithm looks overkill for simple logging.
self
.
output
=
''
while
True
:
line
=
self
.
stdout
.
readline
()
if
line
==
''
and
self
.
poll
()
!=
None
:
break
self
.
output
=
self
.
output
+
line
if
line
[
-
1
:]
==
'
\
n
'
:
line
=
line
[:
-
1
]
logger
.
info
(
line
)
def
getSoftwareUrlHash
(
url
):
return
md5
(
url
).
hexdigest
()
...
...
@@ -275,10 +279,10 @@ def bootstrapBuildout(path, buildout=None,
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r.
\
n
'
%
(
path
)
raise
BuildoutFailedError
(
message
)
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
logger
.
error
(
message
)
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
except
OSError
as
error
:
raise
BuildoutFailedError
(
error
)
finally
:
...
...
@@ -318,8 +322,9 @@ def launchBuildout(path, buildout_binary,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
env
=
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r
\
n
'
%
(
path
)
raise
BuildoutFailedError
(
message
)
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
logger
.
error
(
message
)
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
except
OSError
as
error
:
raise
BuildoutFailedError
(
error
)
finally
:
...
...
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