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

Filtering criteria in apt-sm-plugin output #1961

Merged
merged 5 commits into from
Jun 2, 2023

Conversation

Ruadhri17
Copy link
Contributor

@Ruadhri17 Ruadhri17 commented May 10, 2023

Proposed changes

This PR adds two features:

  • option to filter packages by name and maintainer in apt plugin. User have to set filters manually using tedge.toml.
  • limit of software list output to given number of lines using tedge config. Default value is set to 1000 and 0 means no limit to the output (STC).

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

#1926

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 force-pushed the apt-list-filtering branch 3 times, most recently from c5ffa49 to 02b0d73 Compare May 10, 2023 20:32
@Ruadhri17 Ruadhri17 force-pushed the apt-list-filtering branch 2 times, most recently from d4efaf0 to ec66282 Compare May 11, 2023 18:52
@github-actions
Copy link
Contributor

github-actions bot commented May 11, 2023

Robot Results

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

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.008 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 2.344 s C8Y Child Alarms Rpi
Normal case when the child device already exists 0.983 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 1.4729999999999999 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 5.545 s C8Y Child Alarms Rpi
Prerequisite Parent 15.434 s Child Conf Mgmt Plugin
Prerequisite Child 0.314 s Child Conf Mgmt Plugin
Child device bootstrapping 14.65 s Child Conf Mgmt Plugin
Snapshot from device 62.35 s Child Conf Mgmt Plugin
Child device config update 61.716 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 49.729 s Inotify Crate
Check lock file existence in default folder 1.103 s Lock File
Check PID number in lock file 1.061 s Lock File
Check PID number in lock file after restarting the services 1.689 s Lock File
Check starting same service twice 1.181 s Lock File
Switch off lock file creation 2.8209999999999997 s Lock File
Set configuration when file exists 13.268 s Configuration Operation
Set configuration when file does not exist 6.261 s Configuration Operation
Set configuration with broken url 4.823 s Configuration Operation
Get configuration 5.339 s Configuration Operation
Get non existent configuration file 5.121 s Configuration Operation
Get non existent configuration type 4.292 s Configuration Operation
Update configuration plugin config via cloud 4.729 s Configuration Operation
Modify configuration plugin config via local filesystem modify inplace 3.068 s Configuration Operation
Modify configuration plugin config via local filesystem overwrite 5.586 s Configuration Operation
Update configuration plugin config via local filesystem copy 6.945 s Configuration Operation
Update configuration plugin config via local filesystem move (different directory) 5.572 s Configuration Operation
Update configuration plugin config via local filesystem move (same directory) 5.181 s Configuration Operation
Successful firmware operation 65.41 s Firmware Operation
Install with empty firmware name 51.382 s Firmware Operation
Prerequisite Parent 17.115 s Firmware Operation Child Device
Prerequisite Child 8.024 s Firmware Operation Child Device
Child device firmware update 6.462 s Firmware Operation Child Device
Child device firmware update with cache 5.89 s Firmware Operation Child Device
Firmware plugin supports restart via service manager #1932 5.541 s Firmware Operation Child Device Retry
Update Inventory data via inventory.json 1.202 s Inventory Update
Inventory includes the agent fragment with version information 1.145 s Inventory Update
Retrieve a JWT tokens 51.473 s Jwt Request
Check running collectd 1.065 s Monitor Device Collectd
Is collectd publishing MQTT messages? 2.9459999999999997 s Monitor Device Collectd
Check thin-edge monitoring 3.866 s Monitor Device Collectd
Check grouping of measurements 8.468 s Monitor Device Collectd
Update the custom operation dynamically 48.262 s Dynamically Reload Operation
Main device registration 2.012 s Device Registration
Child device registration 2.3689999999999998 s Device Registration
Supports restarting the device 59.413 s Restart Device
Update tedge version from previous using Cumulocity 83.63 s Tedge Self Update
Test if all c8y services are up 109.495 s Service Monitoring
Test if all c8y services are down 45.941 s Service Monitoring
Test if all c8y services are using configured service type 108.348 s Service Monitoring
Test if all c8y services using default service type when service type configured as empty 154.064 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker stop start 25.68 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker restart 27.404 s Service Monitoring
Check health status of child device service 24.173 s Service Monitoring
Successful shell command with output 3.565 s Shell Operation
Check Successful shell command with literal double quotes output 3.315 s Shell Operation
Execute multiline shell command 3.248 s Shell Operation
Failed shell command 3.228 s Shell Operation
Software list should be populated during startup 43.506 s Software
Install software via Cumulocity 42.404 s Software
Software list should only show currently installed software and not candidates 39.648 s Software
Child devices support sending simple measurements 3.605 s Child Device Telemetry
Child devices support sending custom measurements 1.162 s Child Device Telemetry
Child devices support sending custom events 3.423 s Child Device Telemetry
Child devices support sending custom events overriding the type 1.167 s Child Device Telemetry
Child devices support sending custom alarms #1699 3.175 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 0.95 s Child Device Telemetry
Child device supports sending custom child device measurements directly to c8y 1.389 s Child Device Telemetry
Check retained alarms 221.564 s Raise Alarms
Thin-edge devices support sending simple measurements 1.339 s Thin-Edge Device Telemetry
Thin-edge devices support sending simple measurements with custom type 1.042 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom measurements 0.968 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events 1.2 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events overriding the type 1.005 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom alarms #1699 0.915 s Thin-Edge Device Telemetry
Thin-edge device supports sending custom Thin-edge device measurements directly to c8y 1.467 s Thin-Edge Device Telemetry
Thin-edge device support sending inventory data via c8y topic 1.244 s Thin-Edge Device Telemetry
thin-edge components support a custom config-dir location via flags 26.373 s Config Dir
Validate updated data path used by tedge-agent 0.559 s Data Path Config
Validate updated data path used by c8y-firmware-plugin 10.822 s Data Path Config
Stop tedge-agent service 0.254 s Log Path Config
Customize the log path 0.112 s Log Path Config
Initialize tedge-agent 0.127 s Log Path Config
Check created folders 0.103 s Log Path Config
Remove created custom folders 0.125 s Log Path Config
Install thin-edge via apt 34.407 s Install Apt
Install latest via script (from current branch) 23.712 s Install Tedge
Install specific version via script (from current branch) 21.364 s Install Tedge
Install latest tedge via script (from main branch) 20.698 s Install Tedge
Install then uninstall latest tedge via script (from main branch) 54.651 s Install Tedge
Support starting and stopping services 34.037 s Service-Control
Supports a reconnect 49.353 s Test-Commands
Supports disconnect then connect 33.889 s Test-Commands
Update unknown setting 38.017 s Test-Commands
Update known setting 33.81 s Test-Commands
Stop c8y-configuration-plugin 0.122 s Health C8Y-Configuration-Plugin
Update the service file 0.095 s Health C8Y-Configuration-Plugin
Reload systemd files 0.524 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.166 s Health C8Y-Configuration-Plugin
Start watchdog service 10.189 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.085 s Health C8Y-Configuration-Plugin
Kill the PID 0.114 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 6.382 s Health C8Y-Configuration-Plugin
Compare PID change 0.006 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.135 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.087 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 0.146 s Health C8Y-Log-Plugin
Update the service file 0.081 s Health C8Y-Log-Plugin
Reload systemd files 0.3 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.128 s Health C8Y-Log-Plugin
Start watchdog service 10.133 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.054 s Health C8Y-Log-Plugin
Kill the PID 0.398 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 6.699 s Health C8Y-Log-Plugin
Compare PID change 0.001 s Health C8Y-Log-Plugin
Stop watchdog service 0.186 s Health C8Y-Log-Plugin
Remove entry from service file 0.197 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.127 s Health Tedge Mapper C8Y
Update the service file 0.156 s Health Tedge Mapper C8Y
Reload systemd files 0.37 s Health Tedge Mapper C8Y
Start tedge-mapper 0.211 s Health Tedge Mapper C8Y
Start watchdog service 10.382 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.281 s Health Tedge Mapper C8Y
Kill the PID 0.288 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 6.379 s Health Tedge Mapper C8Y
Compare PID change 0.001 s Health Tedge Mapper C8Y
Stop watchdog service 0.109 s Health Tedge Mapper C8Y
Remove entry from service file 0.095 s Health Tedge Mapper C8Y
Stop tedge-agent 0.164 s Health Tedge-Agent
Update the service file 0.139 s Health Tedge-Agent
Reload systemd files 0.456 s Health Tedge-Agent
Start tedge-agent 0.114 s Health Tedge-Agent
Start watchdog service 10.146 s Health Tedge-Agent
Check PID of tedge-mapper 0.222 s Health Tedge-Agent
Kill the PID 0.242 s Health Tedge-Agent
Recheck PID of tedge-agent 6.345 s Health Tedge-Agent
Compare PID change 0.001 s Health Tedge-Agent
Stop watchdog service 0.106 s Health Tedge-Agent
Remove entry from service file 0.116 s Health Tedge-Agent
Stop tedge-mapper-az 0.231 s Health Tedge-Mapper-Az
Update the service file 0.172 s Health Tedge-Mapper-Az
Reload systemd files 0.483 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.234 s Health Tedge-Mapper-Az
Start watchdog service 10.271 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.089 s Health Tedge-Mapper-Az
Kill the PID 0.199 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 6.325 s Health Tedge-Mapper-Az
Compare PID change 0.001 s Health Tedge-Mapper-Az
Stop watchdog service 0.122 s Health Tedge-Mapper-Az
Remove entry from service file 0.102 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.14 s Health Tedge-Mapper-Collectd
Update the service file 0.086 s Health Tedge-Mapper-Collectd
Reload systemd files 0.529 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.181 s Health Tedge-Mapper-Collectd
Start watchdog service 10.174 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.114 s Health Tedge-Mapper-Collectd
Kill the PID 0.225 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 6.299 s Health Tedge-Mapper-Collectd
Compare PID change 0.001 s Health Tedge-Mapper-Collectd
Stop watchdog service 0.064 s Health Tedge-Mapper-Collectd
Remove entry from service file 0.08 s Health Tedge-Mapper-Collectd
tedge-collectd-mapper health status 5.448 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.541 s MQTT health endpoints
c8y-configuration-plugin health status 5.425 s MQTT health endpoints
Publish on a local insecure broker 0.293 s Basic Pub Sub
Publish on a local secure broker 2.341 s Basic Pub Sub
Publish on a local secure broker with client authentication 2.726 s Basic Pub Sub
Check remote mqtt broker #1773 4.896 s Remote Mqtt Broker
Apply name filter 0.111 s Filter Packages List Output
Apply maintainer filter 0.182 s Filter Packages List Output
Apply both filters 0.16 s Filter Packages List Output
No filters 0.13 s Filter Packages List Output
Both filters but name filter as empty string 0.15 s Filter Packages List Output
Both filters but maintainer filter as empty string 0.142 s Filter Packages List Output
Both filters as empty string 0.136 s Filter Packages List Output
Wrong package name 0.129 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.148 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.441 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.212 s Tedge Connect Test
tedge_connect_test_negative 0.349 s Tedge Connect Test
tedge_connect_test_sm_services 6.982 s Tedge Connect Test
tedge_disconnect_test_sm_services 60.317 s Tedge Connect Test
Install thin-edge.io 14.336 s Call Tedge
call tedge -V 0.244 s Call Tedge
call tedge -h 0.179 s Call Tedge
call tedge -h -V 0.176 s Call Tedge
call tedge help 0.108 s Call Tedge
tedge config list 0.056 s Call Tedge Config List
tedge config list --all 0.06 s Call Tedge Config List
set/unset device.type 0.247 s Call Tedge Config List
set/unset device.key_path 0.284 s Call Tedge Config List
set/unset device.cert_path 0.308 s Call Tedge Config List
set/unset c8y.root_cert_path 0.215 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.281 s Call Tedge Config List
set/unset az.root_cert_path 0.233 s Call Tedge Config List
set/unset aws.url 0.28 s Call Tedge Config List
set/unset aws.root_cert_path 0.298 s Call Tedge Config List
set/unset aws.mapper.timestamp 0.262 s Call Tedge Config List
set/unset az.mapper.timestamp 0.254 s Call Tedge Config List
set/unset mqtt.bind.address 0.226 s Call Tedge Config List
set/unset mqtt.bind.port 0.315 s Call Tedge Config List
set/unset http.bind.port 0.23 s Call Tedge Config List
set/unset tmp.path 0.224 s Call Tedge Config List
set/unset logs.path 0.24 s Call Tedge Config List
set/unset run.path 0.222 s Call Tedge Config List
set/unset firmware.child.update.timeout 0.261 s Call Tedge Config List
set/unset c8y.url 0.333 s Call Tedge Config List
set/unset az.url 0.339 s Call Tedge Config List
set/unset mqtt.external.bind.port 0.266 s Call Tedge Config List
mqtt.external.bind.address 0.327 s Call Tedge Config List
mqtt.external.bind.interface 0.369 s Call Tedge Config List
set/unset mqtt.external.ca_path 0.397 s Call Tedge Config List
set/unset mqtt.external.cert_file 0.392 s Call Tedge Config List
set/unset mqtt.external.key_file 0.425 s Call Tedge Config List
set/unset software.plugin.default 0.418 s Call Tedge Config List
Get Put Delete 1.416 s Http File Transfer Api
Set keys should return value on stdout 0.091 s Tedge Config Get
Unset keys should not return anything on stdout and warnings on stderr 0.225 s Tedge Config Get
Invalid keys should not return anything on stdout and warnings on stderr 0.218 s Tedge Config Get
Set configuration via environment variables 0.743 s Tedge Config Get
Set unknown configuration via environment variables 0.074 s Tedge Config Get

