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

Fix/1896/file modifications #1928

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

jmshark
Copy link
Contributor

@jmshark jmshark commented Apr 24, 2023

Proposed changes

Fix for 1896 sed creates a temp file where the edits are made then moves the file to the final destination. Moving a file in the same directory generates various EventKind::Modify where the modification kind is Name these events were being dropped by crates\common\tedge_utils\src\notify.rs which is why it fails for these cases.

In addition to capturing these events I've also removed some dead code.

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


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

@jmshark jmshark had a problem deploying to Test Pull Request April 24, 2023 17:22 — with GitHub Actions Failure
@jmshark jmshark force-pushed the fix/1896/file-modifications branch from 4ca36fd to 5ab728b Compare April 24, 2023 17:25
@jmshark jmshark temporarily deployed to Test Pull Request April 24, 2023 17:34 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Apr 24, 2023

Robot Results

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

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.015 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 2.495 s C8Y Child Alarms Rpi
Normal case when the child device already exists 1.236 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 1.7730000000000001 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 5.135 s C8Y Child Alarms Rpi
Prerequisite Parent 75.821 s Child Conf Mgmt Plugin
Prerequisite Child 0.485 s Child Conf Mgmt Plugin
Child device bootstrapping 13.697 s Child Conf Mgmt Plugin
Snapshot from device 61.706 s Child Conf Mgmt Plugin
Child device config update 62.333 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 109.001 s Inotify Crate
Check lock file existence in default folder 2.104 s Lock File
Check PID number in lock file 2.061 s Lock File
Check PID number in lock file after restarting the services 2.742 s Lock File
Check starting same service twice 1.17 s Lock File
Switch off lock file creation 1.962 s Lock File
Set configuration when file exists 53.292 s Configuration Operation
Set configuration when file does not exist 4.92 s Configuration Operation
Set configuration with broken url 4.8100000000000005 s Configuration Operation
Get configuration 5.092 s Configuration Operation
Get non existent configuration file 5.257 s Configuration Operation
Get non existent configuration type 4.509 s Configuration Operation
Update configuration plugin config via cloud 5.216 s Configuration Operation
Modify configuration plugin config via local filesystem modify inplace 2.424 s Configuration Operation
Modify configuration plugin config via local filesystem overwrite 4.521 s Configuration Operation
Update configuration plugin config via local filesystem copy 2.672 s Configuration Operation
Update configuration plugin config via local filesystem move (different directory) 2.586 s Configuration Operation
Update configuration plugin config via local filesystem move (same directory) 4.751 s Configuration Operation
Successful firmware operation 66.827 s Firmware Operation
Install with empty firmware name 47.088 s Firmware Operation
Prerequisite Parent 17.833 s Firmware Operation Child Device
Prerequisite Child 7.576 s Firmware Operation Child Device
Child device firmware update 5.797 s Firmware Operation Child Device
Child device firmware update with cache 5.477 s Firmware Operation Child Device
Update Inventory data via inventory.json 1.065 s Inventory Update
Retrieve a JWT tokens 116.999 s Jwt Request
Main device registration 1.7429999999999999 s Device Registration
Child device registration 2.133 s Device Registration
Supports restarting the device 119.78 s Restart Device
Update tedge version from previous using Cumulocity 72.337 s Tedge Self Update
Test if all c8y services are up 109 s Service Monitoring
Test if all c8y services are down 114.06 s Service Monitoring
Test if all c8y services are using configured service type 102.213 s Service Monitoring
Test if all c8y services using default service type when service type configured as empty 38.831 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker stop start 33.391 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker restart 38.421 s Service Monitoring
Check health status of child device service 27.855 s Service Monitoring
Successful shell command with output 3.425 s Shell Operation
Check Successful shell command with literal double quotes output 3.309 s Shell Operation
Execute multiline shell command 3.016 s Shell Operation
Failed shell command 2.963 s Shell Operation
Software list should be populated during startup 36.246 s Software
Install software via Cumulocity 61.482 s Software
Software list should only show currently installed software and not candidates 43.747 s Software
Child devices support sending simple measurements 1.159 s Child Device Telemetry
Child devices support sending custom measurements 0.848 s Child Device Telemetry
Child devices support sending custom events 1.302 s Child Device Telemetry
Child devices support sending custom events overriding the type 1.127 s Child Device Telemetry
Child devices support sending custom alarms #1699 1.003 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 0.851 s Child Device Telemetry
Main device support sending inventory data via c8y topic 1.093 s Child Device Telemetry
Child device supports sending custom child device measurements directly to c8y 1.194 s Child Device Telemetry
Main device supports sending custom child device measurements directly to c8y 1.342 s Child Device Telemetry
Check retained alarms 42 s Raise Alarms
Validate updated data path used by tedge-agent 0.765 s Data Path Config
Validate updated data path used by c8y-firmware-plugin 10.44 s Data Path Config
Stop tedge-agent service 0.429 s Log Path Config
Customize the log path 0.298 s Log Path Config
Initialize tedge-agent 0.269 s Log Path Config
Check created folders 0.141 s Log Path Config
Remove created custom folders 0.234 s Log Path Config
Install thin-edge via apt 42.174 s Install Apt
Install latest via script (from current branch) 20.654 s Install Tedge
Install specific version via script (from current branch) 25.593 s Install Tedge
Install latest tedge via script (from main branch) 23.555 s Install Tedge
Install then uninstall latest tedge via script (from main branch) 38.676 s Install Tedge
Support starting and stopping services 47.855 s Service-Control
Supports a reconnect 60.992 s Test-Commands
Supports disconnect then connect 38.779 s Test-Commands
Update unknown setting 37.528 s Test-Commands
Update known setting 27.117 s Test-Commands
Stop c8y-configuration-plugin 60.296 s Health C8Y-Configuration-Plugin
Update the service file 0.099 s Health C8Y-Configuration-Plugin
Reload systemd files 0.402 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.13 s Health C8Y-Configuration-Plugin
Start watchdog service 10.148 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.058 s Health C8Y-Configuration-Plugin
Kill the PID 0.135 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 6.431 s Health C8Y-Configuration-Plugin
Compare PID change 0.001 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.123 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.157 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 0.114 s Health C8Y-Log-Plugin
Update the service file 0.112 s Health C8Y-Log-Plugin
Reload systemd files 0.353 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.091 s Health C8Y-Log-Plugin
Start watchdog service 10.139 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.096 s Health C8Y-Log-Plugin
Kill the PID 0.219 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 6.408 s Health C8Y-Log-Plugin
Compare PID change 0.001 s Health C8Y-Log-Plugin
Stop watchdog service 0.103 s Health C8Y-Log-Plugin
Remove entry from service file 0.089 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.083 s Health Tedge Mapper C8Y
Update the service file 0.073 s Health Tedge Mapper C8Y
Reload systemd files 0.309 s Health Tedge Mapper C8Y
Start tedge-mapper 0.066 s Health Tedge Mapper C8Y
Start watchdog service 10.089 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.091 s Health Tedge Mapper C8Y
Kill the PID 0.245 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 6.509 s Health Tedge Mapper C8Y
Compare PID change 0.001 s Health Tedge Mapper C8Y
Stop watchdog service 0.285 s Health Tedge Mapper C8Y
Remove entry from service file 0.134 s Health Tedge Mapper C8Y
Stop tedge-agent 0.107 s Health Tedge-Agent
Update the service file 0.117 s Health Tedge-Agent
Reload systemd files 0.388 s Health Tedge-Agent
Start tedge-agent 0.24 s Health Tedge-Agent
Start watchdog service 10.242 s Health Tedge-Agent
Check PID of tedge-mapper 0.129 s Health Tedge-Agent
Kill the PID 0.299 s Health Tedge-Agent
Recheck PID of tedge-agent 6.529 s Health Tedge-Agent
Compare PID change 0.001 s Health Tedge-Agent
Stop watchdog service 0.086 s Health Tedge-Agent
Remove entry from service file 0.128 s Health Tedge-Agent
Stop tedge-mapper-az 0.136 s Health Tedge-Mapper-Az
Update the service file 0.208 s Health Tedge-Mapper-Az
Reload systemd files 0.529 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.136 s Health Tedge-Mapper-Az
Start watchdog service 10.121 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.11 s Health Tedge-Mapper-Az
Kill the PID 0.253 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 6.357 s Health Tedge-Mapper-Az
Compare PID change 0.001 s Health Tedge-Mapper-Az
Stop watchdog service 0.257 s Health Tedge-Mapper-Az
Remove entry from service file 0.108 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.103 s Health Tedge-Mapper-Collectd
Update the service file 0.122 s Health Tedge-Mapper-Collectd
Reload systemd files 0.308 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.135 s Health Tedge-Mapper-Collectd
Start watchdog service 10.139 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.069 s Health Tedge-Mapper-Collectd
Kill the PID 0.173 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 6.535 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.128 s Health Tedge-Mapper-Collectd
tedge-collectd-mapper health status 5.576 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.521 s MQTT health endpoints
c8y-configuration-plugin health status 5.546 s MQTT health endpoints
Publish on a local insecure broker 0.215 s Basic Pub Sub
Publish on a local secure broker 2.7359999999999998 s Basic Pub Sub
Publish on a local secure broker with client authentication 2.944 s Basic Pub Sub
Wrong package name 0.074 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.059 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.175 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.275 s Tedge Connect Test
tedge_connect_test_negative 0.646 s Tedge Connect Test
tedge_connect_test_sm_services 6.715 s Tedge Connect Test
tedge_disconnect_test_sm_services 0.518 s Tedge Connect Test
Install thin-edge.io 14.076 s Call Tedge
call tedge -V 0.08 s Call Tedge
call tedge -h 0.122 s Call Tedge
call tedge -h -V 0.111 s Call Tedge
call tedge help 0.109 s Call Tedge
tedge config list 0.069 s Call Tedge Config List
tedge config list --all 0.105 s Call Tedge Config List
set/unset device.type 0.279 s Call Tedge Config List
set/unset device.key.path 0.284 s Call Tedge Config List
set/unset device.cert.path 0.298 s Call Tedge Config List
set/unset c8y.root.cert.path 0.288 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.301 s Call Tedge Config List
set/unset az.root.cert.path 0.258 s Call Tedge Config List
set/unset az.mapper.timestamp 0.307 s Call Tedge Config List
set/unset mqtt.bind_address 0.305 s Call Tedge Config List
set/unset mqtt.port 0.346 s Call Tedge Config List
set/unset tmp.path 0.279 s Call Tedge Config List
set/unset logs.path 0.324 s Call Tedge Config List
set/unset run.path 0.266 s Call Tedge Config List
Get Put Delete 3.408 s Http File Transfer Api
Set keys should return value on stdout 0.134 s Tedge Config Get
Unset keys should not return anything on stdout and warnings on stderr 0.231 s Tedge Config Get
Invalid keys should not return anything on stdout and warnings on stderr 0.202 s Tedge Config Get
Set configuration via environment variables 0.994 s Tedge Config Get
Set unknown configuration via environment variables 0.131 s Tedge Config Get

