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

Issue #1724 Derive actor configs from TEdgeConfig #1745

Conversation

albinsuresh
Copy link
Contributor

@albinsuresh albinsuresh commented Feb 23, 2023

Proposed changes

Derive actor configs from TEdgeConfig

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

#1724

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

@@ -77,3 +89,12 @@ async fn main() -> anyhow::Result<()> {
runtime.run_to_completion().await?;
Ok(())
}

fn mqtt_config(tedge_config: &TEdgeConfig) -> Result<MqttConfig, TEdgeConfigError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of this function, I'd have preferred something like TryFrom<&TEdgeConfig> for MqttConifg but the compiler was not letting me do that with the error: error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate.

The other option would have been either:

  • Introduce a concrete wrapper impl for MqttConifg and implement the TryFrom for that type
  • Implement the TryFrom for the mqtt_channel::Config itself. But, for that I need to make the mqtt_channel crate depend on the tedge_config crate as well, which didn't seem like a good idea.

Since both were additional work for little benefit, I chose this path. But happy to fall back to either approach if you prefer one of those as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with that.

A 3rd alternative is to TryFrom<&TEdgeConfig> for MqttConfig in the tedge_config crate. This would add many dependencies to tedge_config but I see those less problematic.

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 will approve. Just run cargo +nightly fmt

Comment on lines -7 to -9
#[derive(Clone, Debug, Default)]
pub struct HttpConfig {}

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree to remove this for now, even if this might be useful later. Indeed, the plan was here to set options such as pool_idle_timeout

@@ -77,3 +89,12 @@ async fn main() -> anyhow::Result<()> {
runtime.run_to_completion().await?;
Ok(())
}

fn mqtt_config(tedge_config: &TEdgeConfig) -> Result<MqttConfig, TEdgeConfigError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with that.

A 3rd alternative is to TryFrom<&TEdgeConfig> for MqttConfig in the tedge_config crate. This would add many dependencies to tedge_config but I see those less problematic.

@albinsuresh albinsuresh force-pushed the issue/1724/actor-configs-from-tedge-config branch from 9cc8705 to 88c014a Compare February 23, 2023 11:48
@albinsuresh albinsuresh temporarily deployed to Test Pull Request February 23, 2023 11:55 — with GitHub Actions Inactive
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.

Approved

@github-actions
Copy link
Contributor