@Ruadhri17 Ruadhri17 force-pushed the apt-list-filtering branch 4 times, most recently from 0418613 to 5f88978 Compare May 11, 2023 22:16
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request May 11, 2023 22:24 — with GitHub Actions Inactive
@Ruadhri17 Ruadhri17 force-pushed the apt-list-filtering branch 2 times, most recently from 6d6d4a2 to 6eed099 Compare May 11, 2023 23:51

const DESCRIPTION: &'static str = concat!(
"The maximum number of software packages reported by each sm-plugin",
"Note: If the value is set to 0, there is no limit to reported packages",
Copy link
Contributor

Choose a reason for hiding this comment

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

Using 0 to mean no-limit is usual but not really sound. Why not using an Option ? Or simpler, set a default of 1000 as suggested by #1926 ?

crates/core/plugin_sm/src/plugin.rs Outdated Show resolved Hide resolved
@didier-wenzek
Copy link
Contributor

Filtering the output of software-package lists must be addressed at two levels.

  • At the global level, by the tedge-agent, the filtering can be done only on the generic attributes as the number of entries or the package names.
  • At the plugin level, in this precise case the apt-plugin, the filtering can be more specific using for instance the package maintainers.

This means for this PR:

  • The change adding a filter parameter to the Plugin::list() method must be reverted, as this would impact all the plugins while used only by one.
  • What has been done to filter out the number of packages per plugin, can be kept as proposed here (I have some disagreements but minor).
  • Its a good idea to add - --name and --maintainer parameters to the apt-plugin command. These parameters will be ignored by the tedge-agent but will be useful for testing purposes.
  • As the - --name and --maintainer parameters are ignored by the tedge-agent, one needs to add some configuration for these parameters in tedge_config.toml. However, it's not mandatory to have these parameter managed by the tegde config command. One can add a specific stanza for the apt-plugin in tedge_config.toml. Doing so the apt-plugin will need no dependency on the tedge_config crate and can simply use serde to read the relevant parts of the config.

