I’ve got a very similar issue that I could partially fix. I will try to explain it as well as I can, but please let me know if it isn’t clear.
I’m using a Mender Open-Source server, currently on 3.1.0 (I’m pretty sure it appeared when we moved from 3.0.0 to 3.1.0), and use the preautorization workflow since the beginning. At some point (and can’t explain why), some devices I created weren’t able to connect on first try anymore, so it was necessary to decomission them, and manually accept the new pending requests. The problem is, I still have the inventory of the preautorized devices and can’t delete them, even with the Delete Device Inventory API request. It does return a code 204, but I still can get the device inventory.
It’s already an issue, but the real problem is that they share the same serial number I’m using as ID data, and I just realized yesterday that this could prevent some devices to be included in deployment. After I accepted the new devices requests, I do see them as accepted in my GUI, but with the GET List Devices Inventories request, I saw that they missed the “status” attribute.
Using the commands @t-mon provided at the top, I was able to fix the issue for the current devices (thanks a lot btw!), but I’m concerned that this issue might remain for following devices.
I also tried the last commands @peter provided, but it seems that the deletion of my device doesn’t work:
root@mender:~/mender-server.3.1.0/production# echo -ne "use deviceconnect\ndb.devices.deleteMany({\"_id\":\"${device_id}\"})\n" | docker exec -i `docker ps | grep mongo | head -1 | awk '{print($1);}'` mongo
MongoDB shell version v4.4.20
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("6656bac5-628a-4fd1-bcab-7c1e420073e2") }
MongoDB server version: 4.4.20
switched to db deviceconnect
{ "acknowledged" : true, "deletedCount" : 0 }
bye
Any help on that will be very appreciated.
Yoann