From c425694d9f4d5f924427cb91b6854f35045a07b9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 30 Sep 2024 16:13:32 +0200 Subject: [PATCH] (#236) agent_state_summary: Check if cached_catalog_status is null The attribute `cached_catalog_status` on the `/nodes` endpoint will be `null` for nodes without a catalog in PuppetDB: ``` puppet query 'nodes[certname,latest_report_noop,latest_report_corrective_change,cached_catalog_status,latest_report_status,report_timestamp]{}' ``` ``` [ { "cached_catalog_status": null, "certname": "pe2.tim.betadots.training", "latest_report_corrective_change": null, "latest_report_noop": null, "latest_report_status": null, "report_timestamp": null } ] ``` --- plans/agent_state_summary.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plans/agent_state_summary.pp b/plans/agent_state_summary.pp index d964dd3f..260a3eb8 100644 --- a/plans/agent_state_summary.pp +++ b/plans/agent_state_summary.pp @@ -36,7 +36,8 @@ $corrective_changes = $nodes.map |$node| { if ($node['latest_report_corrective_change'] == true){ $node['certname'] } }.filter |$node| { $node =~ NotUndef } # all nodes that used a cached catalog on the last run - $used_cached_catalog = $nodes.map |$node| { if ($node['cached_catalog_status'] != 'not_used'){ $node['certname'] } }.filter |$node| { $node =~ NotUndef } + # explicitly check if `cached_catalog_status` is set, will be null on nodes without a catalog + $used_cached_catalog = $nodes.map |$node| { if ($node['cached_catalog_status'] and $node['cached_catalog_status'] != 'not_used'){ $node['certname'] } }.filter |$node| { $node =~ NotUndef } # all nodes with failed resources in the last report $failed = $nodes.map |$node| { if ($node['latest_report_status'] == 'failed'){ $node['certname'] } }.filter |$node| { $node =~ NotUndef }