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
Guillaume Hervier
slapos.core
Commits
66aa4d59
Commit
66aa4d59
authored
Jun 20, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapgrid: exception handling cleanup
parent
a9be8240
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
47 deletions
+24
-47
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+22
-44
slapos/slap/slap.py
slapos/slap/slap.py
+2
-3
No files found.
slapos/grid/slapgrid.py
View file @
66aa4d59
...
@@ -445,14 +445,12 @@ class Slapgrid(object):
...
@@ -445,14 +445,12 @@ class Slapgrid(object):
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
raise
raise
except
Exception
:
except
Exception
:
self
.
logger
.
error
(
'Problem while reporting error, continuing:
\
n
%s'
%
self
.
logger
.
exception
(
'Problem while reporting error, continuing:'
)
traceback
.
format_exc
())
# For everything else: log it, send it, continue.
# For everything else: log it, send it, continue.
except
Exception
:
except
Exception
:
exc
=
traceback
.
format_exc
()
self
.
logger
.
exception
(
''
)
self
.
logger
.
error
(
exc
)
software_release
.
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
software_release
.
error
(
exc
,
logger
=
self
.
logger
)
clean_run
=
False
clean_run
=
False
else
:
else
:
if
state
==
'available'
:
if
state
==
'available'
:
...
@@ -464,7 +462,7 @@ class Slapgrid(object):
...
@@ -464,7 +462,7 @@ class Slapgrid(object):
try
:
try
:
software_release
.
destroyed
()
software_release
.
destroyed
()
except
(
NotFoundError
,
ServerError
):
except
(
NotFoundError
,
ServerError
):
print
traceback
.
format_exc
(
)
self
.
logger
.
exception
(
''
)
self
.
logger
.
info
(
'Finished software releases.'
)
self
.
logger
.
info
(
'Finished software releases.'
)
# Return success value
# Return success value
...
@@ -583,7 +581,7 @@ class Slapgrid(object):
...
@@ -583,7 +581,7 @@ class Slapgrid(object):
periodicity
=
int
(
open
(
periodicity_path
).
read
())
periodicity
=
int
(
open
(
periodicity_path
).
read
())
except
ValueError
:
except
ValueError
:
os
.
remove
(
periodicity_path
)
os
.
remove
(
periodicity_path
)
self
.
logger
.
e
rror
(
traceback
.
format_exc
()
)
self
.
logger
.
e
xception
(
''
)
# Check if timestamp from server is more recent than local one.
# Check if timestamp from server is more recent than local one.
# If not: it's not worth processing this partition (nothing has
# If not: it's not worth processing this partition (nothing has
...
@@ -609,7 +607,7 @@ class Slapgrid(object):
...
@@ -609,7 +607,7 @@ class Slapgrid(object):
os
.
remove
(
timestamp_path
)
os
.
remove
(
timestamp_path
)
except
ValueError
:
except
ValueError
:
os
.
remove
(
timestamp_path
)
os
.
remove
(
timestamp_path
)
self
.
logger
.
e
rror
(
traceback
.
format_exc
()
)
self
.
logger
.
e
xception
(
''
)
self
.
logger
.
info
(
' Software URL: %s'
%
software_url
)
self
.
logger
.
info
(
' Software URL: %s'
%
software_url
)
self
.
logger
.
info
(
' Software path: %s'
%
software_path
)
self
.
logger
.
info
(
' Software path: %s'
%
software_path
)
...
@@ -708,26 +706,17 @@ class Slapgrid(object):
...
@@ -708,26 +706,17 @@ class Slapgrid(object):
computer_partition
.
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
computer_partition
.
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
raise
raise
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
as
exc
:
try
:
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
Exception
:
self
.
logger
.
error
(
'Problem during reporting error, continuing:
\
n
%s'
%
traceback
.
format_exc
())
# For everything else: log it, send it, continue.
except
Exception
as
exc
:
except
Exception
as
exc
:
self
.
logger
.
error
(
traceback
.
format_exc
())
# if Buildout failed: send log but don't print it to output (already done)
if
not
isinstance
(
exc
,
BuildoutFailedError
):
# For everything else: log it, send it, continue.
self
.
logger
.
exception
(
''
)
try
:
try
:
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
raise
raise
except
Exception
:
except
Exception
:
self
.
logger
.
error
(
'Problem during reporting error, continuing:
\
n
%s'
%
self
.
logger
.
exception
(
'Problem while reporting error, continuing:'
)
traceback
.
format_exc
())
return
filtered_computer_partition_list
return
filtered_computer_partition_list
...
@@ -773,31 +762,20 @@ class Slapgrid(object):
...
@@ -773,31 +762,20 @@ class Slapgrid(object):
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
raise
raise
except
Exception
:
except
Exception
:
self
.
logger
.
error
(
'Problem during reporting error, continuing:
\
n
%s'
%
self
.
logger
.
exception
(
'Problem while reporting error, continuing:'
)
traceback
.
format_exc
())
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
as
exc
:
clean_run
=
False
try
:
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
Exception
:
self
.
logger
.
error
(
'Problem during reporting error, continuing:
\
n
%s'
%
traceback
.
format_exc
())
# For everything else: log it, send it, continue.
except
Exception
as
exc
:
except
Exception
as
exc
:
clean_run
=
False
clean_run
=
False
self
.
logger
.
error
(
traceback
.
format_exc
())
# if Buildout failed: send log but don't print it to output (already done)
if
not
isinstance
(
exc
,
BuildoutFailedError
):
# For everything else: log it, send it, continue.
self
.
logger
.
exception
(
''
)
try
:
try
:
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
except
(
SystemExit
,
KeyboardInterrupt
):
except
(
SystemExit
,
KeyboardInterrupt
):
raise
raise
except
Exception
:
except
Exception
:
self
.
logger
.
error
(
'Problem during reporting error, continuing:
\
n
%s'
%
self
.
logger
.
exception
(
'Problem while reporting error, continuing:'
)
traceback
.
format_exc
())
self
.
logger
.
info
(
'Finished computer partitions.'
)
self
.
logger
.
info
(
'Finished computer partitions.'
)
...
@@ -966,8 +944,8 @@ class Slapgrid(object):
...
@@ -966,8 +944,8 @@ class Slapgrid(object):
computer_partition
.
error
(
'
\
n
'
.
join
(
failed_script_list
),
logger
=
self
.
logger
)
computer_partition
.
error
(
'
\
n
'
.
join
(
failed_script_list
),
logger
=
self
.
logger
)
# Whatever happens, don't stop processing other instances
# Whatever happens, don't stop processing other instances
except
Exception
:
except
Exception
:
self
.
logger
.
info
(
'Cannot run usage script(s) for %r: %s
'
%
self
.
logger
.
exception
(
'Cannot run usage script(s) for %r:
'
%
(
computer_partition
.
getId
(),
traceback
.
format_exc
()
))
computer_partition
.
getId
(
))
#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
=
[]
...
@@ -1013,8 +991,8 @@ class Slapgrid(object):
...
@@ -1013,8 +991,8 @@ class Slapgrid(object):
# Whatever happens, don't stop processing other instances
# Whatever happens, don't stop processing other instances
except
Exception
:
except
Exception
:
self
.
logger
.
info
(
'Cannot run usage script(s) for %r: %s
'
%
self
.
logger
.
exception
(
'Cannot run usage script(s) for %r:
'
%
(
computer_partition
.
getId
(),
traceback
.
format_exc
()
))
computer_partition
.
getId
(
))
for
computer_partition_usage
in
computer_partition_usage_list
:
for
computer_partition_usage
in
computer_partition_usage_list
:
self
.
logger
.
info
(
'computer_partition_usage_list: %s - %s'
%
self
.
logger
.
info
(
'computer_partition_usage_list: %s - %s'
%
...
@@ -1088,9 +1066,9 @@ class Slapgrid(object):
...
@@ -1088,9 +1066,9 @@ class Slapgrid(object):
raise
raise
except
Exception
:
except
Exception
:
clean_run
=
False
clean_run
=
False
self
.
logger
.
exception
(
''
)
exc
=
traceback
.
format_exc
()
exc
=
traceback
.
format_exc
()
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
computer_partition
.
error
(
exc
,
logger
=
self
.
logger
)
self
.
logger
.
error
(
exc
)
try
:
try
:
computer_partition
.
destroyed
()
computer_partition
.
destroyed
()
except
NotFoundError
:
except
NotFoundError
:
...
...
slapos/slap/slap.py
View file @
66aa4d59
...
@@ -39,7 +39,6 @@ import logging
...
@@ -39,7 +39,6 @@ import logging
import
re
import
re
import
socket
import
socket
import
ssl
import
ssl
import
traceback
import
urllib
import
urllib
import
urlparse
import
urlparse
...
@@ -160,7 +159,7 @@ class SoftwareRelease(SlapDocument):
...
@@ -160,7 +159,7 @@ class SoftwareRelease(SlapDocument):
'computer_id'
:
self
.
getComputerId
(),
'computer_id'
:
self
.
getComputerId
(),
'error_log'
:
error_log
})
'error_log'
:
error_log
})
except
Exception
:
except
Exception
:
(
logger
or
fallback_logger
).
e
rror
(
traceback
.
format_exc
()
)
(
logger
or
fallback_logger
).
e
xception
(
''
)
def
available
(
self
):
def
available
(
self
):
self
.
_connection_helper
.
POST
(
'/availableSoftwareRelease'
,
{
self
.
_connection_helper
.
POST
(
'/availableSoftwareRelease'
,
{
...
@@ -448,7 +447,7 @@ class ComputerPartition(SlapRequester):
...
@@ -448,7 +447,7 @@ class ComputerPartition(SlapRequester):
'computer_partition_id'
:
self
.
getId
(),
'computer_partition_id'
:
self
.
getId
(),
'error_log'
:
error_log
})
'error_log'
:
error_log
})
except
Exception
:
except
Exception
:
(
logger
or
fallback_logger
).
e
rror
(
traceback
.
format_exc
()
)
(
logger
or
fallback_logger
).
e
xception
(
''
)
def
bang
(
self
,
message
):
def
bang
(
self
,
message
):
self
.
_connection_helper
.
POST
(
'/softwareInstanceBang'
,
{
self
.
_connection_helper
.
POST
(
'/softwareInstanceBang'
,
{
...
...
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