Skip to content

fix: make device profile skip field optional and skip operation fragment when it is set to true #3417

Merged
Ruadhri17 merged 3 commits intothin-edge:mainfrom
Ruadhri17:device-profile-optional-skip
Mar 3, 2025
Merged

fix: make device profile skip field optional and skip operation fragment when it is set to true #3417
Ruadhri17 merged 3 commits intothin-edge:mainfrom
Ruadhri17:device-profile-optional-skip

Conversation

@Ruadhri17
Copy link
Copy Markdown
Contributor

Proposed changes

This PR fixes an issue where the skip field in the device profile was treated as mandatory by serde. Now, if the field is omitted, it defaults to false. Additionally, the field has been renamed to @skip so that it is properly recognized by the workflow and aligns with our documentation. Finally, this PR addresses a problem where the mapper did not verify whether an operation fragment sent to the cloud was marked as skipped.

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

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 24, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
583 0 3 583 100 1h33m52.013136999s

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.

minor: The docs still use the keyword skip instead of @skip in one place (The "skip" field is optional and the value is false, by default.)

},
{
"operation": "config_update",
"@skip": true,
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 don't get how this test checks that the config update is skipped, but software & firmware update applied.

Copy link
Copy Markdown
Contributor Author

@Ruadhri17 Ruadhri17 Feb 24, 2025

Choose a reason for hiding this comment

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

If config update has not been skipped, operation fragment message would be sent:

        // Expect `120` smartrest message on `c8y/s/us`.
        assert_received_contains_str(
            &mut mqtt,
            [(
                "c8y/s/us",
                "120,path/config/test-config,http://www.my.url,test-config",
            )],
        )

So it not about checking if config update was skipped (that is already covered by one of our system tests), but more about if we skip fragment message when it is marked as skipped.

pub struct DeviceProfileOperation {
#[serde(flatten)]
pub operation: OperationPayload,
#[serde(default, rename = "@skip")]
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 don't think we can do that now as this has been part of a public API, esp a mandatory field. So, if we change it now, it might affect existing users.

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.

Scratch that. It is indeed @skip that the agent supports:

let skipped = next.get("@skip").and_then(|v| v.as_bool()).unwrap_or(false);

&config.config_type,
&config.server_url.unwrap_or_default(),
Some(&config.name),
if !device_profile_operation.skip {
Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh Feb 25, 2025

Choose a reason for hiding this comment

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

This change is the source of confusion. The actual skip functionality of device profile is not this, but implemented by the agent here:

let skipped = next.get("@skip").and_then(|v| v.as_bool()).unwrap_or(false);

This change only makes sure that the mapper, while processing the successful response, also ignores the operations that are marked to be skipped. But i reality this will never happen as the mapper will never send a request to the agent with an operation marked as skipped, since C8Y doesn't support a skip field. So, all operations received in the c8y_DeviceProfile payload are mapped to tedge operations with @skip field as false. So, it's not going to get a response with an operation skipped either, unless the agent does something weird.

@Ruadhri17 Ruadhri17 force-pushed the device-profile-optional-skip branch from 827ea0b to 9f102ec Compare February 26, 2025 09:55
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request February 26, 2025 09:55 — with GitHub Actions Inactive
@Ruadhri17 Ruadhri17 enabled auto-merge February 26, 2025 09:56
@reubenmiller reubenmiller added the theme:profile Device Profile label Feb 26, 2025
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

@reubenmiller
Copy link
Copy Markdown
Contributor

@Ruadhri17 I'd recommend rebasing as there has been a lot of system test improvements to fix flaky tests (e.g. the two failing tests on the last run have been fixed).

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 force-pushed the device-profile-optional-skip branch from 9f102ec to bd5b275 Compare March 3, 2025 09:46
@Ruadhri17 Ruadhri17 temporarily deployed to Test Pull Request March 3, 2025 09:46 — with GitHub Actions Inactive
@Ruadhri17 Ruadhri17 added this pull request to the merge queue Mar 3, 2025
Merged via the queue into thin-edge:main with commit e85f7f2 Mar 3, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:profile Device Profile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants