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

extend error message for chown function #1930

Merged
merged 1 commit into from
Apr 28, 2023

Conversation

Ruadhri17
Copy link
Contributor

Proposed changes

Small improvement to the error messages created by tedge init commands that was mentioned in #1795. Issue only happened when we wanted to change the owner/group of the file. The problem was with chown that handled errors by itself but did not provide any information about directory, file etc.

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

#1795

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

@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request April 26, 2023 10:38 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Apr 26, 2023

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
184 0 7 184 100

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.041 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 2.533 s C8Y Child Alarms Rpi
Normal case when the child device already exists 0.884 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 1.8559999999999999 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 5.318 s C8Y Child Alarms Rpi
Prerequisite Parent 18.152 s Child Conf Mgmt Plugin
Prerequisite Child 0.583 s Child Conf Mgmt Plugin
Child device bootstrapping 14.323 s Child Conf Mgmt Plugin
Snapshot from device 61.263 s Child Conf Mgmt Plugin
Child device config update 62.318 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 51.159 s Inotify Crate
Check lock file existence in default folder 1.044 s Lock File
Check PID number in lock file 1.883 s Lock File
Check PID number in lock file after restarting the services 4.627 s Lock File
Check starting same service twice 2.207 s Lock File
Switch off lock file creation 3.337 s Lock File
Set configuration when file exists 8.975 s Configuration Operation
Set configuration when file does not exist 6.079 s Configuration Operation
Set configuration with broken url 6.313 s Configuration Operation
Get configuration 5.615 s Configuration Operation
Get non existent configuration file 5.06 s Configuration Operation
Get non existent configuration type 4.394 s Configuration Operation
Update configuration plugin config via cloud 5.115 s Configuration Operation
Modify configuration plugin config via local filesystem overwrite 4.197 s Configuration Operation
Update configuration plugin config via local filesystem copy 2.2800000000000002 s Configuration Operation
Update configuration plugin config via local filesystem move (different directory) 2.079 s Configuration Operation
Successful firmware operation 73.662 s Firmware Operation
Install with empty firmware name 54.736 s Firmware Operation
Prerequisite Parent 20.368 s Firmware Operation Child Device
Prerequisite Child 7.848 s Firmware Operation Child Device
Child device firmware update 6.083 s Firmware Operation Child Device
Child device firmware update with cache 5.955 s Firmware Operation Child Device
Update Inventory data via inventory.json 3.458 s Inventory Update
Retrieve a JWT tokens 119.569 s Jwt Request
Main device registration 1.8319999999999999 s Device Registration
Child device registration 2.183 s Device Registration
Supports restarting the device 73.671 s Restart Device
Update tedge version from previous using Cumulocity 98.928 s Tedge Self Update
Test if all c8y services are up 115.5 s Service Monitoring
Test if all c8y services are down 112.457 s Service Monitoring
Test if all c8y services are using configured service type 110.06 s Service Monitoring
Test if all c8y services using default service type when service type configured as empty 37.97 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker stop start 32.642 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker restart 36.142 s Service Monitoring
Check health status of child device service 27.621 s Service Monitoring
Successful shell command with output 3.433 s Shell Operation
Check Successful shell command with literal double quotes output 3.145 s Shell Operation
Execute multiline shell command 3.082 s Shell Operation
Failed shell command 2.969 s Shell Operation
Software list should be populated during startup 44.22 s Software
Install software via Cumulocity 65.939 s Software
Software list should only show currently installed software and not candidates 49.41 s Software
Child devices support sending simple measurements 1.329 s Child Device Telemetry
Child devices support sending custom measurements 1.333 s Child Device Telemetry
Child devices support sending custom events 1.06 s Child Device Telemetry
Child devices support sending custom events overriding the type 0.935 s Child Device Telemetry
Child devices support sending custom alarms #1699 1.106 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 0.881 s Child Device Telemetry
Main device support sending inventory data via c8y topic 1.5190000000000001 s Child Device Telemetry
Child device supports sending custom child device measurements directly to c8y 1.389 s Child Device Telemetry
Main device supports sending custom child device measurements directly to c8y 1.307 s Child Device Telemetry
Check retained alarms 48.895 s Raise Alarms
Validate updated data path used by tedge-agent 0.923 s Data Path Config
Validate updated data path used by c8y-firmware-plugin 10.795 s Data Path Config
Stop tedge-agent service 0.472 s Log Path Config
Customize the log path 0.211 s Log Path Config
Initialize tedge-agent 0.139 s Log Path Config
Check created folders 0.139 s Log Path Config
Remove created custom folders 0.118 s Log Path Config
Install thin-edge via apt 49.437 s Install Apt
Install latest via script (from current branch) 26.131 s Install Tedge
Install specific version via script (from current branch) 24.183 s Install Tedge
Install latest tedge via script (from main branch) 23.615 s Install Tedge
Install then uninstall latest tedge via script (from main branch) 54.025 s Install Tedge
Support starting and stopping services 42.482 s Service-Control
Supports a reconnect 61.077 s Test-Commands
Supports disconnect then connect 42.11 s Test-Commands
Update unknown setting 45.536 s Test-Commands
Update known setting 27.004 s Test-Commands
Stop c8y-configuration-plugin 60.254 s Health C8Y-Configuration-Plugin
Update the service file 0.134 s Health C8Y-Configuration-Plugin
Reload systemd files 0.659 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.175 s Health C8Y-Configuration-Plugin
Start watchdog service 10.207 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.134 s Health C8Y-Configuration-Plugin
Kill the PID 0.272 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 6.584 s Health C8Y-Configuration-Plugin
Compare PID change 0.001 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.206 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.34 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 0.357 s Health C8Y-Log-Plugin
Update the service file 0.182 s Health C8Y-Log-Plugin
Reload systemd files 1.082 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.231 s Health C8Y-Log-Plugin
Start watchdog service 10.325 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.164 s Health C8Y-Log-Plugin
Kill the PID 0.474 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 6.6899999999999995 s Health C8Y-Log-Plugin
Compare PID change 0.001 s Health C8Y-Log-Plugin
Stop watchdog service 0.102 s Health C8Y-Log-Plugin
Remove entry from service file 0.136 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.211 s Health Tedge Mapper C8Y
Update the service file 0.219 s Health Tedge Mapper C8Y
Reload systemd files 0.593 s Health Tedge Mapper C8Y
Start tedge-mapper 0.255 s Health Tedge Mapper C8Y
Start watchdog service 10.319 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.097 s Health Tedge Mapper C8Y
Kill the PID 0.232 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 6.41 s Health Tedge Mapper C8Y
Compare PID change 0.001 s Health Tedge Mapper C8Y
Stop watchdog service 0.296 s Health Tedge Mapper C8Y
Remove entry from service file 0.162 s Health Tedge Mapper C8Y
Stop tedge-agent 0.373 s Health Tedge-Agent
Update the service file 0.164 s Health Tedge-Agent
Reload systemd files 0.729 s Health Tedge-Agent
Start tedge-agent 0.125 s Health Tedge-Agent
Start watchdog service 10.4 s Health Tedge-Agent
Check PID of tedge-mapper 0.127 s Health Tedge-Agent
Kill the PID 0.359 s Health Tedge-Agent
Recheck PID of tedge-agent 6.625 s Health Tedge-Agent
Compare PID change 0.001 s Health Tedge-Agent
Stop watchdog service 0.193 s Health Tedge-Agent
Remove entry from service file 0.109 s Health Tedge-Agent
Stop tedge-mapper-az 0.204 s Health Tedge-Mapper-Az
Update the service file 0.155 s Health Tedge-Mapper-Az
Reload systemd files 0.571 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.411 s Health Tedge-Mapper-Az
Start watchdog service 10.227 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.151 s Health Tedge-Mapper-Az
Kill the PID 0.363 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 6.573 s Health Tedge-Mapper-Az
Compare PID change 0.004 s Health Tedge-Mapper-Az
Stop watchdog service 0.259 s Health Tedge-Mapper-Az
Remove entry from service file 0.134 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.236 s Health Tedge-Mapper-Collectd
Update the service file 0.11 s Health Tedge-Mapper-Collectd
Reload systemd files 0.419 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.132 s Health Tedge-Mapper-Collectd
Start watchdog service 10.177 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.077 s Health Tedge-Mapper-Collectd
Kill the PID 0.179 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 6.643 s Health Tedge-Mapper-Collectd
Compare PID change 0.006 s Health Tedge-Mapper-Collectd
Stop watchdog service 0.276 s Health Tedge-Mapper-Collectd
Remove entry from service file 0.273 s Health Tedge-Mapper-Collectd
tedge-collectd-mapper health status 5.663 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.828 s MQTT health endpoints
c8y-configuration-plugin health status 5.725 s MQTT health endpoints
Publish on a local insecure broker 0.25 s Basic Pub Sub
Publish on a local secure broker 2.218 s Basic Pub Sub
Publish on a local secure broker with client authentication 2.124 s Basic Pub Sub
Check remote mqtt broker #1773 5.283 s Remote Mqtt Broker
Wrong package name 0.172 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.151 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.425 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.273 s Tedge Connect Test
tedge_connect_test_negative 0.927 s Tedge Connect Test
tedge_connect_test_sm_services 6.64 s Tedge Connect Test
tedge_disconnect_test_sm_services 0.342 s Tedge Connect Test
Install thin-edge.io 17.881 s Call Tedge
call tedge -V 0.133 s Call Tedge
call tedge -h 0.156 s Call Tedge
call tedge -h -V 0.119 s Call Tedge
call tedge help 0.206 s Call Tedge
tedge config list 0.055 s Call Tedge Config List
tedge config list --all 0.055 s Call Tedge Config List
set/unset device.type 0.265 s Call Tedge Config List
set/unset device.key.path 0.3 s Call Tedge Config List
set/unset device.cert.path 0.399 s Call Tedge Config List
set/unset c8y.root.cert.path 0.282 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.22 s Call Tedge Config List
set/unset az.root.cert.path 0.217 s Call Tedge Config List
set/unset az.mapper.timestamp 0.263 s Call Tedge Config List
set/unset mqtt.bind_address 0.253 s Call Tedge Config List
set/unset mqtt.port 0.219 s Call Tedge Config List
set/unset tmp.path 0.359 s Call Tedge Config List
set/unset logs.path 0.32 s Call Tedge Config List
set/unset run.path 0.3 s Call Tedge Config List
Get Put Delete 3.306 s Http File Transfer Api
Set keys should return value on stdout 0.09 s Tedge Config Get
Unset keys should not return anything on stdout and warnings on stderr 0.167 s Tedge Config Get
Invalid keys should not return anything on stdout and warnings on stderr 0.174 s Tedge Config Get
Set configuration via environment variables 0.657 s Tedge Config Get
Set unknown configuration via environment variables 0.085 s Tedge Config Get

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.

