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
Xiaowu Zhang
slapos.toolbox
Commits
b70edc75
Commit
b70edc75
authored
Jan 27, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mostly working version of watchdog.
Need to be fully tested.
parent
4d444533
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
21 deletions
+14
-21
slapos/wordpress/ia/watchdog/__init__.py
slapos/wordpress/ia/watchdog/__init__.py
+2
-1
slapos/wordpress/ia/watchdog/connection.py
slapos/wordpress/ia/watchdog/connection.py
+12
-20
No files found.
slapos/wordpress/ia/watchdog/__init__.py
View file @
b70edc75
...
...
@@ -46,7 +46,8 @@ def main():
while
True
:
time
.
sleep
(
args
.
frequency
)
server
.
get_master
()
server
.
think
(
1
)
# XXX: Hard coding 5 minutes
server
.
think
(
5
)
...
...
slapos/wordpress/ia/watchdog/connection.py
View file @
b70edc75
...
...
@@ -39,10 +39,16 @@ from slapos.slap import slap
def
get_status
(
feed_content
):
feed
=
feedparser
.
parse
(
feed_content
)
# Just for test purpose
# here should be the algorithm saying if we
# should rename or not the partition.
error_amount
=
0
for
entry
in
feed
.
entries
:
if
'FAIL'
in
entry
.
content
:
error_amount
+=
1
# XXX: Hard coding maximum error amount
# is 3.
if
error_amount
>=
3
:
return
False
return
True
def
get_timestamp
(
minutes_ago
):
result
=
datetime
.
datetime
.
now
()
...
...
@@ -120,10 +126,6 @@ class Server(Connector):
for
url
in
json
.
loads
(
connector
.
GET
(
'getPeers'
).
read
())])
except
:
pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
@
staticmethod
def
_convert_uuid
(
id_
):
...
...
@@ -141,10 +143,6 @@ class Server(Connector):
type_
=
value
.
GET
(
'info/type'
).
read
()
except
:
pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
else
:
to_set_none
=
deque
()
# Look for peer having same type (type should be unique)
...
...
@@ -182,10 +180,6 @@ class Server(Connector):
failed_list
.
append
(
peer
)
except
:
pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
return
self
.
get_peer_id
(
id_
).
geturl
()
...
...
@@ -236,10 +230,6 @@ class Server(Connector):
pass
except
:
pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
def
get_type
(
self
,
type_
):
for
peer_type
,
peer
in
self
.
_peers
.
itervalues
():
...
...
@@ -257,6 +247,8 @@ class Server(Connector):
def
down
(
self
,
connector
):
new_name
=
'down_%s'
%
uuid
.
uuid4
().
hex
self
.
rename
(
connector
,
new_name
)
# XXX: EXTREMELY Dirty Workaround to avoid bug #20120127-6487F8
time
.
sleep
(
10
)
self
.
slaprequest
(
partition_reference
=
new_name
,
software_type
=
'down'
)
...
...
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