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

update_agent: remove unused Results #610

Merged
merged 2 commits into from
Jul 29, 2021
Merged

update_agent: remove unused Results #610

merged 2 commits into from
Jul 29, 2021

Conversation

kelvinfan001
Copy link
Member

@kelvinfan001 kelvinfan001 commented Jul 27, 2021

update_agent: remove unused Results

Previously, the tick_ functions returned a Result, but only two
of these functions would ever return the Err variant. Even in the
case where the returned Result was of the Err variant, the caller
does not really do anything with it.

Since we already do a good amount of error logging in the inner
functions, refactor the tick_ functions to return () instead.

update_agent: misc cleanup

For helpers that return a Result, move error logging to the caller
functions.

Refactor register_driver to return (), because errors shouldn't
be returned since #599.

Use anyhow::Result.

Refactor tick_finalize_update to return early to avoid deeply nested
if-else statements.

Previously, the `tick_` functions returned a `Result`, but only two
of these functions would ever return the `Err` variant. Even in the
case where the returned `Result` was of the `Err` variant, the caller
does not really do anything with it.

Since we already do a good amount of error logging in the inner
functions, refactor the `tick_` functions to return `()` instead.
Copy link
Contributor

@lucab lucab left a comment

Choose a reason for hiding this comment

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

Code looks good, I think there are couple of directly related spots where the same cleanup approach can be applied.

src/update_agent/actor.rs Outdated Show resolved Hide resolved
src/update_agent/actor.rs Show resolved Hide resolved
src/update_agent/actor.rs Show resolved Hide resolved
src/update_agent/actor.rs Outdated Show resolved Hide resolved
For helpers that return a `Result`, move error logging to the caller
functions.

Refactor `register_driver` to return `()`, because errors shouldn't
be returned since #599.

Use `anyhow::Result`.

Refactor `tick_finalize_update` to return early to avoid deeply nested
if-else statements.
@lucab lucab enabled auto-merge July 29, 2021 10:10
@lucab lucab merged commit 46bf6c7 into coreos:main Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants