Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate entity deletions to Cumulocity cloud #3340

Open
albinsuresh opened this issue Jan 20, 2025 · 2 comments
Open

Propagate entity deletions to Cumulocity cloud #3340

albinsuresh opened this issue Jan 20, 2025 · 2 comments
Labels
idea ideas/opportunities/feature requests which need to be further investigated before implementation

Comments

@albinsuresh
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When an entity is deleted from the entity store of the agent, the mapper reacts to this by removing the corresponding entry from its entity cache. But, the same is not propagated to the cloud to delete the twin of that entity from the cloud as well. This leaves the burden of the cleanup from the cloud to the user. It would have been better if a deletion from the thin-edge entity store is properly synced with the cloud as well, so that the users don't have to do this manually.

Describe the solution you'd like

The mapper needs to map the entity clear message that it receives to the REST call to delete the corresponding managed object from Cumulocity.

To avoid the user from accidentally deleting entities from the cloud when they clear local state, propagation of these deletions must be controlled by a tedge config setting(e.g: c8y.sync.inventory.delete: true or false) which the user must explicitly enable (default: false).

Additional context

We're forced to use the HTTP API for deletions because deletion of managed objects from the inventory is not supported over MQTT, neither with SmartREST and not even with JSON over MQTT as documented here.

On top of that, the managed object deletion API expects the numeric internal id of the managed object as the input and not the external id. So, an additional lookup would be required to fetch the internal id using the external id.

@albinsuresh albinsuresh added the idea ideas/opportunities/feature requests which need to be further investigated before implementation label Jan 20, 2025
@didier-wenzek
Copy link
Contributor

To avoid the user from accidentally deleting entities from the cloud when they clear local state, propagation of these deletions must be controlled by a tedge config setting(e.g: c8y.sync.inventory.delete: true or false) which the user must explicitly enable (default: false).

Using a flag seems fragile: what about all the entities that have been removed while the flag was turned off. Will they be cleared on c8y when synchronization is turned on?

I would rather go with an on-demand synchronization command. This will lead to less surprises and will give more flexibility to the user.

@albinsuresh
Copy link
Contributor Author

Using a flag seems fragile: what about all the entities that have been removed while the flag was turned off. Will they be cleared on c8y when synchronization is turned on?

I would rather go with an on-demand synchronization command. This will lead to less surprises and will give more flexibility to the user.

I have a feeling that a combination of both would be the right solution. I fully appreciate the need for an on-demand synchronization command for the reasons that you highlighted. But, having to trigger a command every time after an entity deletion also would be cumbersome for a user that prefers to have his twins deleted synchronously as-and-when they delete the entities locally.

So I'd still keep the flag to control the behaviour when the mapper is live while performing the deletion and use the command when someone wants to do some extensive changes post which they'd like to synchronize the whole entity tree at once.

@reubenmiller Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea ideas/opportunities/feature requests which need to be further investigated before implementation
Projects
None yet
Development

No branches or pull requests

2 participants