@reubenmiller is this okay for you that the apt-plugin read its config from tedge_config.toml, but using free settings not managed by the tedge config command? Such support can be added later and starting with something simpler would make this PR more independent of the tegde-config refactoring.

@reubenmiller
Copy link
Contributor

@reubenmiller is this okay for you that the apt-plugin read its config from tedge_config.toml, but using free settings not managed by the tedge config command? Such support can be added later and starting with something simpler would make this PR more independent of the tegde-config refactoring.

Yes I'm ok with this proposal for now. We might be a bit silent about the feature/docs until the support of the tedge config get/set is supported out of the box using the config refactoring PR.

@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request May 15, 2023 22:25 — 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.

Nice, things are going in the expected direction.

plugins/tedge_apt_plugin/Cargo.toml Outdated Show resolved Hide resolved
plugins/tedge_apt_plugin/src/main.rs Outdated Show resolved Hide resolved
plugins/tedge_apt_plugin/src/main.rs Outdated Show resolved Hide resolved
plugins/tedge_apt_plugin/src/main.rs Show resolved Hide resolved
@Ruadhri17 Ruadhri17 force-pushed the apt-list-filtering branch 2 times, most recently from 573fd17 to 2c63d4d Compare May 17, 2023 19:41
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request May 17, 2023 19:52 — with GitHub Actions Inactive
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request May 31, 2023 09:04 — with GitHub Actions Inactive
@Ruadhri17 Ruadhri17 force-pushed the apt-list-filtering branch 2 times, most recently from 5bb0544 to 3646424 Compare May 31, 2023 18:06
@didier-wenzek
Copy link
Contributor

