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 unreachable checks execution scenario #304

Merged
merged 14 commits into from
Apr 14, 2022

Conversation

arbulu89
Copy link
Contributor

@arbulu89 arbulu89 commented Apr 6, 2022

Handle the unreachable checks execution scenario.

The implementation was not that simple.

  • New table which stores the hosts states for each execution added
  • The cluster domain changed to store the checks executions in host basis
  • Update the projection to store the new hosts state
  • Update the frontend

Initially, I thought of adding a new NotReached event or similar (actually, some intermediate commits have this code), but eventually I saw that the code was being duplicated, and the only real difference was the name of the event. I thought that it is not enough the hassle.

Please, don't judge the UI, I didn't have enough time to work on it. But I wanted to open the PR on draft so you can have a view while I'm away.

PD: The tests are still missing

Here how it looks like:
unreachable

@arbulu89
Copy link
Contributor Author

Hey @trento-project/developers ,
Did you have the chance to have a look on this PR?
Should I simply work on the conflicts and tests?

@arbulu89 arbulu89 force-pushed the handle-unreachable-execution-state branch from b161dbf to c9d22ae Compare April 11, 2022 16:13
@arbulu89 arbulu89 marked this pull request as ready for review April 11, 2022 16:13
@arbulu89 arbulu89 force-pushed the handle-unreachable-execution-state branch from c9d22ae to 615045c Compare April 12, 2022 08:10

@derive {Jason.Encoder, except: [:__meta__, :__struct__]}
@primary_key false
schema "hosts_checks_results" do
Copy link
Member

Choose a reason for hiding this comment

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

hosts checks results or hosts checks execution?

Copy link
Member

Choose a reason for hiding this comment

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

Between the two I'd prefer HostsChecksExecution.


Just as a discussion triggering point:
I cannot also think about the possibility of it being at the moment just ChecksExecution 🤔
anyway it is bounded to the context of a host, right?

We can refine also on the language and see whether some extra differentiation is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, HostsChecksExecutions looks more appropriate. I think the Hosts prefix helps to identify that the data is Host related (even though it is still a bit abstract to understand what is it about...(

@@ -24,6 +27,7 @@ defmodule Trento.ClusterReadModel do
field :details, :map
field :checks_execution, Ecto.Enum, values: [:not_running, :requested, :running]

has_many :hosts_executions, HostChecksExecutionsReadModel, foreign_key: :cluster_id
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason why we are not nesting check results under checks execution?
is it more ergonomic on the frontend side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was much more hassle to do so, and without big advantages. It forces you to do more hierarchical operations to get the checks (loop through hosts, and them loop through the checks), and as we were already storing the host_id for each check, I thought that it was good enough. In fact, as you commented, it is easier to handle the 2 lists independently in the frontend

Copy link
Member

Choose a reason for hiding this comment

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

Perfect, i was just curious about the rationale. at the end read models are for, well, reading, so it make sense to make them closer to the usecase.

Copy link
Member

@fabriziosestito fabriziosestito left a comment

Choose a reason for hiding this comment

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

Overall great job! some minor changes requested and a doubt on the read model hierarchy

@dottorblaster
Copy link
Contributor

Woh lots of stuff, great! Could you rewrite the history to make the review easier? Thanks!

Copy link
Member

@nelsonkopliku nelsonkopliku left a comment

Choose a reason for hiding this comment

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

Great job!

No big thing from my side, @fabriziosestito already pointed out good comments.

Naming is always difficult and good design too 😄


@derive {Jason.Encoder, except: [:__meta__, :__struct__]}
@primary_key false
schema "hosts_checks_results" do
Copy link
Member

Choose a reason for hiding this comment

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

Between the two I'd prefer HostsChecksExecution.


Just as a discussion triggering point:
I cannot also think about the possibility of it being at the moment just ChecksExecution 🤔
anyway it is bounded to the context of a host, right?

We can refine also on the language and see whether some extra differentiation is needed.

@fabriziosestito fabriziosestito merged commit ab82dac into main Apr 14, 2022
@fabriziosestito fabriziosestito deleted the handle-unreachable-execution-state branch April 14, 2022 07:32
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.

4 participants