Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
main
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
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
Simone Rossi
main
Commits
ad31af17
Commit
ad31af17
authored
Jan 31, 2017
by
Daniele Venzano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some configuration sanity checking at startup
parent
1578fbfb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
12 deletions
+59
-12
zoe_api/entrypoint.py
zoe_api/entrypoint.py
+10
-3
zoe_master/backends/common.py
zoe_master/backends/common.py
+1
-1
zoe_master/backends/interface.py
zoe_master/backends/interface.py
+7
-1
zoe_master/backends/old_swarm/api_client.py
zoe_master/backends/old_swarm/api_client.py
+10
-1
zoe_master/backends/old_swarm_new_api/api_client.py
zoe_master/backends/old_swarm_new_api/api_client.py
+10
-1
zoe_master/backends/old_swarm_new_api/backend.py
zoe_master/backends/old_swarm_new_api/backend.py
+2
-2
zoe_master/backends/old_swarm_new_api/threads.py
zoe_master/backends/old_swarm_new_api/threads.py
+1
-1
zoe_master/entrypoint.py
zoe_master/entrypoint.py
+18
-2
No files found.
zoe_api/entrypoint.py
View file @
ad31af17
...
...
@@ -34,6 +34,13 @@ log = logging.getLogger("zoe_api")
LOG_FORMAT
=
'%(asctime)-15s %(levelname)s %(threadName)s->%(name)s: %(message)s'
def
_check_configuration_sanity
():
if
config
.
get_conf
().
auth_type
==
'ldap'
and
not
zoe_api
.
auth
.
ldap
.
LDAP_AVAILABLE
:
log
.
error
(
"LDAP authentication requested, but 'pyldap' module not installed."
)
return
1
return
0
def
zoe_web_main
()
->
int
:
"""
This is the entry point for the Zoe Web script.
...
...
@@ -46,9 +53,9 @@ def zoe_web_main() -> int:
else
:
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
LOG_FORMAT
)
if
config
.
get_conf
().
auth_type
==
'ldap'
and
not
zoe_api
.
auth
.
ldap
.
LDAP_AVAILABLE
:
log
.
error
(
"LDAP authentication requested, but 'pyldap' module not installed."
)
return
1
ret
=
_check_configuration_sanity
()
if
ret
!=
0
:
return
ret
zoe_api
.
db_init
.
init
()
...
...
zoe_master/backends/common.py
View file @
ad31af17
...
...
@@ -48,7 +48,7 @@ def gen_environment(service: Service, execution: Execution):
def
_create_logs_directories
(
exec_id
,
service_name
):
path
=
get_conf
().
logs_base_path
+
'/'
+
get_conf
().
deployment_name
+
str
(
exec_id
)
+
'/'
+
service_name
path
=
get_conf
().
logs_base_path
+
'/'
+
get_conf
().
deployment_name
+
'/'
+
str
(
exec_id
)
+
'/'
+
service_name
try
:
os
.
makedirs
(
path
)
except
OSError
as
e
:
...
...
zoe_master/backends/interface.py
View file @
ad31af17
...
...
@@ -23,8 +23,10 @@ from zoe_lib.state import Execution, Service
from
zoe_master.backends.base
import
BaseBackend
from
zoe_master.backends.old_swarm.backend
import
OldSwarmBackend
import
zoe_master.backends.old_swarm.api_client
from
zoe_master.backends.old_swarm_new_api.backend
import
OldSwarmNewAPIBackend
from
zoe_master.exceptions
import
ZoeStartExecutionFatalException
,
ZoeStartExecutionRetryException
import
zoe_master.backends.old_swarm_new_api.api_client
from
zoe_master.exceptions
import
ZoeStartExecutionFatalException
,
ZoeStartExecutionRetryException
,
ZoeException
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -33,8 +35,12 @@ def _get_backend() -> BaseBackend:
"""Return the right backend instance by reading the global configuration."""
backend_name
=
get_conf
().
backend
if
backend_name
==
'OldSwarm'
:
if
not
zoe_master
.
backends
.
old_swarm
.
api_client
.
AVAILABLE
:
raise
ZoeException
(
'The OldSwarm backend requires docker-py version <= 1.10.2'
)
return
OldSwarmBackend
(
get_conf
())
elif
backend_name
==
'OldSwarmNewAPI'
:
if
not
zoe_master
.
backends
.
old_swarm_new_api
.
api_client
.
AVAILABLE
:
raise
ZoeException
(
'The OldSwarmNewAPI backend requires docker python version >= 2.0.2'
)
return
OldSwarmNewAPIBackend
(
get_conf
())
else
:
log
.
error
(
'Unknown backend selected'
)
...
...
zoe_master/backends/old_swarm/api_client.py
View file @
ad31af17
...
...
@@ -32,12 +32,17 @@ try:
except
ImportError
:
KazooClient
=
None
AVAILABLE
=
True
try
:
import
docker
import
docker.errors
import
docker.utils
except
ImportError
:
pass
AVAILABLE
=
False
try
:
docker
.
Client
()
except
:
AVAILABLE
=
False
import
requests.packages
...
...
@@ -148,9 +153,13 @@ class SwarmClient:
self
.
opts
=
opts
url
=
opts
.
swarm
if
'zk://'
in
url
:
if
KazooClient
is
None
:
raise
ZoeLibException
(
'ZooKeeper URL for Swarm, but the kazoo package is not installed'
)
url
=
url
[
len
(
'zk://'
):]
manager
=
zookeeper_swarm
(
url
,
opts
.
backend_swarm_zk_path
)
elif
'consul://'
in
url
:
if
Consul
is
None
:
raise
ZoeLibException
(
'Consul URL for Swarm, but the consul package is not installed'
)
url
=
url
[
len
(
'consul://'
):]
manager
=
consul_swarm
(
url
)
elif
'http://'
or
'https://'
in
url
:
...
...
zoe_master/backends/old_swarm_new_api/api_client.py
View file @
ad31af17
...
...
@@ -32,12 +32,18 @@ try:
except
ImportError
:
KazooClient
=
None
AVAILABLE
=
True
try
:
import
docker
import
docker.errors
import
docker.utils
except
ImportError
:
pass
AVAILABLE
=
False
else
:
try
:
docker
.
DockerClient
()
except
:
AVAILABLE
=
False
import
requests.packages
...
...
@@ -290,6 +296,9 @@ class SwarmClient:
elif
container
.
status
==
'OOMKilled'
or
container
.
status
==
'exited'
:
info
[
"state"
]
=
"killed"
info
[
"running"
]
=
False
elif
container
.
status
==
'created'
:
info
[
"state"
]
=
'created'
info
[
"running"
]
=
False
else
:
log
.
error
(
'Unknown container status: {}'
.
format
(
container
.
status
))
info
[
"state"
]
=
"unknown"
...
...
zoe_master/backends/old_swarm_new_api/backend.py
View file @
ad31af17
...
...
@@ -20,11 +20,11 @@ import logging
from
zoe_lib.config
import
get_conf
from
zoe_lib.exceptions
import
ZoeLibException
,
ZoeNotEnoughResourcesException
from
zoe_lib.state
import
Execution
,
Service
from
zoe_master.backends.old_swarm.api_client
import
DockerContainerOptions
,
SwarmClient
from
zoe_master.backends.old_swarm
_new_api
.api_client
import
DockerContainerOptions
,
SwarmClient
from
zoe_master.exceptions
import
ZoeStartExecutionRetryException
,
ZoeStartExecutionFatalException
,
ZoeException
import
zoe_master.backends.common
import
zoe_master.backends.base
from
zoe_master.backends.old_swarm.threads
import
SwarmMonitor
,
SwarmStateSynchronizer
from
zoe_master.backends.old_swarm
_new_api
.threads
import
SwarmMonitor
,
SwarmStateSynchronizer
from
zoe_master.stats
import
NodeStats
,
ClusterStats
# pylint: disable=unused-import
log
=
logging
.
getLogger
(
__name__
)
...
...
zoe_master/backends/old_swarm_new_api/threads.py
View file @
ad31af17
...
...
@@ -21,7 +21,7 @@ import time
from
zoe_lib.config
import
get_conf
from
zoe_lib.state
import
SQLManager
,
Service
from
zoe_master.backends.old_swarm.api_client
import
SwarmClient
from
zoe_master.backends.old_swarm
_new_api
.api_client
import
SwarmClient
log
=
logging
.
getLogger
(
__name__
)
...
...
zoe_master/entrypoint.py
View file @
ad31af17
...
...
@@ -18,6 +18,7 @@
"""Zoe Master main entrypoint."""
import
logging
import
os
import
zoe_lib.config
as
config
from
zoe_lib.metrics.influxdb
import
InfluxDBMetricSender
...
...
@@ -28,11 +29,19 @@ import zoe_master.scheduler
import
zoe_master.backends.interface
from
zoe_master.preprocessing
import
restart_resubmit_scheduler
from
zoe_master.master_api
import
APIManager
from
zoe_master.exceptions
import
ZoeException
log
=
logging
.
getLogger
(
"main"
)
LOG_FORMAT
=
'%(asctime)-15s %(levelname)s %(threadName)s->%(name)s: %(message)s'
def
_check_configuration_sanity
():
if
not
os
.
access
(
config
.
get_conf
().
logs_base_path
,
os
.
W_OK
):
log
.
error
(
'Logs directory {} is not writable'
.
format
(
config
.
get_conf
().
logs_base_path
))
return
1
return
0
def
main
():
"""
The entrypoint for the zoe-master script.
...
...
@@ -42,10 +51,13 @@ def main():
args
=
config
.
get_conf
()
if
args
.
debug
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
LOG_FORMAT
)
else
:
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
LOG_FORMAT
)
ret
=
_check_configuration_sanity
()
if
ret
!=
0
:
return
ret
if
config
.
get_conf
().
influxdb_enable
:
metrics
=
InfluxDBMetricSender
(
config
.
get_conf
().
deployment_name
,
config
.
get_conf
().
influxdb_url
,
config
.
get_conf
().
influxdb_dbname
)
else
:
...
...
@@ -57,7 +69,11 @@ def main():
log
.
info
(
"Initializing scheduler"
)
scheduler
=
getattr
(
zoe_master
.
scheduler
,
config
.
get_conf
().
scheduler_class
)(
state
,
config
.
get_conf
().
scheduler_policy
)
zoe_master
.
backends
.
interface
.
initialize_backend
(
state
)
try
:
zoe_master
.
backends
.
interface
.
initialize_backend
(
state
)
except
ZoeException
as
e
:
log
.
error
(
'Cannot initialize backend: {}'
.
format
(
e
.
message
))
return
1
restart_resubmit_scheduler
(
state
,
scheduler
)
...
...
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