puppetlabs / puppetlabs-pe_status_check

Self Service Module for Puppet Enterprise
Apache License 2.0
1 stars 32 forks source link

agent_state_summary plan - null report_timestamp for node(s) fails the plan #236

Open taikaa opened 1 month ago

taikaa commented 1 month ago

Describe the Bug

If a node returned in the PuppetDB query has a null report_timestamp, the plan fails at line 23

Plan output

{
  "msg" : "The function 'new_timestamp' was called with arguments it does not accept. It expects one of:\n  ()\n    rejected: expects no arguments, got 1\n  (Variant[Integer, Float] seconds)\n    rejected: parameter 'seconds' expects a value of type Integer or Float, got Undef\n  (String[1] string, Formats = Variant[String[2], Array[String[2], 1]] format?, String[1] timezone?)\n    rejected: parameter 'string' expects a String value, got Undef\n  (Struct[{'string' => String[1], Optional['format'] => Formats, Optional['timezone'] => String[1]}] hash_arg)\n    rejected: parameter 'hash_arg' expects a Struct value, got Undef",
  "kind" : "bolt/pal-error",
  "details" : {
    "file" : "/opt/puppetlabs/server/data/orchestration-services/code/environments/production/modules/pe_status_check/plans/agent_state_summary.pp",
    "line" : 23,
    "column" : 30
  }
}

Expected Behavior

A node with a null report_timestamp shouldn't fail the plan. Since the plan operationalizes unhealthy nodes as "latest reports that are older than runinterval", the node's with a null report_timestamp can be added to the unhealthy list.

Steps to Reproduce

Provision a node and request a cert. Submit a node entry to PuppetDB without submitting a report

puppet ssl submit_request
puppet ssl download_cert
puppet facts upload

Query PuppetDB to confirm that report_timestamp is null

puppet query nodes[certname,report_timestamp]{}

Then, run the plan pe_status_check::agent_state_summary

Environment

Additional Context

Another edge case that would result in a null report_timestamp is if a resource that contains a null byte preventing PuppetDB from ever storing a report from a node

MartyEwings commented 1 month ago

@bastelfreak --^

bastelfreak commented 1 month ago

ah nice, I will try to take a look this week.

bastelfreak commented 1 month ago

@taikaa thanks for using the plan. Great to see that other can benefit from it. I raised https://github.com/puppetlabs/puppetlabs-pe_status_check/pull/238 , can you maybe test it?