dalen / puppet-puppetdbquery

Query functions for PuppetDB
Apache License 2.0
197 stars 69 forks source link

query report_timestamp from cli not working #81

Closed jimr6007 closed 8 years ago

jimr6007 commented 8 years ago

puppet query nodes '#node.report_timestamp < @"2 hours ago"' --debug

gives the following ....

Debug: /File[/etc/puppetlabs/code/environments/production]: Adding autorequire relationship with File[/etc/puppetlabs/code] Debug: Finishing transaction 37459200 Debug: #PuppetDB::Connection:0x00000002e56e90: PuppetDB query: ["extract",["certname"],["in","certname",["extract","certname",["select_nodes",["<","report_timestamp","2015-12-14T03:43:12+00:00"]]]]] Debug: Creating new connection for https://puppet.nym1.placeiq.net:8081

so that looks fine but I actually get zero results when I should get 5 nodes returned.

One reason I know I should see 5 nodes returned is because this:

node.report_timestamp<@"now - 2 hours"

via Puppet Explorer, returns 5 nodes, as expected.

I stopped my pupperserver and with just puppetdb running and puppetdb's logging set to debug, I tried this query again and the results of that are attached.

Can you tell by looking at that if something is getting "lost in translation"?

puppetdb.log.txt

dalen commented 8 years ago

It seems like new versions of PuppetDB only handles dates where timezone is specified as Z, not +00:00 which ISO-8601 also allows. This is likely a upstream regression. But I fixed so puppetdbquery emits datetimes in that format instead and released 2.1.1 with the fix.

jimr6007 commented 8 years ago

works... awesome, thanks !!