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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
ee65c76a
Commit
ee65c76a
authored
Aug 06, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promise: treat CRITICAL like ERROR
parent
aee0f487
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
slapos/grid/promise/generic.py
slapos/grid/promise/generic.py
+11
-9
No files found.
slapos/grid/promise/generic.py
View file @
ee65c76a
...
@@ -47,10 +47,12 @@ PROMISE_LOG_FOLDER_NAME = '.slapgrid/promise/log'
...
@@ -47,10 +47,12 @@ PROMISE_LOG_FOLDER_NAME = '.slapgrid/promise/log'
PROMISE_PARAMETER_NAME
=
'extra_config_dict'
PROMISE_PARAMETER_NAME
=
'extra_config_dict'
LOGLINE_RE
=
r"(\
d{
4}-\
d{
2}-\
d{
2}\
s+
\d{2}:\
d{
2}:\
d{
2})\
s+
\-?\
s*(
\w
{4,7}
)\
s+
\-?\
s+(
\d+\
-
\d{3})\
s+
\-?\
s*(.*)
"
LOGLINE_RE
=
r"(\
d{
4}-\
d{
2}-\
d{
2}\
s+
\d{2}:\
d{
2}:\
d{
2})\
s+
\-?\
s*(
\w
+
)\
s+
\-?\
s+(
\d+\
-
\d{3})\
s+
\-?\
s*(.*)
"
matchLogStr = re.compile(LOGLINE_RE).match
matchLogStr = re.compile(LOGLINE_RE).match
matchLogBytes = re.compile(LOGLINE_RE.encode()).match if PY3 else matchLogStr
matchLogBytes = re.compile(LOGLINE_RE.encode()).match if PY3 else matchLogStr
ERROR_LEVEL = 'CRITICAL', 'ERROR'
class BaseResult(object):
class BaseResult(object):
def __init__(self, problem=False, message=None, date=None):
def __init__(self, problem=False, message=None, date=None):
self.__problem = problem
self.__problem = problem
...
@@ -283,16 +285,16 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
...
@@ -283,16 +285,16 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
continue
continue
match = matchLogStr(line)
match = matchLogStr(line)
if match is not None:
if match is not None:
if not only_failure or (only_failure and match.groups()[1] == 'ERROR'):
date, level, tid, msg = match.groups()
if not only_failure or level in ERROR_LEVEL:
result_list.append({
result_list.append({
'date': datetime.strptime(
match.groups()[0]
, '%Y-%m-%d %H:%M:%S'),
'date': datetime.strptime(
date
, '%Y-%m-%d %H:%M:%S'),
'status':
match.groups()[1]
,
'status':
level
,
'message': (m
atch.groups()[3]
+ line_part).strip(),
'message': (m
sg
+ line_part).strip(),
})
})
line_part = ""
line_part = ""
else:
else:
line_part += '
\
n
' + line
line_part += '
\
n
' + line
result_list
return [result_list]
return [result_list]
...
@@ -358,7 +360,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
...
@@ -358,7 +360,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
if transaction_count > result_count:
if transaction_count > result_count:
break
break
transaction_id = tid
transaction_id = tid
if not only_failure or level
== 'ERROR'
:
if not only_failure or level
in ERROR_LEVEL
:
line_list.insert(0, {
line_list.insert(0, {
'date': datetime.strptime(date,
'date': datetime.strptime(date,
'%Y-%m-%d %H:%M:%S'),
'%Y-%m-%d %H:%M:%S'),
...
@@ -378,7 +380,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
...
@@ -378,7 +380,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
failed = False
failed = False
message = ""
message = ""
for result in result_list:
for result in result_list:
if result['status']
== 'ERROR'
:
if result['status']
in ERROR_LEVEL
:
failed = True
failed = True
message += "
\
n
%
s
" % result['message']
message += "
\
n
%
s
" % result['message']
return failed, message.strip()
return failed, message.strip()
...
@@ -414,7 +416,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
...
@@ -414,7 +416,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
failure_found = 1
failure_found = 1
while i < result_size and failure_found < failure_amount:
while i < result_size and failure_found < failure_amount:
for result in latest_result_list[i]:
for result in latest_result_list[i]:
if result['status']
== 'ERROR'
:
if result['status']
in ERROR_LEVEL
:
failure_found += 1
failure_found += 1
break
break
i += 1
i += 1
...
...
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