@jmshark jmshark requested a review from didier-wenzek April 24, 2023 22:15
@reubenmiller
Copy link
Contributor

@jmshark We'll have to rebase once #1875 is merged (it is going through review now), as it includes a test-stability fix. Though you should still check that the configuration tests marked as skipped have been removed (during rebasing/resolving conflicts).

@reubenmiller
Copy link
Contributor

@jmshark We'll have to rebase once #1875 is merged (it is going through review now), as it includes a test-stability fix. Though you should still check that the configuration tests marked as skipped have been removed (during rebasing/resolving conflicts).

@jmshark #1875 has been merged now, so please rebase/resolve conflicts.

@jmshark jmshark force-pushed the fix/1896/file-modifications branch from 5ab728b to f3e8c8b Compare April 25, 2023 10:34
@jmshark
Copy link
Contributor Author

jmshark commented Apr 25, 2023

@jmshark We'll have to rebase once #1875 is merged (it is going through review now), as it includes a test-stability fix. Though you should still check that the configuration tests marked as skipped have been removed (during rebasing/resolving conflicts).

@jmshark #1875 has been merged now, so please rebase/resolve conflicts.

Done

@jmshark jmshark temporarily deployed to Test Pull Request April 25, 2023 10:42 — with GitHub Actions Inactive
@jmshark jmshark force-pushed the fix/1896/file-modifications branch from f3e8c8b to 6edbb09 Compare April 25, 2023 14:23
@jmshark jmshark temporarily deployed to Test Pull Request April 25, 2023 14:32 — 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. Nice fix and simplification.

crates/common/tedge_utils/src/notify.rs Show resolved Hide resolved
Comment on lines -127 to +111
pub fn add_watcher(
&mut self,
dir_path: &Path,
file: Option<String>,
events: &[FsEvent],
) -> Result<(), NotifyStreamError> {
/// Will return an error if you try to watch a file/directory which doesn't exist
pub fn add_watcher(&mut self, dir_path: &Path) -> Result<(), NotifyStreamError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing the list of watch events is a nice simplification. The caller might receive more messages than expected but it far simpler to do the filtering there.

@jmshark jmshark force-pushed the fix/1896/file-modifications branch from 6edbb09 to 25bb89f Compare April 26, 2023 14:36
@jmshark jmshark temporarily deployed to Test Pull Request April 26, 2023 14:45 — with GitHub Actions Inactive
@jmshark jmshark merged commit 71e2d39 into thin-edge:main Apr 26, 2023
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.

3 participants