Skip to content
Snippets Groups Projects
Commit 30b27948 authored by John Chilton's avatar John Chilton
Browse files

Improvements to Kubernetes pod execution stuff.

- Enable logging and make configurable.
- Bump version to 0.12.0.
- Improve error message if pykube isn't installed.
parent 75fe056f
No related branches found
No related tags found
No related merge requests found
...@@ -4,4 +4,4 @@ docker-image: ...@@ -4,4 +4,4 @@ docker-image:
cd ../..; make dist; cp dist/pulsar*whl docker/coexecutor cd ../..; make dist; cp dist/pulsar*whl docker/coexecutor
all: docker-image all: docker-image
docker build -t 'galaxy/pulsar-pod-staging:0.1' . docker build -t 'galaxy/pulsar-pod-staging:0.12.0' .
...@@ -4,6 +4,7 @@ import os ...@@ -4,6 +4,7 @@ import os
from six import string_types from six import string_types
from pulsar.managers.util.pykube_util import ( from pulsar.managers.util.pykube_util import (
ensure_pykube,
Job, Job,
job_object_dict, job_object_dict,
produce_unique_k8s_job_name, produce_unique_k8s_job_name,
...@@ -364,6 +365,7 @@ class MessageCLIJobClient(BaseMessageJobClient): ...@@ -364,6 +365,7 @@ class MessageCLIJobClient(BaseMessageJobClient):
class MessageCoexecutionPodJobClient(BaseMessageJobClient): class MessageCoexecutionPodJobClient(BaseMessageJobClient):
def __init__(self, destination_params, job_id, client_manager): def __init__(self, destination_params, job_id, client_manager):
ensure_pykube()
super(MessageCoexecutionPodJobClient, self).__init__(destination_params, job_id, client_manager) super(MessageCoexecutionPodJobClient, self).__init__(destination_params, job_id, client_manager)
self.pulsar_container_image = destination_params.get("pulsar_container_image", "galaxy/pulsar-pod-staging:0.10.0") self.pulsar_container_image = destination_params.get("pulsar_container_image", "galaxy/pulsar-pod-staging:0.10.0")
self._default_pull_policy = pull_policy(destination_params) self._default_pull_policy = pull_policy(destination_params)
......
...@@ -64,6 +64,42 @@ HELP_DAEMONIZE = "Daemonzie process (requires daemonize library)." ...@@ -64,6 +64,42 @@ HELP_DAEMONIZE = "Daemonzie process (requires daemonize library)."
CONFIG_PREFIX = "PULSAR_CONFIG_" CONFIG_PREFIX = "PULSAR_CONFIG_"
LOGGING_CONFIG_DEFAULT = {
'version': 1,
'root': {
'handlers': ['console'],
'level': 'INFO',
},
'loggers': {
'pulsar': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': 0,
'qualname': 'pulsar',
},
'galaxy': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': 0,
'qualname': 'pulsar',
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'default',
'level': 'DEBUG',
'stream': 'ext://sys.stderr',
},
},
'formatters': {
'default': {
'format': '%(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s'
},
},
}
def load_pulsar_app( def load_pulsar_app(
config_builder, config_builder,
config_env=False, config_env=False,
...@@ -88,7 +124,7 @@ def load_pulsar_app( ...@@ -88,7 +124,7 @@ def load_pulsar_app(
log.exception("Failed to add Pulsar to sys.path") log.exception("Failed to add Pulsar to sys.path")
raise raise
config_builder.setup_logging() config_builder.setup_file_logging()
config = config_builder.load() config = config_builder.load()
config.update(kwds) config.update(kwds)
...@@ -240,6 +276,7 @@ class PulsarConfigBuilder(object): ...@@ -240,6 +276,7 @@ class PulsarConfigBuilder(object):
if self.app_conf_base64: if self.app_conf_base64:
from pulsar.client.util import from_base64_json from pulsar.client.util import from_base64_json
local_conf = from_base64_json(self.app_conf_base64) local_conf = from_base64_json(self.app_conf_base64)
self.setup_dict_logging(local_conf)
load_kwds["local_conf"] = local_conf load_kwds["local_conf"] = local_conf
else: else:
load_kwds.update(dict( load_kwds.update(dict(
...@@ -249,19 +286,24 @@ class PulsarConfigBuilder(object): ...@@ -249,19 +286,24 @@ class PulsarConfigBuilder(object):
)) ))
return load_app_configuration(**load_kwds) return load_app_configuration(**load_kwds)
def setup_logging(self): def setup_file_logging(self):
if not self.ini_path: if self.ini_path:
# TODO: should be possible can configure using dict. raw_config = configparser.ConfigParser()
return raw_config.read([self.ini_path])
raw_config = configparser.ConfigParser() # https://github.com/mozilla-services/chaussette/pull/32/files
raw_config.read([self.ini_path]) if raw_config.has_section('loggers'):
# https://github.com/mozilla-services/chaussette/pull/32/files config_file = os.path.abspath(self.ini_path)
if raw_config.has_section('loggers'): fileConfig(
config_file = os.path.abspath(self.ini_path) config_file,
fileConfig( dict(__file__=config_file, here=os.path.dirname(config_file))
config_file, )
dict(__file__=config_file, here=os.path.dirname(config_file))
) def setup_dict_logging(self, config):
logging_conf = config.get('logging', None)
if logging_conf is None:
# if using the default logging config, honor the log_level setting
logging_conf = LOGGING_CONFIG_DEFAULT
logging.config.dictConfig(logging_conf)
def to_dict(self): def to_dict(self):
return dict( return dict(
......
...@@ -21,7 +21,7 @@ def main(argv=None): ...@@ -21,7 +21,7 @@ def main(argv=None):
ensure_mesos_libs() ensure_mesos_libs()
config_builder = PulsarManagerConfigBuilder(args) config_builder = PulsarManagerConfigBuilder(args)
config_builder.setup_logging() config_builder.setup_file_logging()
config = config_builder.load() config = config_builder.load()
run( run(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment