prabhjyotsingh commented on code in PR #4263:
URL: https://github.com/apache/ambari/pull/4263#discussion_r4551299781
##########
ambari-web/latest/src/screens/Hosts/bulkRecoverHosts.test.tsx:
##########
@@ -274,6 +278,32 @@ describe("bulk Recover Hosts flow", () => {
expect(mocks.show.mock.calls[1][0].type).toBe(BackgroundOperations);
});
+ it("re-checks recoverability against every component on the host, not just a
filtered subset", async () => {
+ // The "Filtered Hosts" selection narrows the first fetch to the
+ // filtered component. h1's filtered view looks fully recoverable, but
+ // the unfiltered refetch exposes a second, non-recoverable component on
+ // the same host, so h1 must be skipped and only its filtered component
+ // must never be reinstalled on its own.
+ mocks.batchRequest.mockResolvedValue(scheduleResponse(7));
+ const getKDCSessionState = await openRecoverConfirmation(
+ [apiHost("h1", [component("DATANODE", "INSTALLED")])],
+ [
+ apiHost("h1", [
+ component("DATANODE", "INSTALLED"),
+ component("NODEMANAGER", "STARTED"),
+ ]),
+ ]
+ );
+
+ expect(mocks.getHostComponents).toHaveBeenCalledTimes(1);
Review Comment:
`toHaveBeenCalledTimes(1)` only shows the refetch happened. Please also
assert on the request it sends: the query should contain
`Hosts/host_name.in(h1)` and no `host_components/HostRoles/component_name` or
`service_name` filter. Without that, a later change could carry the filter into
the refetch and this test would still pass.
##########
ambari-web/latest/src/screens/Hosts/bulkOperations.tsx:
##########
@@ -155,11 +155,33 @@ const getHostsForBulkOperationSuccessCallback = (
return;
}
- if (
- ["SET_RACK_INFO", "ADD", "DELETE", "RECOVER_HOST"].includes(
- operationData.action
- )
- ) {
+ if (operationData.action === "RECOVER_HOST") {
+ // The host list above may have been fetched with a component/service
+ // filter applied (selection === "filtered"), which narrows each host's
+ // host_components to only the matching component. Recoverability must be
+ // judged on every component on the host, so refetch host_components here
+ // with no component/service filter before partitioning or building
batches.
+ const data = {
+ hosts: hosts.map((host: any) => host.hostName),
+ displayParams: [
+ "host_components/HostRoles/component_name",
+ "host_components/HostRoles/state",
+ ],
+ };
+ getComponentsFromServer(data, clusterName, (responseData: any) => {
+ bulkOperation(
+ operationData,
+ convertHostsObjects(responseData),
+ clusterName,
+ serviceComponentInfo,
+ serviceModels,
+ getKDCSessionState
+ );
+ });
+ return;
+ }
+
+ if (["SET_RACK_INFO", "ADD", "DELETE"].includes(operationData.action)) {
Review Comment:
Possible follow-up, not for this PR: bulk host `DELETE`
(`bulkOperationForHostsDelete`) still uses the hosts from the first fetch. It
decides which components block deletion from `host.allHostComponents`, so with
a component/service filter active, master or running components on a host might
be hidden from that check, the same way recovery was affected here. I haven't
confirmed this on a cluster. Could you check and file a separate JIRA if it
reproduces?
##########
ambari-web/latest/src/screens/Hosts/bulkOperations.tsx:
##########
@@ -155,11 +155,33 @@ const getHostsForBulkOperationSuccessCallback = (
return;
}
- if (
- ["SET_RACK_INFO", "ADD", "DELETE", "RECOVER_HOST"].includes(
- operationData.action
- )
- ) {
+ if (operationData.action === "RECOVER_HOST") {
Review Comment:
Nit: this refetch runs for every selection type, not only `filtered`. For
`selected`/`all` the first response is already complete, so it costs one extra
request. Always refetching is simpler and I'm fine keeping it. Maybe reword the
comment to say it always runs ("may have been fetched with a filter" reads as
if it's conditional).
##########
ambari-web/latest/src/screens/Hosts/bulkRecoverHosts.test.tsx:
##########
@@ -274,6 +278,32 @@ describe("bulk Recover Hosts flow", () => {
expect(mocks.show.mock.calls[1][0].type).toBe(BackgroundOperations);
});
+ it("re-checks recoverability against every component on the host, not just a
filtered subset", async () => {
Review Comment:
This covers the skip half of the bug (a hidden STARTED component). Could you
also add a case for the other half named in the title: the filtered view shows
`DATANODE` INSTALLED, and the refetch returns `DATANODE` + `NODEMANAGER`, both
INSTALLED. Then assert that both `batchRequest` steps (INIT and INSTALLED) use
`HostRoles/component_name.in(DATANODE,NODEMANAGER)`. That's the path that would
wrongly reinstall only part of the host.
A failure case would also help: `getHostComponents` rejects → the error
modal shows, and `show` / `batchRequest` / `getKDCSessionState` are never
called.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]