Jira (PDB-5070) Determine query that provides (dotted) factpaths

14 views
Skip to first unread message

Eric Thompson (Jira)

unread,
Mar 24, 2021, 2:32:03 PM3/24/21
to puppe...@googlegroups.com
Eric Thompson created an issue
 
PuppetDB / Task PDB-5070
Determine query that provides (dotted) factpaths
Issue Type: Task Task
Assignee: Unassigned
Created: 2021/03/24 11:31 AM
Priority: Normal Normal
Reporter: Eric Thompson
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Nick Walker (Jira)

unread,
Mar 25, 2021, 12:13:04 PM3/25/21
to puppe...@googlegroups.com
Nick Walker updated an issue
Change By: Nick Walker
Facter 4 auto-converts facts with dots in the *name* to make it a structured fact.

So {code}foo.bar = true{code} becomes {code}foo = { bar => true }{code}

However, you can still have dots in keys inside of a structured fact so

{code} baz = { zzz.yyy => true } {code} does not change in facter 4 because keys inside of a structured fact can contain dots without getting auto-converted.  Only the top level name of a fact is auto-converted when it contains dots.  

Nick Walker (Jira)

unread,
Mar 25, 2021, 12:15:04 PM3/25/21
to puppe...@googlegroups.com
Nick Walker updated an issue
h1.  Background

Facter 4 auto-converts facts with dots in the *name* to make it a structured fact.

So {code}foo.bar = true{code} becomes {code}foo = { bar => true }{code}

However, you can still have dots in keys inside of a structured fact so

{code} baz = { zzz.yyy => true } {code} does not change in facter 4 because keys inside of a structured fact can contain dots without getting auto-converted.  Only the top level name of a fact is auto-converted when it contains dots.
  

h1.  What we need to do
We need to construct a pdb query that can determine if customers currently have facts with dots in the name of the fact but not worry about keys inside of a structured fact.  

This is so we can find cases where users with puppet < 7 will be affected by this change and can prepare appropriately because they know they are affected.
  

Austin Blatt (Jira)

unread,
Mar 25, 2021, 2:29:04 PM3/25/21
to puppe...@googlegroups.com

Austin Blatt (Jira)

unread,
Mar 25, 2021, 2:32:03 PM3/25/21
to puppe...@googlegroups.com
Austin Blatt commented on Task PDB-5070
 
Re: Determine query that provides (dotted) factpaths

I believe the query that can identify any top-level dotted fact names is

curl -X POST http://localhost:8080/pdb/query/v4/fact-names \
  -H 'Content-Type:application/json' \
  -d '{"query": ["~", "name", ".*\\..*"]}'

The exact escaping needed to make that . match only a . may differ based on where the POST is originating. From the command line my first attempt with a sngle backslash produced the error

Json parse error at line 1, column 30:
 
{"query": ["~", "name", ".*\..*"]}
                            ^
 
Unrecognized character escape '.' (code 46)

Austin Blatt (Jira)

unread,
Mar 26, 2021, 12:43:03 PM3/26/21
to puppe...@googlegroups.com
Austin Blatt updated an issue
 
Change By: Austin Blatt
Fix Version/s: PDB n/a
Release Notes: Not Needed

Josh Cooper (Jira)

unread,
Apr 2, 2021, 1:08:03 AM4/2/21
to puppe...@googlegroups.com
Josh Cooper commented on Task PDB-5070
 
Re: Determine query that provides (dotted) factpaths

Facter 3 creates core legacy facts where part of the name can include network interface names, block devices, etc so those need to be filtered out as well. For posterity, the query I came up with is:

{
  "query":
  ["and",
    ["~", "name", ".*\\..*"],
    ["not",
      ["or",
        ["~", "name", "^blockdevice_.+_(model|size|vendor)"],
        ["~", "name", "^(ipaddress|macaddress|mtu|netmask|network)_"],
        ["~", "name", "^(ipaddress|macaddress|netmask|network|scope)6_"],
        ["~", "name", "^sp_"],
        ["~", "name", "^zone_.+_(brand|iptype|name|uuid|id|path|status)"]
      ]
    ]
  ]
}

The one liner version of that is:

$ curl -s -X POST http://localhost:8080/pdb/query/v4/fact-names -H 'Content-Type:application/json' -d '{"query":["and",["~","name",".*\\..*"],["not",["or",["~","name","^blockdevice_.+_(model|size|vendor)"],["~","name","^(ipaddress|macaddress|mtu|netmask|network)_"],["~","name","^(ipaddress|macaddress|netmask|network|scope)6_"],["~","name","^sp_"],["~","name","^zone_.+_(brand|iptype|name|uuid|id|path|status)"]]]]}'

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages