Raise an error for empty plan
If the execution graph that solar-worker retrieves from db is empty, ValueError is raised (it's handled by zerorpc executor). Additionally, db string used for db connection is logged on start of solar-worker. Change-Id: I2acafec0e94c0d2792b34d0485415782eae1b9dd Closes-bug:1545813
This commit is contained in:
parent
ec71d71d6a
commit
72876bf215
@ -55,6 +55,7 @@ def construct_tasks(extensions, clients):
|
||||
def main():
|
||||
# NOTE(mkwiek): no arguments should be supplied to solar-worker
|
||||
argparse.ArgumentParser().parse_args()
|
||||
log.info('Database in use: {}'.format(C.solar_db))
|
||||
runner = loader.get_runner(C.runner)
|
||||
constructors = loader.get_constructors()
|
||||
clients = loader.get_clients()
|
||||
|
@ -51,6 +51,8 @@ class Scheduler(base.Worker):
|
||||
):
|
||||
log.debug('Received *next* event for %s', plan_uid)
|
||||
plan = graph.get_graph(plan_uid)
|
||||
if len(plan) == 0:
|
||||
raise ValueError('Plan {} is empty'.format(plan_uid))
|
||||
rst = self._next(plan)
|
||||
for task_name in rst:
|
||||
self._do_scheduling(plan, task_name)
|
||||
|
23
solar/test/orchestration/test_scheduler.py
Normal file
23
solar/test/orchestration/test_scheduler.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright 2016 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import pytest
|
||||
|
||||
from solar.orchestration.workers.scheduler import Scheduler
|
||||
|
||||
|
||||
def test_scheduler_next_fails_with_empty_plan():
|
||||
scheduler = Scheduler(None)
|
||||
with pytest.raises(ValueError):
|
||||
scheduler.next({}, 'nonexistent_uid')
|
Loading…
x
Reference in New Issue
Block a user