Skip to content

Extra json on mongo output causing provider 'mongodb': 783: unexpected token at '{ #680

@xepa

Description

@xepa

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.26.0
  • Ruby: 2.7.8p225
  • Distribution: ubuntu
  • Module version: master

How to reproduce (e.g Puppet code you use)

we are running this on an established mongodb instance,

What are you seeing

running any /usr/bin/mongo command cli returns an extra json line, this is related to SERVER-78540 it would seem and was fixed in 4.x and 6.x but not yet in 5.x (running 5.0.21 atm)

output of command will result in something like

{"t":{"$date":"2023-09-12T06:33:42.971Z"},"s":"I",  "c":"NETWORK",  "id":5490002, "ctx":"thread4","msg":"Started a new thread for the timer service"}
{
  "databases" : [
    {
      "name" : "admin",
      "sizeOnDisk" : NumberLong(184320),
      "empty" : false
    },
    {
      "name" : "config",
      "sizeOnDisk" : NumberLong(110592),
      "empty" : false
    },
    {
      "name" : "local",
      "sizeOnDisk" : NumberLong(81920),
      "empty" : false
    }
  ],
  "totalSize" : NumberLong(1261928448),
  "totalSizeMb" : NumberLong(1203),
  "ok" : 1
}

Error will be something like

Error: Could not prefetch mongodb_database provider 'mongodb': 783: unexpected token at '{

What behaviour did you expect instead

In my opinion this extra line should be removed in lib/puppet/util/mongodb_output.rb

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions