Skip to content

fix: Ignore extra HealthStatus fields in service monitor (maintain single HealthStatus)#3133

Closed
Bravo555 wants to merge 2 commits intothin-edge:mainfrom
Bravo555:fix/3128/health-ignore-pid-in-mapper-big-health
Closed

fix: Ignore extra HealthStatus fields in service monitor (maintain single HealthStatus)#3133
Bravo555 wants to merge 2 commits intothin-edge:mainfrom
Bravo555:fix/3128/health-ignore-pid-in-mapper-big-health

Conversation

@Bravo555
Copy link
Copy Markdown
Member

Proposed changes

This is an alternative fix to #3132. It contains the same test, but differs in the approach to how we should deserialize HealthStatus.

In #3132, we use separate structs in tedge_api and tedge_watchdog. This allows each component to deserialize only mapper and watchdog to deserialize only fields they require, but could be argued duplicates structs and makes it harder to see what are possible fields for this type of message because they're spread out.

In this PR, an alternative approach is taken where we use a single tedge_api::HealthStatus struct which just fills in a fallback None on deserialization errors for other fields. Here we keep all the fields in a single place but ignore errors, which is not desirable. I thought it's going to be more complex but it turned out simpler than I anticipated.

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

Features were added because without them it was impossible to build and
check `tedge-watchdog` by itself using a `-p` flag, i.e: `cargo build -p
tedge-watchdog` (`hide_env_values` requires `env` and `default_value`
variant that uses `OsString` required `string`)

Note that adding these features in workspace Cargo.toml should not add
more code to the binary as these features were already used because
other crate required them, so the only clap instance we're pulling have
these enabled. Only now we're making these features available to all the
workspace crates (including tedge-watchdog).

Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
…al values

Allows deserialization of HealthStatus to succeed if errors happen on
some fields (e.g. PID is not a number). This is achieved by the
`NoneIfErr` deserialization wrapper that ignores errors and puts in
`None` instead.

Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files

📢 Thoughts on this report? Let us know!

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.

Thank you for this alternative implementation for #3132.

Pros (of this proposal):

  • A single HealthStatus struct
  • More natural if the watchdog is fixed to use the status field.

Cons:

  • More complex, even if simpler than what you were expecting.
  • It's really not obvious that the mapper uses only the status field and the watchdog the pid and time fields.

For the latter point, I finally prefer the first proposal i.e. #3132.

@Bravo555 What's your point of view?

@github-actions
Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
505 0 2 505 100 1h34m13.096081s

@Bravo555
Copy link
Copy Markdown
Member Author

@Bravo555 What's your point of view?

If the team prefers the first proposal we can go with it, there's not much code built on top so we're free to change it later if it's no longer fit for purpose.

As for addressing the status field in tedge_watchdog, can be done in a follow-up PR.

@didier-wenzek
Copy link
Copy Markdown
Contributor

If the team prefers the first proposal we can go with it, there's not much code built on top so we're free to change it later if it's no longer fit for purpose.

I'm okay first the first proposal. Approving it.

@reubenmiller reubenmiller changed the title Ignore extra HealthStatus fields in service monitor (maintain single HealthStatus) fix: Ignore extra HealthStatus fields in service monitor (maintain single HealthStatus) Sep 24, 2024
@reubenmiller reubenmiller added the theme:monitoring Theme: Service monitoring and watchdogs label Sep 24, 2024
@Bravo555 Bravo555 closed this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:monitoring Theme: Service monitoring and watchdogs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants