Skip to content

feat: c8y-mapper sends all supported operations on-demand via signal channel#3761

Merged
rina23q merged 4 commits intothin-edge:mainfrom
rina23q:improve/3738/tedge-mapper-c8y-can-reload-supported-opetation-by-option
Sep 16, 2025
Merged

feat: c8y-mapper sends all supported operations on-demand via signal channel#3761
rina23q merged 4 commits intothin-edge:mainfrom
rina23q:improve/3738/tedge-mapper-c8y-can-reload-supported-opetation-by-option

Conversation

@rina23q
Copy link
Copy Markdown
Member

@rina23q rina23q commented Aug 15, 2025

Proposed changes

This PR introduces signal, a new MQTT API channel for stateless requests.
This channel allows users to instruct tedge-mapper-c8y to 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:

[c8y/s/us] 114,c8y_Command,c8y_DeviceProfile,c8y_DownloadConfigFile,c8y_LogfileRequest,c8y_RemoteAccessConnect,c8y_Restart,c8y_SoftwareUpdate,c8y_UploadConfigFile
[c8y/s/us/rina0010:device:child01] 114,c8y_LogfileRequest,c8y_Restart
[c8y/s/us/rina0010:device:child02] 114,c8y_Restart

Tasks:

  • Supported operations for child devices can be loaded from the operation directory (/etc/tedge/c8y/) and converted to 114.
  • Re-publishing 114 for main and child devices, which is triggered by the MQTT API new endpoint signal (signal).
  • Adding docs accordingly.
  • Adding a test.

Future plan

  • Expand the support for other signal types (sync_config, sync_log)

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

#3738

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check 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

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 83.11688% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/core/tedge_api/src/mqtt_topics.rs 51.21% 20 Missing ⚠️
crates/extensions/c8y_mapper_ext/src/config.rs 0.00% 2 Missing ⚠️
crates/extensions/c8y_mapper_ext/src/converter.rs 85.71% 0 Missing and 2 partials ⚠️
crates/extensions/c8y_mapper_ext/src/signals.rs 89.47% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reubenmiller
Copy link
Copy Markdown
Contributor

I know this is still in draft, but the tedge-mapper c8y --no-cache might be difficult given that users generally don't start the mapper themselves, it is typically done via tedge reconnect c8y (or the service just starts). And given that generally you'd just want the mapper to ignore (delete?) the cache for once, it makes it impractical for users to coordinate.

Comment on lines +682 to +683
| <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` |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller Aug 28, 2025

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated the design in 8f28b06. Now only one level after signal.

Ok(vec![])
}

Channel::Signal { signal_type } => self.process_signal_message(&source, signal_type),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller Aug 29, 2025

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@didier-wenzek didier-wenzek mentioned this pull request Sep 3, 2025
19 tasks
@rina23q rina23q temporarily deployed to Test Pull Request September 3, 2025 11:22 — with GitHub Actions Inactive
@rina23q rina23q changed the title feat: c8y-mapper sends child supported operations from cache at startup feat: c8y-mapper sends all supported operations on-demand via signal channel Sep 3, 2025
@rina23q rina23q marked this pull request as ready for review September 3, 2025 11:34
@rina23q rina23q requested review from a team and jarhodes314 as code owners September 3, 2025 11:34
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 3, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
693 0 3 693 100 2h7m37.405634s

Copy link
Copy Markdown
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 will be happy to approve this PR. I just have some questions and minor comments.

Comment on lines +1415 to +1450
self.supported_operations
.load_all(external_id, &self.config.bridge_config)?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious. Why do we need the bridge config to load supported operations?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
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.

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.

@rina23q rina23q closed this Sep 4, 2025
@rina23q rina23q force-pushed the improve/3738/tedge-mapper-c8y-can-reload-supported-opetation-by-option branch from f593c4b to 34c8dbc Compare September 5, 2025 12:52
@rina23q rina23q temporarily deployed to Test Pull Request September 5, 2025 12:52 — with GitHub Actions Inactive
@reubenmiller
Copy link
Copy Markdown
Contributor

@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.

@rina23q
Copy link
Copy Markdown
Member Author

rina23q commented Sep 10, 2025

@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 sync_twins? Then probably easier to extend the actions what mapper does in the future.

@rina23q
Copy link
Copy Markdown
Member Author

rina23q commented Sep 10, 2025

Renamed to sync in 11082cd

@rina23q rina23q force-pushed the improve/3738/tedge-mapper-c8y-can-reload-supported-opetation-by-option branch from 86dbfeb to 11082cd Compare September 10, 2025 13:29
@rina23q rina23q temporarily deployed to Test Pull Request September 10, 2025 13:29 — with GitHub Actions Inactive
Copy link
Copy Markdown
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. 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.)

@reubenmiller reubenmiller added the theme:c8y Theme: Cumulocity related topics label Sep 16, 2025
@rina23q rina23q force-pushed the improve/3738/tedge-mapper-c8y-can-reload-supported-opetation-by-option branch from 1ac3136 to ee20a69 Compare September 16, 2025 11:19
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>
@rina23q rina23q force-pushed the improve/3738/tedge-mapper-c8y-can-reload-supported-opetation-by-option branch from ee20a69 to 4cc7191 Compare September 16, 2025 11:20
@rina23q rina23q temporarily deployed to Test Pull Request September 16, 2025 11:20 — with GitHub Actions Inactive
@rina23q rina23q added this pull request to the merge queue Sep 16, 2025
Merged via the queue into thin-edge:main with commit 1e34d53 Sep 16, 2025
34 checks passed
@rina23q rina23q deleted the improve/3738/tedge-mapper-c8y-can-reload-supported-opetation-by-option branch September 16, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:c8y Theme: Cumulocity related topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants