From 9a235da568c35faaddb76ece0ecab789e00f2bb4 Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Thu, 9 Nov 2023 14:17:25 +0100 Subject: [PATCH] Tolerate newer metrics yaml file Signed-off-by: Andreas Maier --- docs/changes.rst | 4 ++++ zhmc_prometheus_exporter/zhmc_prometheus_exporter.py | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 418135de..fcf409a2 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -32,6 +32,10 @@ Released: not yet **Enhancements:** +* Tolerated when unknown 'resource' types are specified in the metrics.yaml + file, because one possible reason for that is that a newer metrics.yaml file + is being used. (issue #379) + **Cleanup:** **Known issues:** diff --git a/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py b/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py index c9477bed..0c412147 100755 --- a/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py +++ b/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py @@ -673,12 +673,11 @@ def create_metrics_context(session, yaml_metric_groups, hmc_version): continue # skip this LPAR resources[metric_group].append(lpar) else: - new_exc = ImproperExit( - "Invalid 'resource' item in resource metric group {} in " - "metrics file: {}". - format(metric_group, resource_path)) - new_exc.__cause__ = None # pylint: disable=invalid-name - raise new_exc + logprint(logging.ERROR, PRINT_ALWAYS, + "Ignoring invalid 'resource' item {rp!r} in resource " + "metric group {mg!r} in metrics file (Is the metrics file " + "newer than the exporter program?)". + format(rp=resource_path, mg=metric_group)) return context, resources