Config settings have now to be added to crates/common/tedge_config/src/tedge_config_cli/new.rs.

I acknowledge that the current status is confusing as there are still some pending cleaning tasks to finalize #1936.

_=> I will take the time tomorrow to help you and see what needs to be cleaned.

error[E0609]: no field `max_packages` on type `TEdgeConfigDtoSoftware`
    --> crates/common/tedge_config/src/tedge_config_cli/tedge_config.rs:1072:14
     |
1072 |             .max_packages
     |              ^^^^^^^^^^^^ unknown field
     |
     = note: available fields are: `plugin`

error[E0609]: no field `max_packages` on type `TEdgeConfigDtoSoftware`
    --> crates/common/tedge_config/src/tedge_config_cli/tedge_config.rs:1082:28
     |
1082 |         self.data.software.max_packages = Some(value.into());
     |                            ^^^^^^^^^^^^ unknown field
     |
     = note: available fields are: `plugin`

error[E0609]: no field `max_packages` on type `TEdgeConfigDtoSoftware`
    --> crates/common/tedge_config/src/tedge_config_cli/tedge_config.rs:1087:28
     |
1087 |         self.data.software.max_packages = Some(self.config_defaults.default_max_packages.into());
     |                            ^^^^^^^^^^^^ unknown field
     |
     = note: available fields are: `plugin`

