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

Guidelines for MQTT topics #2030

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

albinsuresh
Copy link
Contributor

@albinsuresh albinsuresh commented Jun 14, 2023

Proposed changes

Guidelines for MQTT topics

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


#2005

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if this PR is still in a draft status, I took the time to read it. Nice reflection.

docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
@albinsuresh albinsuresh marked this pull request as ready for review June 15, 2023 14:45
Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see as a missing requirement what is suggested by this comment #2030 (comment), i.e. the ability to use an MQTT bridge to connect as a child device a device that is running tedge.

About id uniqueness, my feeling is that we are making things more complex than they need and that the registration step is not required (at least to assign unique names). A line of thought is to take the same approach as for names of a file-system: file names are not attached to the files but to the directories and only file inodes have to be unique at the file-system level. If a child-device has 2 grand-child devices, it already has to distinguish them: somehow so the requirements of ids being namespaced are natural. The question could have been to enforce a notion of uniqueness for all recursively attached child devices and services (kind of inodes). But we seem to implicitly agree that we don't want that. It would be good to make it explicit.

docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
@reubenmiller reubenmiller changed the title Guidelines for MQTT topics #2005 Guidelines for MQTT topics Jun 22, 2023
Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a slight preference for proposal 2 as proposal 1 also needs some kind of registration, i.e. add complexities without removing once and for all the main issue.

docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-topic-guidelines.md Outdated Show resolved Hide resolved
@albinsuresh
Copy link
Contributor Author

I have a slight preference for proposal 2 as proposal 1 also needs some kind of registration, i.e. add complexities without removing once and for all the main issue.

The goal was to support auto-registration for majority of the common use-cases involving direct child devices and services only.

And the other key factor is observability as well, as I mentioned above. While looking at a trace of MQTT messages, it'd be far more easier to have some context instead of just random IDs. With just IDs, you always have to lookup into the inventory to differentiate what's what. May be I should list this observability at least as a nice-to-have requirement, if not must-have.

@didier-wenzek
Copy link
Contributor

I have a slight preference for proposal 2 as proposal 1 also needs some kind of registration, i.e. add complexities without removing once and for all the main issue.

The goal was to support auto-registration for majority of the common use-cases involving direct child devices and services only.

And the other key factor is observability as well, as I mentioned above. While looking at a trace of MQTT messages, it'd be far more easier to have some context instead of just random IDs. With just IDs, you always have to lookup into the inventory to differentiate what's what. May be I should list this observability at least as a nice-to-have requirement, if not must-have.

Why random IDs? Proposal 2 can work with user-defined IDs.

And yes observability is key but is not conflicting with the use of an inventory.

docs/src/references/mqtt-api.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-api.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-api.md Outdated Show resolved Hide resolved
Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can only approved this proposal ♥

  • the proposal is crisp, sound and well explained
  • there is clear separation of the user doc from the design rationale.

I still have some questions and I do think that what has been proposed for health checks must be fixed, but these can be addressed easily.

