-
Notifications
You must be signed in to change notification settings - Fork 15
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
Send and receive explicit restoration events #1673
Conversation
fb8e403
to
c50ee6b
Compare
cluster_restored
& sap_system_restored
websocket eventsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to preload the database_instances
in the database restoration and maybe change the view
@@ -341,11 +341,11 @@ defmodule Trento.SapSystemProjector do | |||
sap_system = | |||
SapSystemReadModel | |||
|> Repo.get!(sap_system_id) | |||
|> Repo.preload([:tags]) | |||
|> Repo.preload([:tags, :database_instances, :application_instances]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I noticed here as that we could even do this:
@impl true
def after_update(
%SapSystemRestored{},
_,
%{sap_system: %SapSystemReadModel{} = sap_system}
) do
enriched_sap_system =
Repo.preload(sap_system, [
:application_instances,
:database_instances,
:tags
])
....
I mean, we don't need to query, as the read model already comes in the 3rd parameter of the after_update
.
Not a big deal though.
@@ -306,7 +306,7 @@ defmodule Trento.DatabaseProjector do | |||
|
|||
TrentoWeb.Endpoint.broadcast( | |||
@databases_topic, | |||
"database_registered", | |||
"database_restored", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you need to preload the database_instances
160f81b
to
0d5d2e2
Compare
@@ -36,7 +36,7 @@ context('Databases Overview', () => { | |||
cy.contains('div', hdqDatabase.instances[1].name).should('exist'); | |||
}); | |||
|
|||
it('should show the ACTIVE pill in the right host', () => { | |||
it.skip('should show the ACTIVE pill in the right host', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this test is for bug TRNT-2357.
This skip
needs to be removed is the PR fixing that bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mamma mia...
How we have ended like this now? 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many comments...
The PR is pretty huge, so I don't know if I missed something..
@@ -102,6 +102,7 @@ export const clustersListSlice = createSlice({ | |||
}); | |||
|
|||
export const CLUSTER_DEREGISTERED = 'CLUSTER_DEREGISTERED'; | |||
export const CLUSTER_RESTORED = 'CLUSTER_RESTORED'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a new line after this?
@@ -30,6 +30,12 @@ export const databasesListSlice = createSlice({ | |||
appendDatabaseInstance: (state, action) => { | |||
state.databaseInstances = [...state.databaseInstances, action.payload]; | |||
}, | |||
upsertDatabaseInstances: (state, action) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like this now.
I think that the filterByInstances
should be changed to be upsertInstances
and include the concat there.
In fact, I think we should remove the upsertDatabaseInstance
and only leave upsertDatabaseInstances
, because the we have the risk for appending already existing instances with the previous function (I would even leave appendDatabaseInstances
as it is easier to understand)
So I would replace the plural usage everywhere
assets/js/state/sagas/clusters.js
Outdated
yield put(appendCluster(payload)); | ||
yield put( | ||
notify({ | ||
text: `Cluster, ${payload.name}, has been restored.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abravosuse Do we want to use this notifications with the restoration
wording, or should we still use registered
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the ,
s
assets/js/state/sagas/index.js
Outdated
yield debounce( | ||
debounceDuration, | ||
HOST_DEREGISTERED, | ||
loadSapSystemsHealthSummary | ||
); | ||
yield debounce(debounceDuration, HOST_RESTORED, loadSapSystemsHealthSummary); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this formatted?
Anyway, the order of things looks unsorted.
Could we maybe have all deregistered
first and all restored
afterwards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the formatter keeps one-line-ing it 🤦♂️.
Moved all the restored
events below the deregistered
events 👍.
I notice there is not a listener here for DATABASE_DEREGISTERED
, should this be added in?
assets/js/state/sapSystems.test.js
Outdated
const action = upsertDatabaseInstances(newInstances); | ||
|
||
const expectedState = { | ||
databaseInstances: initialState.databaseInstances |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really complex...
Cannot we have a fixed expected thing so everyone can understand in a first glance what's going on?
|> Repo.preload([ | ||
:tags, | ||
:database_instances, | ||
database_instances: [host: :tags], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this host and tags
preloaded instances?
Why do we even need to have them twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just included them otherwise the JSON serialiser was complaining.
Why do we even need to have them twice?
One is the :tags
for the DatabaseReadModel
, the other is :tags
for HostReadModel
.
I can see how to remove the HostReadModel
tags if it's not desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we need to fix the view them, not add database_instances
twice loading hosts that we don't need, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you don't want to include the hosts data from database_instances
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why we need it?
We don't use it in the frontend as far as I know
@@ -36,7 +36,7 @@ context('Databases Overview', () => { | |||
cy.contains('div', hdqDatabase.instances[1].name).should('exist'); | |||
}); | |||
|
|||
it('should show the ACTIVE pill in the right host', () => { | |||
it.skip('should show the ACTIVE pill in the right host', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mamma mia...
How we have ended like this now? 😭
@@ -40,7 +40,6 @@ defmodule TrentoWeb.V1.SapSystemView do | |||
database | |||
|> Map.from_struct() | |||
|> Map.delete(:__meta__) | |||
|> Map.delete(:database_instances) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, here we might want to use add_system_replication_status_to_secondary_instance
so we put the pills properly.
We need to see how it behaves
475fe2f
to
37b6681
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Just a couple of last comments, but you don't need a new review.
I hope you tested how it works manually as well 😉
@@ -70,6 +71,17 @@ export function* databaseDeregistered({ payload }) { | |||
); | |||
} | |||
|
|||
export function* databaseRestored({ payload }) { | |||
yield put(appendDatabase(payload)); | |||
yield put(upsertDatabaseInstances(payload.database_instances)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need yield put(upsertDatabaseInstancesToSapSystem([payload]));
here?
@@ -302,11 +302,11 @@ defmodule Trento.DatabaseProjector do | |||
database = | |||
DatabaseReadModel | |||
|> Repo.get!(sap_system_id) | |||
|> Repo.preload([:tags]) | |||
|> Repo.preload([:tags, :database_instances, [database_instances: :host]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this [database_instances: :host]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @jamie-suse
Description
Previously, when a restoration occurred on the backend,
*_registered
events were being sent. Now we need to explicitly send events indicating that a restoration (*_restored
event) has occurred.sap_system_restored
anddatabase_restored
events also senddatabase_instances
(and additionallyapplication_instances
, in the case ofsap_system_restored
) data, which is required to update the UI.Fixes TRNT-2355
How was this tested?
Updated projector tests to ensure they send the new events.
Added tests for new Sagas and new SAP systems reducer functions.