bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

InvalidTextualPosition when trying pdbquery remote snapshot #180

Closed PierreR closed 8 years ago

PierreR commented 8 years ago

I have just committed 8c4448168bb9 to fix a parsing problem with the snapshot command. I have now this error:

pdbquery -l puppetdb.sandbox.srv.cirb.lan:8080 -t remote snapshot ~/testdb.yaml
pdbquery: InvalidTextualPosition "null" 0 (-1)

I do have a file testdb.yaml that looks correct but it stops at

    type: Other
    physicalprocessorcount: '2'
    clientversion: '3.8.6'
    serialnumber: VMware-42 14 1 
    blockdevice_sda_vendor: VMware
    ipaddress_lo: '

I don't know why for this specific node I have got this error. Any idea ?

bartavelle commented 8 years ago

Can you reproduce the queries with curl and share that information?

PierreR commented 8 years ago

The error occurs at the facts level (first level facts: yaml key).

Here are more information that could be helpful:

    selinux: 'false'
    is_pe: 'false'
    blockdevice_sda_model: Virtual disk
    typ

The file has 49137 of size and stop at line 1190 (just 10 nodes)

Could it be a memory/lazy loading problem while writing the file ?

Do you think it is really useful to see the curl for the node that fails (curl 'http://puppetdb.sandbox.srv.cirb.lan:8080/v3/nodes/jenkinsmaster.sandbox.srv.cirb.lan/facts/) ?

bartavelle commented 8 years ago

The output is misleading as it probably fails after what is actually written (due to buffering). The actual response from the web server would indeed be useful to debug this ...

This is my public key https://pgp.mit.edu/pks/lookup?op=get&search=0x960CAA9B835FAF50 in case you'd like to share the facts.

PierreR commented 8 years ago

facts.zip Here are three encrypted files:

There should be no secret in these files but it is always nice to play a bit with gpg ;-)

bartavelle commented 8 years ago

jenkinsmaster.curlfacts doesn't look like a list of facts, but like a list of resources

PierreR commented 8 years ago

You're right. This should be right: jenkinsmaster-curlfacts.zip

PierreR commented 8 years ago

I don't understand why I have certname for every key in there but well ...

bartavelle commented 8 years ago

because you can query facts for more than one host

bartavelle commented 8 years ago

This is weird, this is properly read by language puppet, and all facts have string values. What happens if you try the snapshot command with a new puppetdb file ?

bartavelle commented 8 years ago

If it works it means it can't read the testdb file, which either means something changed between versions or that the deserialization code isn't right.

PierreR commented 8 years ago

The first time (deleting testdb.yaml) I have got this error:

~ → pdbquery -l puppetdb.sandbox.srv.cirb.lan:8080 -t remote snapshot ~/testdb.yaml
pdbquery: InvalidTextualPosition "null" 0 (-1)

The produced file is obviously wrong (this is the file I sent with the archive). So the second time it fails with:

# second time
~ → pdbquery -l puppetdb.sandbox.srv.cirb.lan:8080 -t remote snapshot ~/testdb.yaml
pdbquery: puppetdb load Could not parse /home/pierre/testdb.yaml: could not find expected ':' while scanning a simple key at line 1193, column 0
bartavelle commented 8 years ago

I should have checked earlier, but InvalidTextualPosition is a megaparsec error. This isn't a YAML/JSON problem !

bartavelle commented 8 years ago

Does the thing I just pushed help ?

PierreR commented 8 years ago

Nope. It doesn't seem to make any difference.

bartavelle commented 8 years ago

This has something to do with newPos being used with line or column numbers less than 1.

bartavelle commented 8 years ago

There was a brainfart in the previous fix. Must be much better now.

PierreR commented 8 years ago

Great it works ! Thanks.