Skip to content

deregistering an entity does not clear all related retained MQTT messages #3492

Closed
@reubenmiller

Description

@reubenmiller

Describe the bug

De-registering a child device via the entity store HTTP API does not clean up all of the related MQTT topics, for example, below shows that the name and type digital twin properties are still present:

tedge mqtt sub 'te/device/child01/service/custom-app/#'
[te/device/child01/service/custom-app/twin/name] "custom-app"
[te/device/child01/service/custom-app/twin/type] "custom-type"

The bug was found whilst trying to refactor the tests/RobotFramework/tests/cumulocity/registration/registration_lifecycle.robot test to use the deregistration API instead of manually clearing MQTT messages.

To Reproduce

  1. Register a child device

    tedge mqtt pub --retain 'te/device/child01//' '{"@type":"child-device","name":"${CHILD_SN}","type":"linux-device-Aböut"}'
  2. Register a service of the child device

    tedge mqtt pub --retain 'te/device/child01/service/custom-app' '{"@type":"service","@parent":"device/child01//","name":"custom-app","type":"custom-type"}'
  3. De-register the service via the HTTP API

    tedge http delete /tedge/entity-store/v1/entities/device/child01/service/custom-app

Expected behavior

After a service is deregistered (~1-2 seconds after), then all MQTT messages related to that service should no longer be stored as retained messages on the broker.

tedge mqtt sub 'te/device/child01/service/custom-app/#'

Screenshots

Environment (please complete the following information):

Property Value
OS [incl. version] Debian GNU/Linux 12 (bookworm)
Hardware [incl. revision] unknown
System-Architecture Linux b4c8b1418fda 6.8.0-39-generic #39-Ubuntu SMP PREEMPT_DYNAMIC Sat Jul 6 02:50:39 UTC 2024 aarch64 GNU/Linux
thin-edge.io version tedge 1.4.3~316+gaa844f8

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtheme:entity_storeEntity store related functionalitytheme:mqttTheme: mqtt and mosquitto related topics

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions