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 12, 2024
1 parent cac41b4 commit 1ab7de7
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions packages/ui/src/ui/store/actions/system/masters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {YTApiId, ytApiV3Id} from '../../../rum/rum-wrap-api';
import {USE_SUPRESS_SYNC} from '../../../../shared/constants';
import type {AxiosError} from 'axios';
import type {Dispatch} from 'redux';
import type {BatchSubRequest} from '../../../../shared/yt-types';
import type {BatchResultsItem, BatchSubRequest} from '../../../../shared/yt-types';
import type {
MasterAlert,
MasterDataItemInfo,
Expand Down Expand Up @@ -110,16 +110,9 @@ 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 = [
{
command: 'get' as const,
parameters: {
path: `//sys/primary_masters/${primary_path}/orchid/config/primary_master/cell_id`,
...USE_SUPRESS_SYNC,
},
},
const timestamp_tag_cell_requests = [
{
command: 'get' as const,
parameters: {
Expand All @@ -129,11 +122,39 @@ async function loadMastersConfig(): Promise<[MastersConfigResponse, MasterAlert[
},
];

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


let primaryMasterCellTag: BatchResultsItem<any> | undefined;

for (const primary_path of primaryMasterPaths) {
const tag_cell_requests = [
{
command: 'get' as const,
parameters: {
path: `//sys/primary_masters/${primary_path}/orchid/config/primary_master/cell_id`,
...USE_SUPRESS_SYNC,
},
},
];

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

if (primaryMasterCellTag && primaryMasterCellTag.output) {
break;
}
}

if (!primaryMasterCellTag?.output) {
throw primaryMasterCellTag?.error;
}

const primaryMaster = primaryMasterResult.output;
const secondaryMasters = secondaryMastersResult.output;

Expand Down

0 comments on commit 1ab7de7

Please # to comment.