-
Notifications
You must be signed in to change notification settings - Fork 56
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
MQTT twin/ topic support for Cumulocity inventory updates #2280
MQTT twin/ topic support for Cumulocity inventory updates #2280
Conversation
Robot Results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be really nice to use this PR for pushing the implementation along docs and tests.
I see two points that really needs to be clarified:
- How this feature is combined with the inventory fragments extracted from
tedge-config
andinventory.json
- The local consolidation of all the fragments. It's a good idea to persist this aggregated view, but I would really avoid to use the former
inventory.json
file for that. We need to be clear what is the source of truth: the persisted view of the inventory must only be edited by the mapper after data collected from the config and over MQTT.
Cumulocity.Set Device ${CHILD_SN} | ||
${mo}= Device Should Have Fragments subtype | ||
Should Be Equal ${mo["subtype"]} LinuxDeviceA | ||
Should Be Equal ${mo["type"]} thin-edge.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have tests along the specs ♥
This one makes me understand why a type
fragment is an issue as already defined by tedge config get device.type
. But, don't we have to address with a broader view these conflicts with legacy features (inventory.json
and tedge config
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inventory.json
contents can be parsed and any direct key-value pairs can be published to the meta/key
topic, with the value
as the payload. The same can be extended to tedge config
as well, where the value
would be just be the plain value instead of a JSON object, as you suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could go the layered approach and first parse the inventory.json file and use that as the base model, and then apply any changes from the MQTT topics. The inventory.json is good for being able to hardcode static information into a build, however we could also just phase the file out (behind a feature flag or something).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reubenmiller So, no need to re-publish the contents of the file as twin
messages to the broker? Without that, the other components relying on the broker for the inventory information will never get that "base model", right? Unless they all parse that file.
db40a8d
to
5a14baa
Compare
Codecov Report
Additional details and impacted files
|
aa63bca
to
f0c96fc
Compare
f0c96fc
to
0aa10cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have to review inventory.rs
. So far things look really nice.
I'm missing doc comments in inventory.rs
though. This makes things a bit harder to understand/check as one has to compare each implementation with its uses.
tests/RobotFramework/tests/cumulocity/telemetry/child_device_telemetry.robot
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like how things are structured, the inventory.json
file being translated into a sequence of twin data messages which are then translated into c8y fragments exactly as any other twin data.
I have some questions about the protected keys (name and type):
- These keys are not protected when read from the
inventory.json
file. c8y_Agent
seems to be the key needing to be protected form override, notname
.
Once these two points clarified, I will be happy to approve.
:::warning | ||
Updating the following properties via the `twin` channel is not supported | ||
|
||
* `name` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the name
property forbidden? Looking at the code, c8y_Agent
is the fragment that must be protected from overriding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name
and type
fields are forbidden here because they're already part of the entity registration message. If someone wants to update these, they must send another registration message with the updated values. Allowing them to update the same data via both these endpoints will might be confusing especially in the broker as we may have different name
and type
in the device registration topic as well as in the twin/...
topics.
I didn't really understand why you think c8y_Agent
must not be overridden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
name
andtype
fields are forbidden here because they're already part of the entity registration message. If someone wants to update these, they must send another registration message with the updated values. Allowing them to update the same data via both these endpoints will might be confusing especially in the broker as we may have differentname
andtype
in the device registration topic as well as in thetwin/...
topics.
Okay
I didn't really understand why you think
c8y_Agent
must not be overridden?
What if a user publish its own fragment on te/device/main///twin/c8y_Agent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if a user publish its own fragment on te/device/main///twin/c8y_Agent
I don't really have a use-case for someone wanting to update that fragment for the thin-edge device, as we set that. But I don't have any strong arguments to close that option either. So, will need @reubenmiller 's advise on this. For child devices, we probably wouldn't want to prevent them from setting it. For services, this fragment probably doesn't even make any sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if a user publish its own fragment on te/device/main///twin/c8y_Agent
I don't really have a use-case for someone wanting to update that fragment for the thin-edge device, as we set that. But I don't have any strong arguments to close that option either. So, will need @reubenmiller 's advise on this. For child devices, we probably wouldn't want to prevent them from setting it. For services, this fragment probably doesn't even make any sense.
Indeed, this would make no sense, but could be done by a user who fails to notice that this is already done by thin-edge as for the type
. I that case there will be inconsistencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Nice feature and implementation!
0a1351f
to
d5f35fc
Compare
Test PlanThe new |
QA has thoroughly checked the feature and here are the results:
|
Proposed changes
PR to communicate the proposed mapping of the
/twin/
topics including integration tests. This PR can be used for the actual implementation.Types of changes
Paste Link to the issue
#2279
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments