Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Hardik Juneja
slapos.toolbox
Commits
e737a7bb
Commit
e737a7bb
authored
Jan 09, 2017
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: promise timemout is now configurable. Default value is 20
parent
d1d7044f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
slapos/monitor/monitor.py
slapos/monitor/monitor.py
+4
-0
slapos/monitor/runpromise.py
slapos/monitor/runpromise.py
+16
-4
No files found.
slapos/monitor/monitor.py
View file @
e737a7bb
...
...
@@ -94,6 +94,8 @@ class Monitoring(object):
self
.
pid_file
=
config
.
get
(
"monitor"
,
"pid-file"
)
self
.
monitor_promise_folder
=
softConfigGet
(
config
,
"monitor"
,
"monitor-promise-folder"
)
self
.
promise_timeout_file
=
softConfigGet
(
config
,
"monitor"
,
"promises-timeout-file"
)
self
.
config_folder
=
os
.
path
.
join
(
self
.
private_folder
,
'config'
)
self
.
report_folder
=
self
.
private_folder
...
...
@@ -101,6 +103,7 @@ class Monitoring(object):
self
.
promise_output_file
=
config
.
get
(
"monitor"
,
"promise-output-file"
)
self
.
bootstrap_is_ok
=
True
def
loadConfig
(
self
,
pathes
,
config
=
None
):
if
config
is
None
:
config
=
ConfigParser
.
ConfigParser
()
...
...
@@ -411,6 +414,7 @@ class Monitoring(object):
"monitor-promises.pid"
),
'--output "%s"'
%
self
.
public_folder
,
'--promise_folder "%s"'
%
self
.
promise_folder
,
'--timeout_file "%s"'
%
self
.
promise_timeout_file
,
'--monitor_promise_folder "%s"'
%
self
.
monitor_promise_folder
,
'--monitor_url "%s/jio_private/"'
%
self
.
webdav_url
,
# XXX hardcoded,
'--history_folder "%s"'
%
self
.
public_folder
,
...
...
slapos/monitor/runpromise.py
View file @
e737a7bb
...
...
@@ -12,8 +12,8 @@ import glob
import
argparse
import
traceback
# Promise timeout after
12 seconds
promise_timeout
=
12
# Promise timeout after
20 seconds by default
promise_timeout
=
20
def
parseArguments
():
"""
...
...
@@ -32,6 +32,9 @@ def parseArguments():
help
=
'Folder where to find Custom monitor promises to execute.'
)
parser
.
add_argument
(
'--promise_name'
,
help
=
'Title to give to this promise.'
)
parser
.
add_argument
(
'--timeout_file'
,
default
=
''
,
help
=
'File containing Max timeout for each promise run.'
)
parser
.
add_argument
(
'--promise_type'
,
default
=
'status'
,
help
=
'Type of promise to execute. [status, report].'
)
...
...
@@ -52,6 +55,15 @@ class RunPromise(object):
def
__init__
(
self
,
config_parser
):
self
.
config
=
config_parser
self
.
promise_timeout
=
promise_timeout
if
self
.
config
.
timeout_file
and
\
os
.
path
.
exists
(
self
.
config
.
timeout_file
):
with
open
(
self
.
config
.
timeout_file
)
as
tf
:
timeout
=
tf
.
read
()
if
timeout
.
isdigit
():
self
.
promise_timeout
=
int
(
timeout
)
else
:
print
"%s it not a valid promise-timeout value"
%
timeout
def
runpromise
(
self
):
...
...
@@ -298,7 +310,7 @@ class RunPromise(object):
process_handler
.
stdin
=
None
sleep_time
=
0.1
increment_limit
=
int
(
promise_timeout
/
sleep_time
)
increment_limit
=
int
(
self
.
promise_timeout
/
sleep_time
)
for
current_increment
in
range
(
0
,
increment_limit
):
if
process_handler
.
poll
()
is
None
:
time
.
sleep
(
sleep_time
)
...
...
@@ -318,7 +330,7 @@ class RunPromise(object):
message
=
process_handler
.
stderr
.
read
()
if
message
is
None
:
message
=
process_handler
.
stdout
.
read
()
or
""
message
+=
'
\
n
PROMISE TIME OUT AFTER %s SECONDS'
%
promise_timeout
message
+=
'
\
n
PROMISE TIME OUT AFTER %s SECONDS'
%
self
.
promise_timeout
result_dict
[
"message"
]
=
message
promise_result_list
.
append
(
result_dict
)
...
...
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