Skip to content

Commit

Permalink
revert: "chore(System): do not request data from endpoints with "main…
Browse files Browse the repository at this point in the history
…tenance" attribute"

This reverts commit f36cc69.
  • Loading branch information
vrozaev committed Jan 29, 2025
1 parent 1cb8822 commit b052987
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
47 changes: 11 additions & 36 deletions packages/ui/src/ui/store/actions/system/masters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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, CypressNode} from '../../../../shared/yt-types';
import type {BatchSubRequest} from '../../../../shared/yt-types';
import {
MasterAlert,
MasterDataItemInfo,
Expand All @@ -26,7 +26,6 @@ import {
} from '../../reducers/system/masters';
import {ThunkAction} from 'redux-thunk';
import type {RootState} from '../../reducers';
import {ValueOf} from '../../../../@types/types';

export const FETCH_MASTER_CONFIG = createActionTypes('MASTER_CONFIG');
export const FETCH_MASTER_DATA = createActionTypes('MASTER_DATA');
Expand All @@ -36,24 +35,6 @@ const toaster = new Toaster();

const {NODE_DOES_NOT_EXIST} = YTErrors;

export function filterOutMaintananceHosts(
value: Record<string, CypressNode<{maintenance?: boolean}, string>> | null,
) {
if (!value) {
return {};
}

return Object.keys(value).reduce(
(acc, key) => {
if (!value[key].$attributes?.maintenance) {
acc[key] = value[key];
}
return acc;
},
{} as Record<string, ValueOf<typeof value>>,
);
}

async function loadMastersConfig(): Promise<[MastersConfigResponse, MasterAlert[]]> {
const requests = [
{
Expand Down Expand Up @@ -136,12 +117,8 @@ async function loadMastersConfig(): Promise<[MastersConfigResponse, MasterAlert[
}

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

const timestamp_tag_cell_requests = [
{
Expand Down Expand Up @@ -231,7 +208,7 @@ async function loadMastersConfig(): Promise<[MastersConfigResponse, MasterAlert[
};

const discoveryRequests = map_(
filterOutMaintananceHosts(ypath.getValue(discoveryServersResult.output)),
ypath.getValue(discoveryServersResult.output),
(_v, address) => ({
command: 'get' as const,
parameters: {
Expand All @@ -243,7 +220,7 @@ async function loadMastersConfig(): Promise<[MastersConfigResponse, MasterAlert[
);

const queueAgentsStateRequests = map_(
filterOutMaintananceHosts(ypath.getValue(queueAgentsResult.output)),
ypath.getValue(queueAgentsResult.output),
(_v, address) => ({
command: 'get' as const,
parameters: {
Expand Down Expand Up @@ -343,14 +320,12 @@ function loadHydra(

forEach_(
sortBy_(addresses, (address) => address.host),
({host, attributes}) => {
if (!attributes.maintanance) {
masterInfo.push({host, type, cellTag: cellTag!});
requests.push({
command: 'get',
parameters: {path: cypressPath + '/' + host + hydraPath, ...USE_SUPRESS_SYNC},
});
}
({host}) => {
masterInfo.push({host, type, cellTag: cellTag!});
requests.push({
command: 'get',
parameters: {path: cypressPath + '/' + host + hydraPath, ...USE_SUPRESS_SYNC},
});
},
);
}
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/ui/store/reducers/system/masters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export interface MasterAddress {
attributes: {
native_cell_tag: number;
annotations: unknown;
maintanance: boolean;
};
state?: 'online' | 'offline' | 'unknown';
}
Expand Down

0 comments on commit b052987

Please sign in to comment.