Better organize the source file structure of the build manager and change it to choose a lifecycle manager based on the config

This commit is contained in:
Joseph Schorr 2014-11-25 16:14:44 -05:00
parent c48559ee3d
commit 660a640de6
12 changed files with 34 additions and 20 deletions

View file

@ -1,4 +1,3 @@
import argparse
import logging import logging
from app import app, userfiles as user_files, build_logs, dockerfile_build_queue from app import app, userfiles as user_files, build_logs, dockerfile_build_queue
@ -8,13 +7,23 @@ from buildman.server import BuilderServer
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
if __name__ == '__main__': BUILD_MANAGERS = {
logging.basicConfig(level=logging.DEBUG) 'enterprise': EnterpriseManager
}
parser = argparse.ArgumentParser() def run_build_manager():
parser.add_argument('--host', type=str, default='127.0.0.1', help='Host IP.') build_manager_config = app.config.get('BUILD_MANAGER')
args = parser.parse_args() if build_manager_config is None:
return
manager_klass = BUILD_MANAGERS.get(build_manager_config[0])
if manager_klass is None:
return
server = BuilderServer(app.config['SERVER_HOSTNAME'], dockerfile_build_queue, build_logs, server = BuilderServer(app.config['SERVER_HOSTNAME'], dockerfile_build_queue, build_logs,
user_files, EnterpriseManager) user_files, manager_klass)
server.run(args.host) server.run('0.0.0.0')
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
run_build_manager()

View file

View file

@ -8,11 +8,11 @@ import re
from autobahn.wamp.exception import ApplicationError from autobahn.wamp.exception import ApplicationError
from trollius.coroutines import From from trollius.coroutines import From
from buildman.basecomponent import BaseComponent
from buildman.buildpack import BuildPackage, BuildPackageException
from buildman.buildstatus import StatusHandler
from buildman.server import BuildJobResult from buildman.server import BuildJobResult
from buildman.workererror import WorkerError from buildman.component.basecomponent import BaseComponent
from buildman.jobutil.buildpack import BuildPackage, BuildPackageException
from buildman.jobutil.buildstatus import StatusHandler
from buildman.jobutil.workererror import WorkerError
from data.database import BUILD_PHASE from data.database import BUILD_PHASE

View file

View file

@ -1,9 +1,9 @@
import logging import logging
import uuid import uuid
from buildman.component.basecomponent import BaseComponent
from buildman.component.buildcomponent import BuildComponent
from buildman.manager.basemanager import BaseManager from buildman.manager.basemanager import BaseManager
from buildman.basecomponent import BaseComponent
from buildman.buildcomponent import BuildComponent
from trollius.coroutines import From from trollius.coroutines import From

View file

@ -11,7 +11,7 @@ from threading import Event
from trollius.coroutines import From from trollius.coroutines import From
from datetime import datetime, timedelta from datetime import datetime, timedelta
from buildman.buildjob import BuildJob, BuildJobLoadException from buildman.jobutil.buildjob import BuildJob, BuildJobLoadException
from data.queue import WorkQueue from data.queue import WorkQueue
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
@ -21,6 +21,9 @@ TIMEOUT_PERIOD_MINUTES = 20
JOB_TIMEOUT_SECONDS = 300 JOB_TIMEOUT_SECONDS = 300
MINIMUM_JOB_EXTENSION = timedelta(minutes=2) MINIMUM_JOB_EXTENSION = timedelta(minutes=2)
WEBSOCKET_PORT = 8080
CONTROLLER_PORT = 8181
class BuildJobResult(object): class BuildJobResult(object):
""" Build job result enum """ """ Build job result enum """
INCOMPLETE = 'incomplete' INCOMPLETE = 'incomplete'
@ -166,8 +169,8 @@ class BuilderServer(object):
transport_factory.setProtocolOptions(failByDrop=True) transport_factory.setProtocolOptions(failByDrop=True)
# Initialize the controller server and the WAMP server # Initialize the controller server and the WAMP server
create_wsgi_server(self._controller_app, loop=loop, host=host, port=8181) create_wsgi_server(self._controller_app, loop=loop, host=host, port=CONTROLLER_PORT)
yield From(loop.create_server(transport_factory, host, 8080)) yield From(loop.create_server(transport_factory, host, WEBSOCKET_PORT))
# Initialize the work queue checker. # Initialize the work queue checker.
yield From(self._work_checker()) yield From(self._work_checker())

View file

@ -49,9 +49,9 @@ class DefaultConfig(object):
REGISTRY_TITLE = 'Quay.io' REGISTRY_TITLE = 'Quay.io'
REGISTRY_TITLE_SHORT = 'Quay.io' REGISTRY_TITLE_SHORT = 'Quay.io'
CONTACT_INFO = [ CONTACT_INFO = [
'mailto:support@quay.io', 'mailto:support@quay.io',
'irc://chat.freenode.net:6665/quayio', 'irc://chat.freenode.net:6665/quayio',
'tel:+1-888-930-3475', 'tel:+1-888-930-3475',
'https://twitter.com/quayio', 'https://twitter.com/quayio',
] ]
@ -160,6 +160,8 @@ class DefaultConfig(object):
# Feature Flag: Whether users can be created (by non-super users). # Feature Flag: Whether users can be created (by non-super users).
FEATURE_USER_CREATION = True FEATURE_USER_CREATION = True
BUILD_MANAGER = ('enterprise', {})
DISTRIBUTED_STORAGE_CONFIG = { DISTRIBUTED_STORAGE_CONFIG = {
'local_eu': ['LocalStorage', {'storage_path': 'test/data/registry/eu'}], 'local_eu': ['LocalStorage', {'storage_path': 'test/data/registry/eu'}],
'local_us': ['LocalStorage', {'storage_path': 'test/data/registry/us'}], 'local_us': ['LocalStorage', {'storage_path': 'test/data/registry/us'}],