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

Handle software updates discovery errors #2532

Merged
merged 4 commits into from
Apr 19, 2024

Conversation

nelsonkopliku
Copy link
Member

@nelsonkopliku nelsonkopliku commented Apr 18, 2024

Description

This PR handles software updates discovery errors by dispatching an unknown health.

Cleaned a bit up error propagation.

How was this tested?

Automated tests.

@nelsonkopliku nelsonkopliku force-pushed the handle-software-updates-discovery-errors branch from f930a0d to 0307ce6 Compare April 18, 2024 12:26
@nelsonkopliku nelsonkopliku self-assigned this Apr 18, 2024
@nelsonkopliku nelsonkopliku added enhancement New feature or request elixir Pull requests that update Elixir code labels Apr 18, 2024
@nelsonkopliku nelsonkopliku marked this pull request as ready for review April 18, 2024 12:31
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Hey @nelsonkopliku ,
I find the change overly complex.
Why not simply dispatch the command and returning the error?

In fact, the dispatch error case looks a bit over defensive. Our system won't send this command to any host that is not already registered.

I mean, if in the unknown state, if we receive host_not_registered (I don't know when), who cares, we still need to return the original error. At the end, we just want to know if there was an error or not. We don't use the specifics anywhere. I mean, what use has this dispatching error (that why the way, you don't send with the same format for the correct flow of it fails)?

Logger.error(
"An error occurred during software updates discovery for host #{host_id}: #{inspect(error)}"
)

{:error, error}
dispatch_completion_command_on_discovery_error(host_id, discovery_error)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand a thing 😅
Wasn't as simple as putting the the dispatch with the unknown state in the else side?

commanded().dispatch(
      CompleteSoftwareUpdatesDiscovery.new!(%{
        host_id: host_id,
        health: SoftwareUpdatesHealth.unknown()
    })
)

error

Copy link
Member Author

@nelsonkopliku nelsonkopliku Apr 18, 2024

Choose a reason for hiding this comment

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

that's where I started from, honestly.

I wanted to avoid dispatching a CompleteSoftwareUpdatesDiscovery command with unknown when the failure was not a discovery failure, but an error in dispatching CompleteSoftwareUpdatesDiscovery after a successful discovery, as mentioned in the description.

I'd be fine also with that dispatch in the else side 🙈

@nelsonkopliku
Copy link
Member Author

@arbulu89 thanks for the review, I applied the simplified version.
I maybe have some PTSD on over-simplifying things and unwanted side effects 😅

Copy link
Contributor

@arbulu89 arbulu89 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!
PD: This will conflict with my other PR:#2531
But we can fix the conflicts afterwards

@nelsonkopliku nelsonkopliku merged commit 8e238cf into main Apr 19, 2024
26 checks passed
@nelsonkopliku nelsonkopliku deleted the handle-software-updates-discovery-errors branch April 19, 2024 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elixir Pull requests that update Elixir code enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants