Closed jason-e-gross closed 6 years ago
Module identity life cycle is managed by the Edge runtime (specifically the EdgeAgent) when it is deployed on the device. When you remove/add modules in the portal (during the SetModules operation), it simply changes the edgeAgent twin (which contains the deployment), it doesn't actually delete the identities of the modules. Furthermore, if the module was not created by the EdgeAgent (but was created by the user), then it doesn't delete its identity. It is up to the the user to delete its identity.
Did you create the identities of these modules? If not, was EdgeAgent running for this device? And if you did not create the identities of these modules and EdgeAgent was running on the device, can you send us the EdgeAgent logs... that might tell us why it didn't delete the identities of the modules.
The modules were only added and removed through the Azure Iot Hub Portal set modules process. It's code in other places (using registry Manager in a web api to get a list of modules on a device) that is revealing the ghosted modules and their twins.
It seems counter intuitive that we add and remove modules via the portal, but also have to remove them via code to make them REALLY gone. That's a hard disconnect between the two, especially when the ghosted modules twin looks normal and gives no sign that it's not active.
From: Varun Puranik notifications@github.com Sent: Wednesday, June 27, 2018 5:24 PM To: Azure/iot-edge-v1 Cc: jason-e-gross; Author Subject: Re: [Azure/iot-edge-v1] GetModulesOnDeviceAsync and SELECT * from devices.modules Returns Ghosted Modules (#624)
Module identity life cycle is managed by the Edge runtime (specifically the EdgeAgent) when it is deployed on the device. When you remove/add modules in the portal (during the SetModules operation), it simply changes the edgeAgent twin (which contains the deployment), it doesn't actually delete the identities of the modules. Furthermore, if the module was not created by the EdgeAgent (but was created by the user), then it doesn't delete its identity. It is up to the the user to delete its identity.
Did you create the identities of these modules? If not, was EdgeAgent running for this device? And if you did not create the identities of these modules and EdgeAgent was running on the device, can you send us the EdgeAgent logs... that might tell us why it didn't delete the identities of the modules.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Azure/iot-edge-v1/issues/624#issuecomment-400848814, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APvMfLX-3uw2pGOWbq82UGuTmhPAwRkYks5uBAYvgaJpZM4UvY2e.
The idea is that all operations done within the SetModules process affect the "deployment", and not the actual identities. So removing a module there, simply removes it from the deployment. But in any case, thanks for the feedback, we will look at making it clearer and more intuitive.
I will close this issue. If you run into any other issues, feel free to open another one.
OS version and architecture used: ALL
Version used: Latest (1.16.x-preview-004)
Description of the issue:
When Using
registryManager.GetModulesOnDeviceAsync
or.CreateQuery("("SELECT * FROM devices.modules WHERE deviceId='XXXX'")
;They return modules that are no longer on the device. If we add a module, use it for a bit, then remove it (through the Azure Portal) -- the module twin that was removed is still returned with this - even weeks and months later.
The module isn't listed in the $edgeAgent's modules section of reported/desired properties. The module isn't listed in the IOT Edge section for the device in Azure Portal. The module isn't physically on the device's docker container or images - but yet these commands bring its module twin back in the query. For all intents and purposes - this module is no longer part of our system or function - but still comes back in this query, making the queries useless to us -- we can't programmatically iterate through modules on a device and depend on this information.
Imagine deleting a row in a database table, but always getting that row back every time we query the table. That's what this is.
Why would I want to see a module that I added two months ago, removed 1.5 months ago - show up in a query to get me the modules for a device? Of what use is this?
Imagine deleting a row in a database table, but always getting that row back every time we query the table. That's what this is. Why would Microsoft be hanging on and reporting this information, when it's of no use to us.