@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request May 31, 2023 18:16 — with GitHub Actions Inactive
@Ruadhri17
Copy link
Contributor Author

Ruadhri17 commented May 31, 2023

Config settings have now to be added to crates/common/tedge_config/src/tedge_config_cli/new.rs.

I had fixed that issue just before you posted the comment.

If we are after the tedge config refactor, should we now add one for name and maintainer filters?

@Ruadhri17 Ruadhri17 force-pushed the apt-list-filtering branch 3 times, most recently from 7943758 to b617f12 Compare May 31, 2023 18:58
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request May 31, 2023 19:09 — 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.

[EDITED] as I changed my mind after a small experiment: it's super easy to use the new tedge config right now.

The main feature is working fine, but some improvements are required before merging.

  • The source of truth is now tedge_config/../new.rs and the old settings must no more be used.
  • The Quantity type can simply be removed as not really useful.
  • max_packages doc and default value have to be fixed in the new tedge_config.
  • error handling for ill-formed name or maintainer settings can be improved.

crates/common/tedge_config/src/tedge_config_cli/new.rs Outdated Show resolved Hide resolved
crates/common/tedge_config/src/tedge_config_cli/new.rs Outdated Show resolved Hide resolved
crates/common/tedge_config/src/tedge_config_cli/new.rs Outdated Show resolved Hide resolved
plugins/tedge_apt_plugin/src/main.rs Outdated Show resolved Hide resolved
plugins/tedge_apt_plugin/src/main.rs Outdated Show resolved Hide resolved
Copy link
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

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

Suddenly dropping in and left some comments like ninja 🥷

self.name.clone(),
output.stdout.as_slice(),
)?)
let config = get_tedge_config().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this unwrap() is safe because if /etc/tedge/tedge.toml doesn't exist or is malformed, it should panic.

output.stdout.as_slice(),
)?)
let config = get_tedge_config().unwrap();
let limit = config.query(SoftwarePluginMaxPackagesSetting).unwrap().0;
Copy link
Member

Choose a reason for hiding this comment

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

This unwrap() is safe because config.query(SoftwarePluginMaxPackagesSetting) returns always Ok. However, it is always recommended to add a comment why it's safe when you use unwrap().

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 with @rina23q comment: using unwrap() here is unsafe and also buggy as the config might be stored in a non-default location. The correct way to implement that would be to do the same as for the default plugin type: to let the agent read the config and provide the TEdgeConfig value to the plugin. But as this PR is open since quite a long time, I'm okay to have this done in a following PR.


Apply both filters
${packages_list}= Execute Command
... sudo /etc/tedge/sm-plugins/apt list --name sudo --maintainer thin-edge.*
Copy link
Member

Choose a reason for hiding this comment

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

Why the name is sudo? Using it as an example package name which doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, quite the opposite. Filters work here like union so I wanted to show that when we use it with the maintainer filter set to thin-edge, it will print not only all the tedge packages but also sudo package. And I think we can safely assume that the sudo package will be available (In fact, it is even used when executing the test command).

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.

Here the list of changes to make this PR using the new tedge config.

Ruadhri17 and others added 5 commits June 2, 2023 11:50
Signed-off-by: Krzysztof Piotrowski <Krzysztof.Piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <Krzysztof.Piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <Krzysztof.Piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <Krzysztof.Piotrowski@inetum.com>
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request June 2, 2023 12:00 — 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.

Follow-up tasks:

  • The ExternalPluginCommand::list() method must not assume the config is at the default location.
  • Consider to manage the name and maintainer filters with tedge config.

@didier-wenzek didier-wenzek merged commit b4f6ca3 into thin-edge:main Jun 2, 2023
17 checks passed
@Ruadhri17 Ruadhri17 deleted the apt-list-filtering branch June 26, 2023 14:37
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

6 participants