DomGarguilo commented on code in PR #5894:
URL: https://github.com/apache/accumulo/pull/5894#discussion_r2433600134
##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/manager.js:
##########
@@ -23,56 +23,29 @@
*/
"use strict";
-var managerStatusTable, recoveryListTable;
+var managerStatusTable, recoveryListTable, managerStatus;
function refreshManagerBanners() {
- getStatus().then(function () {
- const managerStatus = JSON.parse(sessionStorage.status).managerStatus;
-
- // If manager status is error
- if (managerStatus === 'ERROR') {
- // show the manager error banner and hide table
- $('#managerRunningBanner').show();
- $('#managerStatus_wrapper').hide();
- } else {
- // otherwise, hide the error banner and show manager table
- $('#managerRunningBanner').hide();
- $('#managerStatus_wrapper').show();
- }
- });
-
- getManager().then(function () {
- const managerData = JSON.parse(sessionStorage.manager);
- const managerState = managerData.managerState;
- const managerGoalState = managerData.managerGoalState;
-
- const isStateGoalSame = managerState === managerGoalState;
-
- // if the manager state is normal and the goal state is the same as the
current state,
- // or of the manager is not running, hide the state banner and return early
- if ((managerState === 'NORMAL' && isStateGoalSame) || managerState ===
null) {
- $('#managerStateBanner').hide();
- return;
- }
-
- // update the manager state banner message and show it
- let bannerMessage = 'Manager state: ' + managerState;
- if (!isStateGoalSame) {
- // only show the goal state if it differs from the manager's current
state
- bannerMessage += '. Manager goal state: ' + managerGoalState;
- }
- $('#manager-banner-message').text(bannerMessage);
- $('#managerStateBanner').show();
- });
-
+ // If manager status is error
+ if (managerStatus === 'ERROR') {
+ // show the manager error banner and hide manager table
+ $('#managerRunningBanner').show();
+ $('#managerStatusTable').hide();
+ } else {
+ // otherwise, hide the error banner and show manager table
+ $('#managerRunningBanner').hide();
+ $('#managerStatusTable').show();
+ }
}
/**
* Populates tables with the new information
*/
function refreshManagerTables() {
- ajaxReloadTable(managerStatusTable);
refreshManagerBanners();
+ if (managerStatus !== 'ERROR') {
+ ajaxReloadTable(managerStatusTable);
+ }
ajaxReloadTable(recoveryListTable);
}
Review Comment:
There are some things we need to fix here I think. If the manager process is
killed after the page loads, the table still tries to refresh since we do not
update the `managerStatus` variable. Also the table will never update properly
for the same reason.
I think to fix this we could refactor out the creation logic for the
`managerStatusTable` so we can call it in the `$()` function (where the table
is created now) as well as in the `refreshManagerTables` function after we
refresh `managerStatus` by calling `getStatus()` again and updating
`managerStatus` by parsing the session storage again.
--
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]