Jira (PDB-5350) puppet-query for null fact returns empty set

2 views
Skip to first unread message

Hugh Brown (Jira)

unread,
Oct 27, 2021, 7:27:02 PM10/27/21
to puppe...@googlegroups.com
Hugh Brown created an issue
 
PuppetDB / Bug PDB-5350
puppet-query for null fact returns empty set
Issue Type: Bug Bug
Assignee: Unassigned
Components: PuppetDB
Created: 2021/10/27 4:26 PM
Priority: Low Low
Reporter: Hugh Brown

Puppet Version: 6.24.0
Puppet Server Version: PE 2019.8.8
OS Name/Version: Fedora 33

I'm running puppet-query to get a list of systems that do not have a fact set

`puppet-query inventory[certname] { facts.my_external_fact is null }`

and it returns an empty set.

If I switch to:
`puppet-query inventory[certname] { facts.my_external_fact is not null }`

it returns the list of systems that have the fact defined.

Describe steps to reproduce: Create an external fact on a subset of systems on a primary server. Query puppetdb using puppet-query for systems for which the fact is null.

Desired Behavior:
The number of systems returned by `facts.my_external_fact is not null ` and `facts.my_external_fact is null` should total up to all systems.

Actual Behavior:
The query for `facts.my_external_fact is null ` returns an empty set

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Nate McCurdy (Jira)

unread,
Oct 27, 2021, 7:31:02 PM10/27/21
to puppe...@googlegroups.com
Nate McCurdy commented on Bug PDB-5350
 
Re: puppet-query for null fact returns empty set

To extend this question a bit:

  • What PQL query should we use to search for nodes that do not contain a given fact?
  • Is that fundamentally different than searching for nodes with a fact whose value is undef (in Puppet)?

Romain Tartière

unread,
Oct 27, 2021, 7:45:03 PM10/27/21
to puppe...@googlegroups.com

Same bogus behavior on Puppet 7 AIO package on Debian 11:

romain@optiplex-3050 ~ % puppet query 'inventory[certname] {}' | jq length                    
67
romain@optiplex-3050 ~ % puppet query 'inventory[certname] { facts.odoo is null }' | jq length
0
romain@optiplex-3050 ~ % puppet query 'inventory[certname] { facts.odoo is not null }' | jq length
10

I would expect the second command to return the 57 nodes that do not have this fact (number of nodes with fact (10) + number of nodes without fact (57) == total number of nodes (67)).

Workaround: "find nodes which are not in the list of nodes that do not have this fact not set"

romain@optiplex-3050 ~ % puppet query 'inventory[certname] { ! certname in inventory[certname] {  facts.odoo is not null } }' | jq length
57

Austin Blatt (Jira)

unread,
Nov 3, 2021, 12:53:06 PM11/3/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages