And see how many records should be affected. You can exit that shell and run:
mongo --ssl -u ${agent} -p $pw --authenticationDatabase admin --sslAllowInvalidHostnames --sslAllowInvalidCertificates localhost:37017/juju --eval 'db.charms.find({}).pretty()' > all_records.txt
To get a complete list of all charm records. And
mongo --ssl -u ${agent} -p $pw --authenticationDatabase admin --sslAllowInvalidHostnames --sslAllowInvalidCertificates localhost:37017/juju --eval 'db.charms.find({"meta": null}).pretty()' > null_records.txt
Which will update the records with a nil meta to one with an empty meta, avoiding the nil pointer dereference.
You should see a line like:
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 })
Where the nModified matches the count() from earlier.
We have a potential workaround for people impacted by this bug.
SSH to the controller machine and get access to Mongo:
agent=$(cd /var/lib/ juju/agents; echo machine-*) juju/agents/ ${agent} /agent. conf | cut '-d ' -sf2)
pw=$(sudo grep statepassword /var/lib/
mongo --ssl -u ${agent} -p $pw --authenticatio nDatabase admin --sslAllowInval idHostnames --sslAllowInval idCertificates localhost: 37017/juju
If you are in an HA controller, you will want to determine which machine is the Mongo Primary (it will have a prompt of:
juju:PRIMARY>
if you already are, and
juju:SECONDARY>
if you are not.
You can use
rs.status()
And look for the
"members": [
with "stateStr" of "PRIMARY", eg:
From there you can run:
db.charms. find({meta: null}).count()
And see how many records should be affected. You can exit that shell and run: nDatabase admin --sslAllowInval idHostnames --sslAllowInval idCertificates localhost: 37017/juju --eval 'db.charms. find({} ).pretty( )' > all_records.txt
mongo --ssl -u ${agent} -p $pw --authenticatio
To get a complete list of all charm records. And nDatabase admin --sslAllowInval idHostnames --sslAllowInval idCertificates localhost: 37017/juju --eval 'db.charms. find({" meta": null}).pretty()' > null_records.txt
mongo --ssl -u ${agent} -p $pw --authenticatio
To get just the null records.
And then nDatabase admin --sslAllowInval idHostnames --sslAllowInval idCertificates localhost: 37017/juju --eval 'db.charms. update( {meta: null}, { $set: {"meta": {}} }, false, true)'
mongo --ssl -u ${agent} -p $pw --authenticatio
Which will update the records with a nil meta to one with an empty meta, avoiding the nil pointer dereference.
You should see a line like:
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 })
Where the nModified matches the count() from earlier.