Robot Results

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

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.039 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 4.638 s C8Y Child Alarms Rpi
Normal case when the child device already exists 1.138 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 1.963 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 6.395 s C8Y Child Alarms Rpi
Prerequisite Parent 21.565 s Child Conf Mgmt Plugin
Prerequisite Child 0.305 s Child Conf Mgmt Plugin
Child device bootstrapping 17.049 s Child Conf Mgmt Plugin
Snapshot from device 20.633 s Child Conf Mgmt Plugin
Child device config update 17.374 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 95.928 s Inotify Crate
Child devices support sending simple measurements 95.167 s Child Device Telemetry
Child devices support sending custom measurements 51.61 s Child Device Telemetry
Child devices support sending custom events 45.05 s Child Device Telemetry
Child devices support sending custom events overriding the type 44.246 s Child Device Telemetry
Child devices support sending custom alarms #1699 54.738 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 24.504 s Child Device Telemetry
Main device support sending inventory data via c8y topic 24.236 s Child Device Telemetry
Successful firmware operation 115.302 s Firmware Operation
Install with empty firmware name 56.228 s Firmware Operation
Supports restarting the device 132.495 s Restart Device
Update tedge version from previous using Cumulocity 50.815 s Tedge Self Update
Successful shell command with output 4.052 s Shell Operation
Check Successful shell command with literal double quotes output 3.5629999999999997 s Shell Operation
Execute multiline shell command 3.456 s Shell Operation
Failed shell command 3.287 s Shell Operation
Software list should be populated during startup 103.276 s Software
Install software via Cumulocity 87.727 s Software
Software list should only show currently installed software and not candidates 44.863 s Software
Stop tedge-agent service 1.019 s Log Path Config
Customize the log path 0.359 s Log Path Config
Initialize tedge-agent 0.343 s Log Path Config
Check created folders 0.233 s Log Path Config
Remove created custom folders 0.174 s Log Path Config
Install latest via script (from current branch) 36.49 s Install Tedge
Install specific version via script (from current branch) 18.386 s Install Tedge
Install latest tedge via script (from main branch) 29.97 s Install Tedge
Support starting and stopping services 47.948 s Service-Control
Supports a reconnect 63.875 s Test-Commands
Supports disconnect then connect 58.689 s Test-Commands
Update unknown setting 32.985 s Test-Commands
Update known setting 28.221 s Test-Commands
Stop c8y-configuration-plugin 0.152 s Health C8Y-Configuration-Plugin
Update the service file 0.242 s Health C8Y-Configuration-Plugin
Reload systemd files 0.863 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.242 s Health C8Y-Configuration-Plugin
Start watchdog service 10.379 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.136 s Health C8Y-Configuration-Plugin
Kill the PID 0.174 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 2.221 s Health C8Y-Configuration-Plugin
Compare PID change 0.001 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.168 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.129 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 0.252 s Health C8Y-Log-Plugin
Update the service file 0.209 s Health C8Y-Log-Plugin
Reload systemd files 0.761 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.208 s Health C8Y-Log-Plugin
Start watchdog service 10.185 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.141 s Health C8Y-Log-Plugin
Kill the PID 0.208 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 2.404 s Health C8Y-Log-Plugin
Compare PID change 0.001 s Health C8Y-Log-Plugin
Stop watchdog service 0.303 s Health C8Y-Log-Plugin
Remove entry from service file 0.153 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.25 s Health Tedge Mapper C8Y
Update the service file 0.211 s Health Tedge Mapper C8Y
Reload systemd files 0.781 s Health Tedge Mapper C8Y
Start tedge-mapper 0.212 s Health Tedge Mapper C8Y
Start watchdog service 10.443 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.239 s Health Tedge Mapper C8Y
Kill the PID 0.391 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 2.5300000000000002 s Health Tedge Mapper C8Y
Compare PID change 0.002 s Health Tedge Mapper C8Y
Stop watchdog service 0.27 s Health Tedge Mapper C8Y
Remove entry from service file 0.392 s Health Tedge Mapper C8Y
Stop tedge-agent 0.324 s Health Tedge-Agent
Update the service file 0.203 s Health Tedge-Agent
Reload systemd files 0.868 s Health Tedge-Agent
Start tedge-agent 0.172 s Health Tedge-Agent
Start watchdog service 10.509 s Health Tedge-Agent
Check PID of tedge-mapper 0.103 s Health Tedge-Agent
Kill the PID 0.13 s Health Tedge-Agent
Recheck PID of tedge-agent 2.176 s Health Tedge-Agent
Compare PID change 0.001 s Health Tedge-Agent
Stop watchdog service 0.069 s Health Tedge-Agent
Remove entry from service file 0.072 s Health Tedge-Agent
Stop tedge-mapper-az 0.093 s Health Tedge-Mapper-Az
Update the service file 0.126 s Health Tedge-Mapper-Az
Reload systemd files 0.763 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.157 s Health Tedge-Mapper-Az
Start watchdog service 10.176 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.198 s Health Tedge-Mapper-Az
Kill the PID 0.238 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 2.2640000000000002 s Health Tedge-Mapper-Az
Compare PID change 0.001 s Health Tedge-Mapper-Az
Stop watchdog service 0.249 s Health Tedge-Mapper-Az
Remove entry from service file 0.15 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.149 s Health Tedge-Mapper-Collectd
Update the service file 0.092 s Health Tedge-Mapper-Collectd
Reload systemd files 0.354 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.113 s Health Tedge-Mapper-Collectd
Start watchdog service 10.157 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.115 s Health Tedge-Mapper-Collectd
Kill the PID 0.204 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 2.255 s Health Tedge-Mapper-Collectd
Compare PID change 0.001 s Health Tedge-Mapper-Collectd
Stop watchdog service 0.142 s Health Tedge-Mapper-Collectd
Remove entry from service file 0.145 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.865 s MQTT health endpoints
c8y-configuration-plugin health status 5.949 s MQTT health endpoints
Wrong package name 0.319 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.281 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.601 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.71 s Tedge Connect Test
tedge_connect_test_negative 2.36 s Tedge Connect Test
tedge_connect_test_sm_services 10.358 s Tedge Connect Test
tedge_disconnect_test_sm_services 1.671 s Tedge Connect Test
Install thin-edge.io 12.927 s Call Tedge
call tedge -V 0.094 s Call Tedge
call tedge -h 0.083 s Call Tedge
call tedge -h -V 0.135 s Call Tedge
call tedge help 0.108 s Call Tedge
tedge config list 0.128 s Call Tedge Config List
tedge config list --all 0.141 s Call Tedge Config List
set/unset device.type 0.693 s Call Tedge Config List
set/unset device.key.path 0.738 s Call Tedge Config List
set/unset device.cert.path 0.781 s Call Tedge Config List
set/unset c8y.root.cert.path 0.871 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.724 s Call Tedge Config List
set/unset az.root.cert.path 0.569 s Call Tedge Config List
set/unset az.mapper.timestamp 0.718 s Call Tedge Config List
set/unset mqtt.bind_address 0.725 s Call Tedge Config List
set/unset mqtt.port 0.362 s Call Tedge Config List
set/unset tmp.path 0.277 s Call Tedge Config List
set/unset logs.path 0.384 s Call Tedge Config List
set/unset run.path 0.342 s Call Tedge Config List
Get Put Delete 4.452 s Http File Transfer Api

@albinsuresh albinsuresh merged commit 6fcb0f6 into thin-edge:main Feb 23, 2023
@albinsuresh albinsuresh deleted the issue/1724/actor-configs-from-tedge-config branch March 8, 2023 09:42
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

2 participants