This is already a nice improvement. However, this can be improved a bit more.

Now, we have this error:

$ tedge --init        
Error: Failed to change owner: "/var/log/tedge".

But it would be good to the user what need to do using anyhow::with_context in tedge::initialize_tedge() to get:

$ tedge --init
Error: Failed to initialize tedge. You have to run tedge with sudo.

Caused by:
      Failed to change owner: "/var/log/tedge".

Copy link
Contributor

@PradeepKiruvale PradeepKiruvale left a comment

Choose a reason for hiding this comment

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

LGTM, I feel its good to add some unit tests.

@didier-wenzek
Copy link
Contributor

LGTM, I feel its good to add some unit tests.

One can add a system test, but I see no point to have unit tests.

@Ruadhri17
Copy link
Contributor Author

This is already a nice improvement. However, this can be improved a bit more.

Now, we have this error:

$ tedge --init        
Error: Failed to change owner: "/var/log/tedge".

But it would be good to the user what need to do using anyhow::with_context in tedge::initialize_tedge() to get:

$ tedge --init
Error: Failed to initialize tedge. You have to run tedge with sudo.

Caused by:
      Failed to change owner: "/var/log/tedge".

Changed for tedge and all plugins that have an initialization process.

@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request April 28, 2023 08:59 — 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.

Please fix the typo that is in all the error messages (missing the article the).

plugins/c8y_configuration_plugin/src/main.rs Outdated Show resolved Hide resolved
Signed-off-by: Krzysztof Piotrowski <Krzysztof.Piotrowski@inetum.com>
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request April 28, 2023 14:50 — with GitHub Actions Inactive
@didier-wenzek didier-wenzek merged commit 76f5b13 into thin-edge:main Apr 28, 2023
15 checks passed
@Ruadhri17 Ruadhri17 deleted the tedge-init-errors branch June 26, 2023 14:38
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

3 participants