diff --git a/packages/ui/src/ui/store/actions/system/masters.ts b/packages/ui/src/ui/store/actions/system/masters.ts index a5cf989bc8..3ca3f012dd 100644 --- a/packages/ui/src/ui/store/actions/system/masters.ts +++ b/packages/ui/src/ui/store/actions/system/masters.ts @@ -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, @@ -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: { @@ -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 | 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;