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

Add a scheduled software updates discovery job #2376

Merged
merged 6 commits into from
Mar 4, 2024

Conversation

nelsonkopliku
Copy link
Member

@nelsonkopliku nelsonkopliku commented Feb 29, 2024

Description

This PR adds the capability to discover software updates for all the registered hosts in trento.
This has been scheduled to happen every 12 hours.

How was this tested?

Automated tests.

@nelsonkopliku nelsonkopliku added enhancement New feature or request user story elixir Pull requests that update Elixir code labels Feb 29, 2024
@nelsonkopliku nelsonkopliku self-assigned this Feb 29, 2024
@nelsonkopliku nelsonkopliku force-pushed the suma-discovery-watcher branch 6 times, most recently from 0d30751 to 2afc779 Compare March 1, 2024 11:16
@nelsonkopliku nelsonkopliku marked this pull request as ready for review March 1, 2024 11:19
Copy link
Contributor

@jamie-suse jamie-suse left a comment

Choose a reason for hiding this comment

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

beautiful 👌

Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

LGTM with a nitpick

Comment on lines 25 to 33
def discover_software_updates,
do:
{:ok,
Hosts.get_all_hosts()
|> Enum.map(&discover_host_software_updates/1)
|> Enum.split_with(fn
{:ok, _, :discovered, _, _} -> true
_ -> false
end)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you just return [] over an erroring discovery? you can keep the logging and you just have to Enum.flatten this list instead of playing with tagged tuples.

Copy link
Member Author

Choose a reason for hiding this comment

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

When testing I want to rely on the output of the function, rather than logging 😅 That's the reason behind it.

We could alternatively return just one list with all the discovery results, successful and errored. However we'd need to do filtering of successful vs errored results in the test to make meaningful assertions. We get that distinction for free by splitting here. I find it convenient.

I simplified a bit the tuple returned in success case from {:ok, host_id, :discovered, system_id, relevant_patches} to {:ok, host_id, system_id, relevant_patches} 👍

@nelsonkopliku nelsonkopliku merged commit 75776e9 into main Mar 4, 2024
24 checks passed
@nelsonkopliku nelsonkopliku deleted the suma-discovery-watcher branch March 4, 2024 08:09
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 user story
Development

Successfully merging this pull request may close these issues.

None yet

3 participants