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 requests for software updates discoveries from Host aggregate #2507

Merged

Conversation

nelsonkopliku
Copy link
Member

@nelsonkopliku nelsonkopliku commented Apr 10, 2024

Description

Yet another alternative to #2505 and #2506

This PR moves the logic for software updates discovery inside the host aggregate which is going to emit a SoftwareUpdatesDiscoveryRequested in the following scenarios:

  • when a host is registered
  • when a host is restored
  • when the fqdn of a host changes

Additionally when the fqdn of the host transitions from a meaningful value to null we take care of dispatching a ClearSoftwareUpdatesDiscovery for clean up purposes.

Following this we will have a SoftwareUpdatesDiscoveryEventHandler listening to SoftwareUpdatesDiscoveryRequested getting information from suma and dispatching back a CompleteSoftwareUpdatesDiscovery command

When implementing the new event handler some minor changes to Trento.SoftwareUpdates.Discovery might be needed. Here's some reference

How was this tested?

Automated tests

@nelsonkopliku nelsonkopliku self-assigned this Apr 10, 2024
@nelsonkopliku nelsonkopliku added the enhancement New feature or request label Apr 10, 2024
@nelsonkopliku nelsonkopliku marked this pull request as ready for review April 10, 2024 16:12
@nelsonkopliku nelsonkopliku force-pushed the trigger-software-updates-process-from-host-aggregate branch from f2e0b02 to c64dcca Compare April 10, 2024 16:19
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 ,
The approach looks correct.
Just a couple of things:

  • we don't need to use the multi as we don't need to get any change from previous events in this event
  • i think we can simply the new maybe_ functions, solution proposed

Besides that, all good

lib/trento/hosts/host.ex Outdated Show resolved Hide resolved
lib/trento/hosts/host.ex Outdated Show resolved Hide resolved
lib/trento/hosts/host.ex Outdated Show resolved Hide resolved
test/trento/hosts/host_test.exs Outdated Show resolved Hide resolved
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 ,
As the solution you propose is correct, I'm giving a green light.
I proposed other solution that I think is better (my opinion).
But in any case, it is ok to move forward

@nelsonkopliku
Copy link
Member Author

Hey @nelsonkopliku , As the solution you propose is correct, I'm giving a green light. I proposed other solution that I think is better (my opinion). But in any case, it is ok to move forward

Here we go @arbulu89 772f280, thanks for the feedback

@nelsonkopliku nelsonkopliku merged commit b3a7b64 into main Apr 12, 2024
24 checks passed
@nelsonkopliku nelsonkopliku deleted the trigger-software-updates-process-from-host-aggregate branch April 12, 2024 10:07
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 @nelsonkopliku ,
Good job

] ++
maybe_emit_software_updates_discovery_events(
host_id,
current_fully_qualified_domain_name,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this 2nd argument be nil here?
I mean, I understood that in this circunstance we don't want to emit the Cleared event, but if the new fqdn is nil, and we had a value before (current), it would be emitted, or not?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, I guess I missed that test.
Here we go #2518
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

None yet

2 participants