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
f6b08606
Commit
f6b08606
authored
Oct 02, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move getWatchdogId to a constant in slapgrid.
parent
3727b3d4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+4
-2
slapos/grid/watchdog.py
slapos/grid/watchdog.py
+8
-9
slapos/tests/slapgrid.py
slapos/tests/slapgrid.py
+10
-9
No files found.
slapos/grid/SlapObject.py
View file @
f6b08606
...
...
@@ -49,7 +49,9 @@ from slapos.grid.svcbackend import getSupervisorRPC
from
slapos.grid.exception
import
(
BuildoutFailedError
,
WrongPermissionError
,
PathDoesNotExistError
)
from
slapos.grid.networkcache
import
download_network_cached
,
upload_network_cached
from
slapos.grid.watchdog
import
getWatchdogID
WATCHDOG_MARK
=
'-on-watch'
REQUIRED_COMPUTER_PARTITION_PERMISSION
=
0o750
...
...
@@ -526,7 +528,7 @@ class Partition(object):
# Same method to add to service and run
self
.
addServiceToGroup
(
partition_id
,
runner_list
,
self
.
run_path
)
self
.
addServiceToGroup
(
partition_id
,
service_list
,
self
.
service_path
,
extension
=
getWatchdogID
()
)
extension
=
WATCHDOG_MARK
)
updateFile
(
self
.
supervisord_partition_configuration_path
,
self
.
partition_supervisor_configuration
)
self
.
updateSupervisor
()
...
...
slapos/grid/watchdog.py
View file @
f6b08606
...
...
@@ -32,11 +32,10 @@ import os.path
import
sys
import
slapos.slap.slap
import
slapos.grid.slapgrid
from
slapos.grid.slapgrid
import
COMPUTER_PARTITION_TIMESTAMP_FILENAME
,
\
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
def
getWatchdogID
():
return
"-on-watch"
from
slapos.grid.SlapObject
import
WATCHDOG_MARK
def
parseArgumentTuple
():
...
...
@@ -110,7 +109,7 @@ class Watchdog(object):
def
handle_event
(
self
,
headers
,
payload
):
if
headers
[
'eventname'
]
in
self
.
process_state_events
:
payload_dict
=
dict
([
x
.
split
(
':'
)
for
x
in
payload
.
split
()])
if
getWatchdogID
()
in
payload_dict
[
'processname'
]
and
\
if
WATCHDOG_MARK
in
payload_dict
[
'processname'
]
and
\
not
self
.
has_bang_already_been_called
(
payload_dict
[
'groupname'
]):
self
.
handle_process_state_change_event
(
headers
,
payload_dict
)
...
...
@@ -128,11 +127,11 @@ class Watchdog(object):
)
partition_timestamp_file_path
=
os
.
path
.
join
(
partition_home_path
,
slapos
.
grid
.
slapgrid
.
COMPUTER_PARTITION_TIMESTAMP_FILENAME
COMPUTER_PARTITION_TIMESTAMP_FILENAME
)
slapos_last_bang_timestamp_file_path
=
os
.
path
.
join
(
partition_home_path
,
slapos
.
grid
.
slapgrid
.
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
)
if
not
os
.
path
.
exists
(
slapos_last_bang_timestamp_file_path
):
...
...
@@ -168,11 +167,11 @@ class Watchdog(object):
)
partition_timestamp_file_path
=
os
.
path
.
join
(
partition_home_path
,
slapos
.
grid
.
slapgrid
.
COMPUTER_PARTITION_TIMESTAMP_FILENAME
COMPUTER_PARTITION_TIMESTAMP_FILENAME
)
slapos_last_bang_timestamp_file_path
=
os
.
path
.
join
(
partition_home_path
,
slapos
.
grid
.
slapgrid
.
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
)
if
os
.
path
.
exists
(
partition_timestamp_file_path
):
timestamp
=
open
(
partition_timestamp_file_path
,
'r'
).
read
()
...
...
slapos/tests/slapgrid.py
View file @
f6b08606
...
...
@@ -48,8 +48,9 @@ import slapos.grid.utils
from
slapos.grid
import
slapgrid
from
slapos.cli_legacy.slapgrid
import
parseArgumentTupleAndReturnSlapgridObject
from
slapos.grid.utils
import
md5digest
from
slapos.grid.watchdog
import
Watchdog
,
getWatchdogID
from
slapos.grid.watchdog
import
Watchdog
from
slapos.grid
import
SlapObject
from
slapos.grid.SlapObject
import
WATCHDOG_MARK
dummylogger
=
logging
.
getLogger
()
...
...
@@ -866,7 +867,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
instance
.
header_list
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[
'softwareInstanceBang'
])
self
.
assertEqual
(
instance
.
header_list
[
0
][
'key'
],
instance
.
key
)
...
...
@@ -890,7 +891,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
computer
.
sequence
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[])
...
...
@@ -943,7 +944,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
instance
.
header_list
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[
'softwareInstanceBang'
])
self
.
assertEqual
(
instance
.
header_list
[
0
][
'key'
],
instance
.
key
)
...
...
@@ -977,7 +978,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
instance
.
header_list
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[
'softwareInstanceBang'
])
self
.
assertEqual
(
instance
.
header_list
[
0
][
'key'
],
instance
.
key
)
...
...
@@ -1066,7 +1067,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
instance
.
header_list
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[
'softwareInstanceBang'
])
self
.
assertEqual
(
instance
.
header_list
[
0
][
'key'
],
instance
.
key
)
...
...
@@ -1080,7 +1081,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
instance
.
header_list
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[])
...
...
@@ -1096,7 +1097,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
instance
.
header_list
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[
'softwareInstanceBang'
])
self
.
assertEqual
(
instance
.
header_list
[
0
][
'key'
],
instance
.
key
)
...
...
@@ -1110,7 +1111,7 @@ class TestSlapgridCPWithMasterWatchdog(MasterMixin, unittest.TestCase):
instance
.
header_list
=
[]
headers
=
{
'eventname'
:
event
}
payload
=
'processname:%s groupname:%s from_state:RUNNING'
%
(
'daemon'
+
getWatchdogID
()
,
instance
.
name
)
'daemon'
+
WATCHDOG_MARK
,
instance
.
name
)
watchdog
.
handle_event
(
headers
,
payload
)
self
.
assertEqual
(
instance
.
sequence
,
[])
...
...
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