Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
main
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Simone Rossi
main
Commits
e9b14a2a
Commit
e9b14a2a
authored
Oct 13, 2017
by
Daniele Venzano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify self-termination state transitions
parent
441f1aba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
21 deletions
+22
-21
service.py
zoe_lib/state/service.py
+6
-2
backend.py
zoe_master/backends/docker/backend.py
+4
-1
threads.py
zoe_master/backends/docker/threads.py
+6
-17
interface.py
zoe_master/backends/interface.py
+6
-1
No files found.
zoe_lib/state/service.py
View file @
e9b14a2a
...
...
@@ -233,9 +233,13 @@ class Service:
if
self
.
is_dead
():
for
port
in
self
.
ports
:
port
.
reset
()
self
.
backend_id
=
None
self
.
ip_address
=
None
self
.
sql_manager
.
service_update
(
self
.
id
,
backend_status
=
new_status
,
ip_address
=
None
,
backend_id
=
None
)
self
.
sql_manager
.
service_update
(
self
.
id
,
backend_status
=
new_status
,
ip_address
=
None
)
if
new_status
==
self
.
BACKEND_DESTROY_STATUS
:
self
.
backend_id
=
None
self
.
sql_manager
.
service_update
(
self
.
id
,
backend_status
=
new_status
,
backend_id
=
None
,
ip_address
=
None
)
else
:
self
.
sql_manager
.
service_update
(
self
.
id
,
backend_status
=
new_status
,
ip_address
=
None
)
else
:
self
.
sql_manager
.
service_update
(
self
.
id
,
backend_status
=
new_status
)
...
...
zoe_master/backends/docker/backend.py
View file @
e9b14a2a
...
...
@@ -79,7 +79,10 @@ class DockerEngineBackend(zoe_master.backends.base.BaseBackend):
"""Terminate and delete a container."""
conf
=
self
.
_get_config
(
service
.
backend_host
)
engine
=
DockerClient
(
conf
)
engine
.
terminate_container
(
service
.
backend_id
,
delete
=
True
)
if
service
.
backend_id
is
not
None
:
engine
.
terminate_container
(
service
.
backend_id
,
delete
=
True
)
else
:
log
.
error
(
'Cannot terminate service {}, since it has not backend ID'
.
format
(
service
.
name
))
service
.
set_backend_status
(
service
.
BACKEND_DESTROY_STATUS
)
def
platform_state
(
self
)
->
ClusterStats
:
...
...
zoe_master/backends/docker/threads.py
View file @
e9b14a2a
...
...
@@ -66,28 +66,17 @@ class DockerStateSynchronizer(threading.Thread):
log
.
info
(
'Node {} is now online'
.
format
(
host_config
.
name
))
node_status
=
'online'
service_list
=
self
.
state
.
service_list
(
backend_host
=
host_config
.
name
,
not_status
=
Service
.
INACTIVE_STATUS
)
try
:
container_list
=
my_engine
.
list
(
only_label
=
{
'zoe_deployment_name'
:
get_conf
()
.
deployment_name
})
except
ZoeException
:
continue
containers
=
{}
for
cont
in
container_list
:
containers
[
cont
[
'id'
]]
=
cont
services
=
{}
for
service
in
service_list
:
services
[
service
.
backend_id
]
=
service
for
service
in
service_list
:
assert
isinstance
(
service
,
Service
)
if
service
.
backend_id
in
containers
:
self
.
_update_service_status
(
service
,
containers
[
service
.
backend_id
])
else
:
if
service
.
status
==
service
.
CREATED_STATUS
or
service
.
backend_status
==
service
.
BACKEND_DESTROY_STATUS
:
continue
else
:
service
.
set_backend_status
(
service
.
BACKEND_DESTROY_STATUS
)
service
=
self
.
state
.
service_list
(
only_one
=
True
,
backend_host
=
host_config
.
name
,
backend_id
=
cont
[
'id'
])
if
service
is
None
:
log
.
warning
(
'Container {} on host {} has no corresponding service'
.
format
(
cont
[
'name'
],
host_config
.
name
))
continue
self
.
_update_service_status
(
service
,
cont
)
time
.
sleep
(
CHECK_INTERVAL
)
...
...
zoe_master/backends/interface.py
View file @
e9b14a2a
...
...
@@ -155,7 +155,6 @@ def start_elastic(execution: Execution, placement) -> str:
def
terminate_execution
(
execution
:
Execution
)
->
None
:
"""Terminate an execution."""
execution
.
set_cleaning_up
()
backend
=
_get_backend
()
for
service
in
execution
.
services
:
# type: Service
if
service
.
status
!=
Service
.
INACTIVE_STATUS
:
...
...
@@ -170,6 +169,12 @@ def terminate_execution(execution: Execution) -> None:
service
.
set_inactive
()
else
:
log
.
error
(
'BUG: don
\'
t know how to terminate a service in status {}'
.
format
(
service
.
status
))
elif
not
service
.
is_dead
():
log
.
warning
(
'Service {} is inactive for Zoe, but running for the back-end, terminating and resetting state'
.
format
(
service
.
name
))
service
.
set_terminating
()
backend
.
terminate_service
(
service
)
service
.
set_inactive
()
log
.
debug
(
'Service {} terminated'
.
format
(
service
.
name
))
execution
.
set_terminated
()
...
...
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