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
Łukasz Nowak
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
Show 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):
...
@@ -379,7 +379,8 @@ class Partition(object):
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
env
=
utils
.
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to bootstrap buildout in %r.'
%
(
self
.
instance_path
)
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'
)
buildout_binary
=
os
.
path
.
join
(
self
.
instance_path
,
'sbin'
,
'buildout'
)
if
not
os
.
path
.
exists
(
buildout_binary
):
if
not
os
.
path
.
exists
(
buildout_binary
):
...
@@ -479,7 +480,8 @@ class Partition(object):
...
@@ -479,7 +480,8 @@ class Partition(object):
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to destroy Computer Partition in %r.'
%
\
message
=
'Failed to destroy Computer Partition in %r.'
%
\
self
.
instance_path
self
.
instance_path
raise
subprocess
.
CalledProcessError
(
message
)
self
.
logger
.
error
(
message
)
raise
subprocess
.
CalledProcessError
(
message
,
process_handler
.
output
)
# Manually cleans what remains
# Manually cleans what remains
try
:
try
:
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
...
...
slapos/grid/slapgrid.py
View file @
18e83aa8
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
import
argparse
import
argparse
import
ConfigParser
import
ConfigParser
from
exception
import
BuildoutFailedError
from
hashlib
import
md5
from
hashlib
import
md5
from
lxml
import
etree
from
lxml
import
etree
import
logging
import
logging
...
@@ -562,10 +563,25 @@ class Slapgrid(object):
...
@@ -562,10 +563,25 @@ class Slapgrid(object):
logger
.
info
(
'Destroying %r...'
%
software_release_uri
)
logger
.
info
(
'Destroying %r...'
%
software_release_uri
)
software
.
destroy
()
software
.
destroy
()
logger
.
info
(
'Destroyed %r.'
%
software_release_uri
)
logger
.
info
(
'Destroyed %r.'
%
software_release_uri
)
# Send log before exiting
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
exception
=
traceback
.
format_exc
()
exception
=
traceback
.
format_exc
()
software_release
.
error
(
exception
)
software_release
.
error
(
exception
)
raise
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
:
except
Exception
:
exception
=
traceback
.
format_exc
()
exception
=
traceback
.
format_exc
()
logger
.
error
(
exception
)
logger
.
error
(
exception
)
...
@@ -800,10 +816,25 @@ class Slapgrid(object):
...
@@ -800,10 +816,25 @@ class Slapgrid(object):
# Process the partition itself
# Process the partition itself
self
.
processComputerPartition
(
computer_partition
)
self
.
processComputerPartition
(
computer_partition
)
# Send log before exiting
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
exception
=
traceback
.
format_exc
()
exception
=
traceback
.
format_exc
()
computer_partition
.
error
(
exception
)
computer_partition
.
error
(
exception
)
raise
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
:
except
Exception
as
exception
:
clean_run
=
False
clean_run
=
False
logger
.
error
(
traceback
.
format_exc
())
logger
.
error
(
traceback
.
format_exc
())
...
...
slapos/grid/utils.py
View file @
18e83aa8
...
@@ -92,6 +92,8 @@ class AlreadyRunning(Exception):
...
@@ -92,6 +92,8 @@ class AlreadyRunning(Exception):
class
SlapPopen
(
subprocess
.
Popen
):
class
SlapPopen
(
subprocess
.
Popen
):
"""
"""
Almost normal subprocess with greedish features and logging.
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
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
kwargs
.
update
(
stdin
=
subprocess
.
PIPE
)
kwargs
.
update
(
stdin
=
subprocess
.
PIPE
)
...
@@ -101,15 +103,17 @@ class SlapPopen(subprocess.Popen):
...
@@ -101,15 +103,17 @@ class SlapPopen(subprocess.Popen):
self
.
stdin
=
None
self
.
stdin
=
None
logger
=
logging
.
getLogger
(
'SlapProcessManager'
)
logger
=
logging
.
getLogger
(
'SlapProcessManager'
)
# XXX-Cedric: this algorithm looks overkill for simple logging.
self
.
output
=
''
while
True
:
while
True
:
line
=
self
.
stdout
.
readline
()
line
=
self
.
stdout
.
readline
()
if
line
==
''
and
self
.
poll
()
!=
None
:
if
line
==
''
and
self
.
poll
()
!=
None
:
break
break
self
.
output
=
self
.
output
+
line
if
line
[
-
1
:]
==
'
\
n
'
:
if
line
[
-
1
:]
==
'
\
n
'
:
line
=
line
[:
-
1
]
line
=
line
[:
-
1
]
logger
.
info
(
line
)
logger
.
info
(
line
)
def
getSoftwareUrlHash
(
url
):
def
getSoftwareUrlHash
(
url
):
return
md5
(
url
).
hexdigest
()
return
md5
(
url
).
hexdigest
()
...
@@ -275,10 +279,10 @@ def bootstrapBuildout(path, buildout=None,
...
@@ -275,10 +279,10 @@ def bootstrapBuildout(path, buildout=None,
process_handler
=
SlapPopen
(
invocation_list
,
process_handler
=
SlapPopen
(
invocation_list
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
**
kw
)
cwd
=
path
,
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r.
\
n
'
%
(
path
)
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
raise
BuildoutFailedError
(
message
)
logger
.
error
(
message
)
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
except
OSError
as
error
:
except
OSError
as
error
:
raise
BuildoutFailedError
(
error
)
raise
BuildoutFailedError
(
error
)
finally
:
finally
:
...
@@ -318,8 +322,9 @@ def launchBuildout(path, buildout_binary,
...
@@ -318,8 +322,9 @@ def launchBuildout(path, buildout_binary,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
preexec_fn
=
lambda
:
dropPrivileges
(
uid
,
gid
),
cwd
=
path
,
env
=
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
env
=
getCleanEnvironment
(
pwd
.
getpwuid
(
uid
).
pw_dir
),
**
kw
)
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
if
process_handler
.
returncode
is
None
or
process_handler
.
returncode
!=
0
:
message
=
'Failed to run buildout profile in directory %r
\
n
'
%
(
path
)
message
=
'Failed to run buildout profile in directory %r'
%
(
path
)
raise
BuildoutFailedError
(
message
)
logger
.
error
(
message
)
raise
BuildoutFailedError
(
'%s:
\
n
%s
\
n
'
%
(
message
,
process_handler
.
output
))
except
OSError
as
error
:
except
OSError
as
error
:
raise
BuildoutFailedError
(
error
)
raise
BuildoutFailedError
(
error
)
finally
:
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