Browse Source

Merge "Improve error logging during validation"

changes/17/688517/1
Zuul 3 years ago committed by Gerrit Code Review
parent
commit
b7d4b12116
  1. 12
      python/drydock_provisioner/orchestrator/orchestrator.py
  2. 22
      python/drydock_provisioner/orchestrator/validations/platform_selection.py
  3. 12
      python/drydock_provisioner/orchestrator/validations/validators.py

12
python/drydock_provisioner/orchestrator/orchestrator.py

@ -259,8 +259,6 @@ class Orchestrator(object):
Given a fully populated Site model, compute the effective
design by applying inheritance and references
"""
node_failed = []
try:
nodes = site_design.baremetal_nodes
for n in nodes or []:
@ -270,13 +268,9 @@ class Orchestrator(object):
state_manager=self.state_manager,
resolve_aliases=resolve_aliases)
except Exception as ex:
node_failed.append(n)
self.logger.debug(
"Failed to build applied model for node %s.", n.name, exc_info=ex)
if node_failed:
raise errors.DesignError(
"Failed to build applied model for %s" % ",".join(
[x.name for x in node_failed]))
raise ex
except AttributeError:
self.logger.debug(
"Model inheritance skipped, no node definitions in site design."
@ -653,8 +647,8 @@ class Orchestrator(object):
for n in site_design.networks:
if n.routedomain is not None:
if n.routedomain not in routedomains:
self.logger.info("Adding routedomain %s to render map."
% n.routedomain)
self.logger.debug("Adding routedomain %s to render map."
% n.routedomain)
routedomains[n.routedomain] = list()
routedomains[n.routedomain].append(n)
for rd, nl in routedomains.items():

22
python/drydock_provisioner/orchestrator/validations/platform_selection.py

@ -36,12 +36,30 @@ class PlatformSelection(Validators):
)
return
valid_images = node_driver.get_available_images()
try:
valid_images = node_driver.get_available_images()
except Exception:
msg = ("Platform validation: Could not load images from driver, skipping"
"image and kernel selection validation.")
self.report_warn(
msg, [],
"Cannot validate platform selection without accessing the node provisioner."
)
return
valid_kernels = dict()
for i in valid_images:
valid_kernels[i] = node_driver.get_available_kernels(i)
try:
valid_kernels[i] = node_driver.get_available_kernels(i)
except Exception:
msg = ("Platform validation: Could not load kernels from driver, skipping"
"image and kernel selection validation.")
self.report_warn(
msg, [],
"Cannot validate platform selection without accessing the node provisioner."
)
return
node_list = site_design.baremetal_nodes or []

12
python/drydock_provisioner/orchestrator/validations/validators.py

@ -13,15 +13,24 @@
# limitations under the License.
"""Business Logic Validation"""
import logging
from drydock_provisioner import objects
from drydock_provisioner.objects import fields as hd_fields
import drydock_provisioner.config as config
class Validators:
def __init__(self, long_name, name):
self.name = name
self.long_name = long_name
self.reset_message_list()
try:
logger_name = config.config_mgr.conf.logging.global_logger_name
except Exception:
logger_name = "drydock"
self.logger = logging.getLogger(logger_name)
def report_msg(self, msg, docs, diagnostic, error, level):
"""Add a validation message to the result list.
@ -43,14 +52,17 @@ class Validators:
self.messages.append(msg_obj)
def report_error(self, msg, docs, diagnostic):
self.logger.info("Design Validation Error: %s", msg)
self.report_msg(msg, docs, diagnostic, True,
hd_fields.MessageLevels.ERROR)
def report_warn(self, msg, docs, diagnostic):
self.logger.info("Design Validation Error: %s", msg)
self.report_msg(msg, docs, diagnostic, False,
hd_fields.MessageLevels.WARN)
def report_info(self, msg, docs, diagnostic):
self.logger.debug("Design Validation Info: %s", msg)
self.report_msg(msg, docs, diagnostic, False,
hd_fields.MessageLevels.INFO)

Loading…
Cancel
Save