docs/src/references/mqtt-api.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-api.md Outdated Show resolved Hide resolved
docs/src/references/mappers/c8y-mapper.md Show resolved Hide resolved
docs/src/references/mqtt-api.md Show resolved Hide resolved
docs/src/references/mqtt-api.md Outdated Show resolved Hide resolved
docs/src/references/mqtt-api.md Show resolved Hide resolved
docs/src/references/mappers/c8y-mapper.md Outdated Show resolved Hide resolved
docs/src/contribute/design/mqtt-topic-design.md Outdated Show resolved Hide resolved
docs/src/contribute/design/mqtt-topic-design.md Outdated Show resolved Hide resolved
@albinsuresh albinsuresh temporarily deployed to Test Pull Request July 20, 2023 08:28 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
239 0 5 239 100

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.008 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 2.277 s C8Y Child Alarms Rpi
Normal case when the child device already exists 0.813 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 1.778 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 5.482 s C8Y Child Alarms Rpi
Prerequisite Parent 16.522 s Child Conf Mgmt Plugin
Prerequisite Child 0.775 s Child Conf Mgmt Plugin
Child device bootstrapping 16.5 s Child Conf Mgmt Plugin
Snapshot from device 61.066 s Child Conf Mgmt Plugin
Child device config update 62.048 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 47.175 s Inotify Crate
Check lock file existence in default folder 1.5859999999999999 s Lock File
Check PID number in lock file 2.073 s Lock File
Check PID number in lock file after restarting the services 2.848 s Lock File
Check starting same service twice 1.771 s Lock File
Switch off lock file creation 1.988 s Lock File
Set configuration when file exists 7.231 s Configuration Operation
Set configuration when file does not exist 6.982 s Configuration Operation
Set configuration with broken url 5.769 s Configuration Operation
Get configuration 7.552 s Configuration Operation
Get non existent configuration file 5.433 s Configuration Operation
Get non existent configuration type 5.265 s Configuration Operation
Update configuration plugin config via cloud 6.191 s Configuration Operation
Modify configuration plugin config via local filesystem modify inplace 2.251 s Configuration Operation
Modify configuration plugin config via local filesystem overwrite 5.96 s Configuration Operation
Update configuration plugin config via local filesystem copy 4.579 s Configuration Operation
Update configuration plugin config via local filesystem move (different directory) 4.807 s Configuration Operation
Update configuration plugin config via local filesystem move (same directory) 4.349 s Configuration Operation
Update the custom operation dynamically 57.661 s Dynamically Reload Operation
Custom operation successful 125.959 s Custom Operation
Custom operation fails 132.196 s Custom Operation
Successful firmware operation 65.257 s Firmware Operation
Install with empty firmware name 55.725 s Firmware Operation
Prerequisite Parent 19.389 s Firmware Operation Child Device
Prerequisite Child 8.464 s Firmware Operation Child Device
Child device firmware update 6.96 s Firmware Operation Child Device
Child device firmware update with cache 6.506 s Firmware Operation Child Device
Firmware plugin supports restart via service manager #1932 5.997 s Firmware Operation Child Device Retry
Update Inventory data via inventory.json 1.094 s Inventory Update
Inventory includes the agent fragment with version information 0.85 s Inventory Update
Retrieve a JWT tokens 42.978 s Jwt Request
Mapper recovers and processes output of ongoing software update request 17.023 s Recover And Publish Software Update Message
Check running collectd 1.15 s Monitor Device Collectd
Is collectd publishing MQTT messages? 3.154 s Monitor Device Collectd
Check thin-edge monitoring 3.866 s Monitor Device Collectd
Check grouping of measurements 8.798 s Monitor Device Collectd
Main device registration 1.9220000000000002 s Device Registration
Child device registration 2.922 s Device Registration
Supports restarting the device 62.674 s Restart Device
Update tedge version from previous using Cumulocity 86.002 s Tedge Self Update
Test if all c8y services are up 110.816 s Service Monitoring
Test if all c8y services are down 50.809 s Service Monitoring
Test if all c8y services are using configured service type 226.853 s Service Monitoring
Test if all c8y services using default service type when service type configured as empty 94.631 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker stop start 21.803 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker restart 23.214 s Service Monitoring
Check health status of child device service 18.381 s Service Monitoring
Successful shell command with output 3.932 s Shell Operation
Check Successful shell command with literal double quotes output 3.601 s Shell Operation
Execute multiline shell command 3.498 s Shell Operation
Failed shell command 3.502 s Shell Operation
Software list should be populated during startup 42.201 s Software
Install software via Cumulocity 47.84 s Software
tedge-agent should terminate on SIGINT while downloading file 45.065 s Software
Software list should only show currently installed software and not candidates 39.064 s Software
Create and publish the tedge agent supported operations on mapper restart 42.997 s Mapper-Publishing-Agent-Supported-Ops
Agent gets the software list request once it comes up 36.044 s Mapper-Publishing-Agent-Supported-Ops
Child devices support sending simple measurements 1.5899999999999999 s Child Device Telemetry
Child devices support sending custom measurements 1.32 s Child Device Telemetry
Child devices support sending custom events 1.2610000000000001 s Child Device Telemetry
Child devices support sending custom events overriding the type 1.361 s Child Device Telemetry
Child devices support sending custom alarms #1699 1.337 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 1.176 s Child Device Telemetry
Child device supports sending custom child device measurements directly to c8y 1.728 s Child Device Telemetry
Check retained alarms 163.263 s Raise Alarms
Thin-edge devices support sending simple measurements 1.442 s Thin-Edge Device Telemetry
Thin-edge devices support sending simple measurements with custom type 1.018 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom measurements 1.099 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events 1.295 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events overriding the type 1.421 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom alarms #1699 1.314 s Thin-Edge Device Telemetry
Thin-edge device supports sending custom Thin-edge device measurements directly to c8y 1.758 s Thin-Edge Device Telemetry
Thin-edge device support sending inventory data via c8y topic 1.583 s Thin-Edge Device Telemetry
thin-edge components support a custom config-dir location via flags 27.057 s Config Dir
Validate updated data path used by tedge-agent 0.271 s Data Path Config
Validate updated data path used by c8y-firmware-plugin 10.419 s Data Path Config
Validate updated data path used by tedge-agent 0.593 s Log Path Config
Check existence of init directories 0.623 s Tedge Init
Tedge init and check creation of folders 0.776 s Tedge Init
Check ownership of the folders 0.895 s Tedge Init
Change user/group and check the change 0.969 s Tedge Init
Tedge init and check if default values are restored 1.049 s Tedge Init
Install thin-edge via apt 49.193 s Install Apt
Install latest via script (from current branch) 29.384 s Install Tedge
Install specific version via script (from current branch) 25.339 s Install Tedge
Install latest tedge via script (from main branch) 28.208 s Install Tedge
Install then uninstall latest tedge via script (from main branch) 64.989 s Install Tedge
Support starting and stopping services 42.023 s Service-Control
Supports a reconnect 55.599 s Test-Commands
Supports disconnect then connect 39.76 s Test-Commands
Update unknown setting 37.682 s Test-Commands
Update known setting 36.263 s Test-Commands
It checks MQTT messages using a pattern 71.663 s Test-Mqtt
Stop c8y-configuration-plugin 0.278 s Health C8Y-Configuration-Plugin
Update the service file 0.113 s Health C8Y-Configuration-Plugin
Reload systemd files 0.53 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.26 s Health C8Y-Configuration-Plugin
Start watchdog service 10.372 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.147 s Health C8Y-Configuration-Plugin
Kill the PID 0.278 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 6.45 s Health C8Y-Configuration-Plugin
Compare PID change 0.001 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.143 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.12 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 0.12 s Health C8Y-Log-Plugin
Update the service file 0.123 s Health C8Y-Log-Plugin
Reload systemd files 0.323 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.171 s Health C8Y-Log-Plugin
Start watchdog service 10.189 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.145 s Health C8Y-Log-Plugin
Kill the PID 0.361 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 6.643 s Health C8Y-Log-Plugin
Compare PID change 0.001 s Health C8Y-Log-Plugin
Stop watchdog service 0.109 s Health C8Y-Log-Plugin
Remove entry from service file 0.101 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.14 s Health Tedge Mapper C8Y
Update the service file 0.088 s Health Tedge Mapper C8Y
Reload systemd files 0.342 s Health Tedge Mapper C8Y
Start tedge-mapper 0.195 s Health Tedge Mapper C8Y
Start watchdog service 10.125 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.249 s Health Tedge Mapper C8Y
Kill the PID 0.398 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 6.535 s Health Tedge Mapper C8Y
Compare PID change 0.001 s Health Tedge Mapper C8Y
Stop watchdog service 0.17 s Health Tedge Mapper C8Y
Remove entry from service file 0.292 s Health Tedge Mapper C8Y
Stop tedge-agent 0.283 s Health Tedge-Agent
Update the service file 0.225 s Health Tedge-Agent
Reload systemd files 0.357 s Health Tedge-Agent
Start tedge-agent 0.115 s Health Tedge-Agent
Start watchdog service 10.212 s Health Tedge-Agent
Check PID of tedge-mapper 0.198 s Health Tedge-Agent
Kill the PID 0.352 s Health Tedge-Agent
Recheck PID of tedge-agent 6.718 s Health Tedge-Agent
Compare PID change 0.001 s Health Tedge-Agent
Stop watchdog service 0.199 s Health Tedge-Agent
Remove entry from service file 0.375 s Health Tedge-Agent
Stop tedge-mapper-az 0.166 s Health Tedge-Mapper-Az
Update the service file 0.141 s Health Tedge-Mapper-Az
Reload systemd files 0.686 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.16 s Health Tedge-Mapper-Az
Start watchdog service 10.277 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.153 s Health Tedge-Mapper-Az
Kill the PID 0.263 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 6.559 s Health Tedge-Mapper-Az
Compare PID change 0.001 s Health Tedge-Mapper-Az
Stop watchdog service 0.113 s Health Tedge-Mapper-Az
Remove entry from service file 0.126 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.136 s Health Tedge-Mapper-Collectd
Update the service file 0.144 s Health Tedge-Mapper-Collectd
Reload systemd files 0.553 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.234 s Health Tedge-Mapper-Collectd
Start watchdog service 10.181 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.17 s Health Tedge-Mapper-Collectd
Kill the PID 0.384 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 6.708 s Health Tedge-Mapper-Collectd
Compare PID change 0.002 s Health Tedge-Mapper-Collectd
Stop watchdog service 0.397 s Health Tedge-Mapper-Collectd
Remove entry from service file 0.139 s Health Tedge-Mapper-Collectd
tedge-collectd-mapper health status 5.803 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.48 s MQTT health endpoints
c8y-configuration-plugin health status 5.779 s MQTT health endpoints
Publish on a local insecure broker 0.478 s Basic Pub Sub
Publish on a local secure broker 2.934 s Basic Pub Sub
Publish on a local secure broker with client authentication 2.464 s Basic Pub Sub
Publish events to subscribed topic 0.204 s Custom Sub Topics Tedge-Mapper-Aws
Publish measurements to unsubscribed topic 5.561 s Custom Sub Topics Tedge-Mapper-Aws
Publish measurements to subscribed topic 0.734 s Custom Sub Topics Tedge-Mapper-Az
Publish measurements to unsubscribed topic 5.507 s Custom Sub Topics Tedge-Mapper-Az
Publish events to subscribed topic 0.564 s Custom Sub Topics Tedge-Mapper-C8Y
Publish measurements to unsubscribed topic 5.425 s Custom Sub Topics Tedge-Mapper-C8Y
Check remote mqtt broker #1773 5.2 s Remote Mqtt Broker
Apply name filter 0.105 s Filter Packages List Output
Apply maintainer filter 0.135 s Filter Packages List Output
Apply both filters 0.142 s Filter Packages List Output
No filters 0.152 s Filter Packages List Output
Both filters but name filter as empty string 0.112 s Filter Packages List Output
Both filters but maintainer filter as empty string 0.143 s Filter Packages List Output
Both filters as empty string 0.164 s Filter Packages List Output
Wrong package name 0.085 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.129 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.214 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.318 s Tedge Connect Test
tedge_connect_test_negative 0.997 s Tedge Connect Test
tedge_connect_test_sm_services 8.032 s Tedge Connect Test
tedge_disconnect_test_sm_services 0.678 s Tedge Connect Test
Install thin-edge.io 22.891 s Call Tedge
call tedge -V 0.072 s Call Tedge
call tedge -h 0.086 s Call Tedge
call tedge -h -V 0.114 s Call Tedge
call tedge help 0.105 s Call Tedge
tedge config list 0.167 s Call Tedge Config List
tedge config list --all 0.091 s Call Tedge Config List
set/unset device.type 0.462 s Call Tedge Config List
set/unset device.key_path 0.623 s Call Tedge Config List
set/unset device.cert_path 0.376 s Call Tedge Config List
set/unset c8y.root_cert_path 0.406 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.521 s Call Tedge Config List
set/unset c8y.topics 0.488 s Call Tedge Config List
set/unset az.root_cert_path 0.425 s Call Tedge Config List
set/unset az.topics 0.406 s Call Tedge Config List
set/unset aws.topics 0.316 s Call Tedge Config List
set/unset aws.url 0.46 s Call Tedge Config List
set/unset aws.root_cert_path 0.542 s Call Tedge Config List
set/unset aws.mapper.timestamp 0.279 s Call Tedge Config List
set/unset az.mapper.timestamp 0.253 s Call Tedge Config List
set/unset mqtt.bind.address 0.271 s Call Tedge Config List
set/unset mqtt.bind.port 0.32 s Call Tedge Config List
set/unset http.bind.port 0.262 s Call Tedge Config List
set/unset tmp.path 0.263 s Call Tedge Config List
set/unset logs.path 0.254 s Call Tedge Config List
set/unset run.path 0.242 s Call Tedge Config List
set/unset firmware.child.update.timeout 0.245 s Call Tedge Config List
set/unset c8y.url 0.254 s Call Tedge Config List
set/unset az.url 0.274 s Call Tedge Config List
set/unset mqtt.external.bind.port 0.273 s Call Tedge Config List
mqtt.external.bind.address 0.249 s Call Tedge Config List
mqtt.external.bind.interface 0.251 s Call Tedge Config List
set/unset mqtt.external.ca_path 0.232 s Call Tedge Config List
set/unset mqtt.external.cert_file 0.261 s Call Tedge Config List
set/unset mqtt.external.key_file 0.237 s Call Tedge Config List
set/unset software.plugin.default 0.318 s Call Tedge Config List
Get Put Delete 1.835 s Http File Transfer Api
Set keys should return value on stdout 0.124 s Tedge Config Get
Unset keys should not return anything on stdout and warnings on stderr 0.208 s Tedge Config Get
Invalid keys should not return anything on stdout and warnings on stderr 0.268 s Tedge Config Get
Set configuration via environment variables 0.814 s Tedge Config Get
Set configuration via environment variables for topics 0.415 s Tedge Config Get
Set unknown configuration via environment variables 0.103 s Tedge Config Get

Copy link
Contributor

@reubenmiller reubenmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

During implementation, any minor modifications will be made in the related PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants