Skip to content

Commit

Permalink
fix(System): now we are trying make a request to another primary mast…
Browse files Browse the repository at this point in the history
…ers if first one did not responded correctrly [#529]
  • Loading branch information
vrozaev committed Jun 18, 2024
1 parent cac41b4 commit b59be7f
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions packages/ui/src/ui/store/actions/system/masters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Toaster} from '@gravity-ui/uikit';

import createActionTypes from '../../../constants/utils';
import {isRetryFutile} from '../../../utils';
import {getBatchError, showErrorPopup} from '../../../utils/utils';
import {getBatchError, showErrorPopup, splitBatchResults} from '../../../utils/utils';

import {YTErrors} from '../../../rum/constants';
import {YTApiId, ytApiV3Id} from '../../../rum/rum-wrap-api';
Expand Down Expand Up @@ -110,29 +110,41 @@ async function loadMastersConfig(): Promise<[MastersConfigResponse, MasterAlert[

const alerts = alertsResult.output ? (alertsResult.output as MasterAlert[]) : [];
const [timestamp_path] = [...Object.keys(ypath.getValue(timestampProvidersResult.output))];
const [primary_path] = [...Object.keys(ypath.getValue(primaryMasterResult.output))];
const primaryMasterPaths = [...Object.keys(ypath.getValue(primaryMasterResult.output))];

const tag_cell_requests = [
const timestamp_tag_cell_requests = [
{
command: 'get' as const,
parameters: {
path: `//sys/primary_masters/${primary_path}/orchid/config/primary_master/cell_id`,
path: `//sys/timestamp_providers/${timestamp_path}/orchid/config/clock_cell`,
...USE_SUPRESS_SYNC,
},
},
{
];

const tag_cell_requests = primaryMasterPaths.map((primary_path) => {
return {
command: 'get' as const,
parameters: {
path: `//sys/timestamp_providers/${timestamp_path}/orchid/config/clock_cell`,
path: `//sys/primary_masters/${primary_path}/orchid/config/primary_master/cell_id`,
...USE_SUPRESS_SYNC,
},
},
];
};
});

const [primaryMasterCellTag, timestampProviderCellTag] = await ytApiV3Id.executeBatch(
YTApiId.systemMastersConfig,
{requests: [...tag_cell_requests]},
);
const [timestampProviderCellTag, ...primaryMasterCellTagResponse] =
await ytApiV3Id.executeBatch(YTApiId.systemMastersConfig, {
requests: [...timestamp_tag_cell_requests, ...tag_cell_requests],
});

const {
results: [masterCellId],
error: primaryMasterCellTagError,
} = splitBatchResults(primaryMasterCellTagResponse, 'Failed to get primary master cell_id');

if (!masterCellId) {
throw primaryMasterCellTagError;
}

const primaryMaster = primaryMasterResult.output;
const secondaryMasters = secondaryMastersResult.output;
Expand Down Expand Up @@ -165,8 +177,8 @@ async function loadMastersConfig(): Promise<[MastersConfigResponse, MasterAlert[
attributes: ypath.getValue(value, '/@'),
};
}),
cellId: primaryMasterCellTag.output,
cellTag: getCellIdTag(primaryMasterCellTag.output),
cellId: masterCellId,
cellTag: getCellIdTag(masterCellId),
},
secondaryMasters: _.map(secondaryMasters, (addresses, cellTag) => {
return {
Expand Down

0 comments on commit b59be7f

Please # to comment.