TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
975 stars 306 forks source link

Clean up component registries when applications got deleted #14

Closed johanstokking closed 2 years ago

johanstokking commented 5 years ago

Summary:

When an application is deleted from IS, the NS and AS registries should delete the application and associated devices.

Steps to Reproduce:

  1. User deletes application
  2. AS deletes all devices and deletes application

What do you see now?

Application gets deleted but devices stay there.

What do you want to see instead?

Devices be gone.

How do you propose to implement this?

An asynchronous garbage collection process in the NS and AS that deletes stale applications and its devices. This does not require an event stream, or even worse a connection, from IS to NS/AS, but rather have them be a client and check periodically if the applications are still there. This means that, as long as the garbage process has not run, unique device identifiers (i.e. JoinEUI, DevEUI) remain in the database, making it impossible to register a new device with the same identifiers.


Original issue: https://github.com/TheThingsIndustries/lorawan-stack/issues/740 by @johanstokking

nejraselimovic commented 3 years ago

@johanstokking I tried creating an end device in the Console, deleting it, then re-adding it with the identical info, and I encountered no issues. Does this mean this issue isn't relevant anymore?

KrishnaIyer commented 3 years ago

I tried creating an end device in the Console, deleting it, then re-adding it with the identical info, and I encountered no issues.

That's because the console takes care of also deleting the device in the NS and AS at the same time as the IS iirc. This is still possible to do via the CLI or our API so I don't think this is already covered.

johanstokking commented 3 years ago

@nejraselimovic the end device delete and add with same identifiers works already indeed.

This issue is about deleting an application in the IS, and not having that deletion propagated to AS, NS and JS. These components then still hold unique identifiers (like DevEUI), that cannot be managed anymore because the application and its security context is gone from IS.

I'm reassigning this to @pgalic96 because he has been working on purging entities, which is a related topic.

NicolasMrad commented 3 years ago

https://discuss.thethingsindustries.com/t/design-document-for-application-data-garbage-control/613