So, looking at the database export, there's a document missing from the resources collection. This is why the attach-resource CLI code is failing with the not found error.
For each resource, there should be at least 2 records in the "resources" collection
eg
For the "nw-health" application and "tools" resource, the second record above has been deleted according to the db export. I could not reproduce how this happened. I bootstrapped a 2.4.7 controller and deployed ubuntu hw-health etc and upgraded to 2.9.32. No issues.
I did manage to see the same symptoms if I manually deleted the relevant resource record.
A quick fix here might just be to replace the missing record. Open a mongodb shell
juju:PRIMARY> var new_doc = db.resources.findOne({_id: '12fb71bc-4e18-47f8-898d-ab608eefcc41:resource#hw-health/tools#charmstore'})
juju:PRIMARY> new_doc._id='12fb71bc-4e18-47f8-898d-ab608eefcc41:resource#hw-health/tools'
juju:PRIMARY> db.resources.insert(new_doc)
So, looking at the database export, there's a document missing from the resources collection. This is why the attach-resource CLI code is failing with the not found error.
For each resource, there should be at least 2 records in the "resources" collection
eg
"_id" : "12fb71bc- 4e18-47f8- 898d-ab608eefcc 41:resource# hw-health/ tools#charmstor e"
and
"_id" : "12fb71bc- 4e18-47f8- 898d-ab608eefcc 41:resource# hw-health/ tools"
For the "nw-health" application and "tools" resource, the second record above has been deleted according to the db export. I could not reproduce how this happened. I bootstrapped a 2.4.7 controller and deployed ubuntu hw-health etc and upgraded to 2.9.32. No issues.
I did manage to see the same symptoms if I manually deleted the relevant resource record.
A quick fix here might just be to replace the missing record. Open a mongodb shell
juju:PRIMARY> var new_doc = db.resources. findOne( {_id: '12fb71bc- 4e18-47f8- 898d-ab608eefcc 41:resource# hw-health/ tools#charmstor e'}) _id='12fb71bc- 4e18-47f8- 898d-ab608eefcc 41:resource# hw-health/ tools' insert( new_doc)
juju:PRIMARY> new_doc.
juju:PRIMARY> db.resources.