feat: c8y-mapper sends all supported operations on-demand via signal channel#3761
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
|
I know this is still in draft, but the |
docs/src/references/mqtt-api.md
Outdated
| | <signal_type> | Signal type. Each signal can define its own payload schema to allow signals to have parameters related to the signal's function. | | ||
| | <action> | Action for the signal type. e.g. `check` | |
There was a problem hiding this comment.
I'm wondering if two levels: signal_type and action are necessary or one would have been sufficient. From the examples listed below it makes sense. But I also feel that semantically config_type/check could have been modelled as config_check as well. But yeah, no harm keeping 2 levels and it might even open up further extension possibilities in future.
There was a problem hiding this comment.
In a sense, the action is similar to a command's "id", e.g.
| Type | Example Topic |
|---|---|
| Command | /cmd/firmware_update/c8y-1234 |
| Signal | /sig/config_type/check |
There was a problem hiding this comment.
Updated the design in 8f28b06. Now only one level after signal.
| Ok(vec![]) | ||
| } | ||
|
|
||
| Channel::Signal { signal_type } => self.process_signal_message(&source, signal_type), |
There was a problem hiding this comment.
Is the mapper the correct place to implement this?
When playing with the feature, I was expecting to see all the capabilities published on the te/# topics.
Then I noticed that sig/operations/check was sent to device/main/service/tedge-mapper-c8y and that only c8y/# capabilities were published. Okay, that can make senses. However, I would expect capabilities to be also published when the signal is sent to device/main// or device/main/service/tedge-agent.
There was a problem hiding this comment.
Yes, I think publishing the capabilities locally makes sense, otherwise it will be very difficult for other clients to know what signals are supported by variables devices/services...though such capabilities don't necessarily have to be published to the cloud.
There was a problem hiding this comment.
To focus on the initial scope (#3738), I keep the implementation only in tedge-mapper-c8y level. If we have concrete usecases that requires the signal channel support in tedge-agent, I'm happy to extend it.
Robot Results
|
didier-wenzek
left a comment
There was a problem hiding this comment.
I will be happy to approve this PR. I just have some questions and minor comments.
| self.supported_operations | ||
| .load_all(external_id, &self.config.bridge_config)?; |
There was a problem hiding this comment.
Curious. Why do we need the bridge config to load supported operations?
There was a problem hiding this comment.
It seems just to get c8y_prefix eventually. Since the usage is very nested, so if you want refactoring, better to do in a separated PR.
There was a problem hiding this comment.
That's okay for now. However, this how unrelated things are slowly more and more coupled. The config should be extended with a method giving the operation directory. Being the scene, the c8y_prefix used by the bridge can be used to infer the name of that directory.
crates/extensions/c8y_mapper_ext/src/supported_operations/mod.rs
Outdated
Show resolved
Hide resolved
didier-wenzek
left a comment
There was a problem hiding this comment.
Approved with one question.
What is missing to complete thin-edge/thin-edge.io-roadmap#101 and easy tenant migration. Operations can be now resent to the tenant. Do we need to do the same for twin data? log types ? sw types ? config types?
Also:
- The branch name is unrelated to the new PR. It would be nice to fix that.
f593c4b to
34c8dbc
Compare
|
@rina23q I'm wondering if we really need the level of control over which parts of synced...For example, we could call the signal "sync" and just keep extending what parts are synced...otherwise if we have individual signals for sync_operations, sync_logs, sync_configs, sync_twin, then it becomes annoying to use, as the main use-case is when migrating a device between two Cumulocity tenants, and you want to make sure the new tenant receives all of the device data after the migration. |
@reubenmiller I can rename it. How about |
|
Renamed to |
86dbfeb to
11082cd
Compare
...tFramework/tests/cumulocity/supported_operations/mapper-publishing-agent-supported-ops.robot
Outdated
Show resolved
Hide resolved
reubenmiller
left a comment
There was a problem hiding this comment.
Approved. I only pushed some very minor doc changes.
Once we extend the scope of the "sync" signal, we'll need to make sure we update the docs accordingly to say that it syncs more than just the supported operations to cumulocity (e.g. twin data etc.)
1ac3136 to
ee20a69
Compare
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
…channel Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
ee20a69 to
4cc7191
Compare
Proposed changes
This PR introduces
signal, a new MQTT API channel for stateless requests.This channel allows users to instruct
tedge-mapper-c8yto republish all supported operations to the c8y tenant on-demand, without needing to restart any services.Example usage:
Request:
tedge mqtt pub te/device/main/service/tedge-mapper-c8y/signal/sync '{}'Response:
Tasks:
/etc/tedge/c8y/) and converted to114.114for main and child devices, which is triggered by the MQTT API new endpointsignal(signal).Future plan
sync_config,sync_log)Types of changes
Paste Link to the issue
#3738
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments