Skip to content

Commit

Permalink
Debug health check (cvat-ai#5587)
Browse files Browse the repository at this point in the history
  • Loading branch information
azhavoro authored Jan 17, 2023
1 parent 8f71d90 commit 3fa6f35
Show file tree
Hide file tree
Showing 32 changed files with 1,547 additions and 1,274 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ARG http_proxy
ARG https_proxy
ARG no_proxy
ARG socks_proxy
ARG PUBLIC_INSTANCE
ARG WA_PAGE_VIEW_HIT
ARG UI_APP_CONFIG

ENV TERM=xterm \
http_proxy=${http_proxy} \
Expand Down Expand Up @@ -34,7 +34,7 @@ COPY cvat-core/ /tmp/cvat-core/
COPY cvat-canvas3d/ /tmp/cvat-canvas3d/
COPY cvat-canvas/ /tmp/cvat-canvas/
COPY cvat-ui/ /tmp/cvat-ui/
RUN yarn run build:cvat-ui
RUN UI_APP_CONFIG="${UI_APP_CONFIG}" yarn run build:cvat-ui

FROM nginx:mainline-alpine
# Replace default.conf configuration to remove unnecessary rules
Expand Down
25 changes: 22 additions & 3 deletions cvat-core/src/server-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,32 @@ async function healthCheck(maxRetries, checkPeriod, requestTimeout, progressCall
timeout: requestTimeout,
})
.then((response) => response.data)
.catch((errorData) => {
if (maxRetries > 0) {
.catch((error) => {
let isHealthy = true;
let data;
if (typeof error?.response?.data === 'object') {
data = error.response.data;
// Temporary workaround: ignore errors with media cache for debugging purposes only
for (const checkName in data) {
if (Object.prototype.hasOwnProperty.call(data, checkName) &&
checkName !== 'Cache backend: media' &&
data[checkName] !== 'working') {
isHealthy = false;
}
}
} else {
isHealthy = false;
}

if (!isHealthy && maxRetries > 0) {
return new Promise((resolve) => setTimeout(resolve, checkPeriod))
.then(() => healthCheck(maxRetries - 1, checkPeriod,
requestTimeout, progressCallback, attempt + 1));
}
throw generateError(errorData);
if (isHealthy) {
return data;
}
throw generateError(error);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Input from 'antd/lib/input';

import GlobalHotKeys, { KeyMap } from 'utils/mousetrap-react';

import consts from 'consts';
import config from 'config';

interface InputElementParameters {
clientID: number;
Expand Down Expand Up @@ -51,7 +51,7 @@ function renderInputElement(parameters: InputElementParameters): JSX.Element {
{values.map(
(value: string): JSX.Element => (
<Select.Option key={value} value={value}>
{value === consts.UNDEFINED_ATTRIBUTE_VALUE ? consts.NO_BREAK_SPACE : value}
{value === config.UNDEFINED_ATTRIBUTE_VALUE ? config.NO_BREAK_SPACE : value}
</Select.Option>
),
)}
Expand All @@ -68,7 +68,7 @@ function renderInputElement(parameters: InputElementParameters): JSX.Element {
{values.map(
(value: string): JSX.Element => (
<Radio style={{ display: 'block' }} key={value} value={value}>
{value === consts.UNDEFINED_ATTRIBUTE_VALUE ? consts.NO_BREAK_SPACE : value}
{value === config.UNDEFINED_ATTRIBUTE_VALUE ? config.NO_BREAK_SPACE : value}
</Radio>
),
)}
Expand Down Expand Up @@ -185,7 +185,7 @@ function renderList(parameters: ListParameters): JSX.Element | null {
[key: string]: (keyEvent?: KeyboardEvent) => void;
} = {};

const filteredValues = values.filter((value: string): boolean => value !== consts.UNDEFINED_ATTRIBUTE_VALUE);
const filteredValues = values.filter((value: string): boolean => value !== config.UNDEFINED_ATTRIBUTE_VALUE);
filteredValues.slice(0, 10).forEach((value: string, index: number): void => {
const key = `SET_${index}_VALUE`;
keyMap[key] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
ReloadOutlined,
} from '@ant-design/icons';

import consts from 'consts';
import config from 'config';
import { DimensionType, CombinedState } from 'reducers';
import CanvasWrapperComponent from 'components/annotation-page/canvas/views/canvas2d/canvas-wrapper';
import CanvasWrapper3DComponent, {
Expand Down Expand Up @@ -72,7 +72,7 @@ const fitLayout = (type: DimensionType, layoutConfig: ItemLayout[]): ItemLayout[
const relatedViews = layoutConfig
.filter((item: ItemLayout) => item.viewType === ViewType.RELATED_IMAGE);
const relatedViewsCols = relatedViews.length > 6 ? 2 : 1;
const height = Math.floor(consts.CANVAS_WORKSPACE_ROWS / (relatedViews.length / relatedViewsCols));
const height = Math.floor(config.CANVAS_WORKSPACE_ROWS / (relatedViews.length / relatedViewsCols));
relatedViews.forEach((view: ItemLayout, i: number) => {
updatedLayout.push({
...view,
Expand All @@ -83,7 +83,7 @@ const fitLayout = (type: DimensionType, layoutConfig: ItemLayout[]): ItemLayout[
});
});

let widthAvail = consts.CANVAS_WORKSPACE_COLS;
let widthAvail = config.CANVAS_WORKSPACE_COLS;
if (updatedLayout.length > 0) {
widthAvail -= updatedLayout[0].w * relatedViewsCols;
}
Expand All @@ -96,7 +96,7 @@ const fitLayout = (type: DimensionType, layoutConfig: ItemLayout[]): ItemLayout[
x: 0,
y: 0,
w: widthAvail,
h: consts.CANVAS_WORKSPACE_ROWS,
h: config.CANVAS_WORKSPACE_ROWS,
});
} else {
const canvas = layoutConfig
Expand All @@ -113,25 +113,25 @@ const fitLayout = (type: DimensionType, layoutConfig: ItemLayout[]): ItemLayout[
x: 0,
y: 0,
w: widthAvail,
h: consts.CANVAS_WORKSPACE_ROWS - helpfulCanvasViewHeight,
h: config.CANVAS_WORKSPACE_ROWS - helpfulCanvasViewHeight,
}, {
...top,
x: 0,
y: consts.CANVAS_WORKSPACE_ROWS,
y: config.CANVAS_WORKSPACE_ROWS,
w: Math.ceil(widthAvail / 3),
h: helpfulCanvasViewHeight,
},
{
...side,
x: Math.ceil(widthAvail / 3),
y: consts.CANVAS_WORKSPACE_ROWS,
y: config.CANVAS_WORKSPACE_ROWS,
w: Math.ceil(widthAvail / 3),
h: helpfulCanvasViewHeight,
},
{
...front,
x: Math.ceil(widthAvail / 3) * 2,
y: consts.CANVAS_WORKSPACE_ROWS,
y: config.CANVAS_WORKSPACE_ROWS,
w: Math.floor(widthAvail / 3),
h: helpfulCanvasViewHeight,
});
Expand All @@ -152,8 +152,8 @@ function CanvasLayout({ type }: { type?: DimensionType }): JSX.Element {
containerHeight = window.innerHeight - container.getBoundingClientRect().bottom;
// https://github.com/react-grid-layout/react-grid-layout/issues/628#issuecomment-1228453084
return Math.floor(
(containerHeight - consts.CANVAS_WORKSPACE_MARGIN * (consts.CANVAS_WORKSPACE_ROWS)) /
consts.CANVAS_WORKSPACE_ROWS,
(containerHeight - config.CANVAS_WORKSPACE_MARGIN * (config.CANVAS_WORKSPACE_ROWS)) /
config.CANVAS_WORKSPACE_ROWS,
);
}

Expand Down Expand Up @@ -214,11 +214,11 @@ function CanvasLayout({ type }: { type?: DimensionType }): JSX.Element {
<Layout.Content>
{ !!rowHeight && (
<ReactGridLayout
cols={consts.CANVAS_WORKSPACE_COLS}
maxRows={consts.CANVAS_WORKSPACE_ROWS}
cols={config.CANVAS_WORKSPACE_COLS}
maxRows={config.CANVAS_WORKSPACE_ROWS}
style={{ background: canvasBackgroundColor }}
containerPadding={[consts.CANVAS_WORKSPACE_PADDING, consts.CANVAS_WORKSPACE_PADDING]}
margin={[consts.CANVAS_WORKSPACE_MARGIN, consts.CANVAS_WORKSPACE_MARGIN]}
containerPadding={[config.CANVAS_WORKSPACE_PADDING, config.CANVAS_WORKSPACE_PADDING]}
margin={[config.CANVAS_WORKSPACE_MARGIN, config.CANVAS_WORKSPACE_MARGIN]}
className='cvat-canvas-grid-root'
rowHeight={rowHeight}
layout={layout}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ObjectItemElementComponent from 'components/annotation-page/standard-work
import ObjectItemContainer from 'containers/annotation-page/standard-workspace/objects-side-bar/object-item';
import { ShapeType, Workspace } from 'reducers';
import { rotatePoint } from 'utils/math';
import consts from 'consts';
import config from 'config';

interface Props {
readonly: boolean;
Expand Down Expand Up @@ -141,9 +141,9 @@ export default function CanvasContextMenu(props: Props): JSX.Element | null {
if (param.key === ReviewContextMenuKeys.OPEN_ISSUE) {
onStartIssue(points);
} else if (param.key === ReviewContextMenuKeys.QUICK_ISSUE_POSITION) {
openIssue(points, consts.QUICK_ISSUE_INCORRECT_POSITION_TEXT);
openIssue(points, config.QUICK_ISSUE_INCORRECT_POSITION_TEXT);
} else if (param.key === ReviewContextMenuKeys.QUICK_ISSUE_ATTRIBUTE) {
openIssue(points, consts.QUICK_ISSUE_INCORRECT_ATTRIBUTE_TEXT);
openIssue(points, config.QUICK_ISSUE_INCORRECT_ATTRIBUTE_TEXT);
} else if (
param.keyPath.length === 2 &&
param.keyPath[1] === ReviewContextMenuKeys.QUICK_ISSUE_FROM_LATEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { LogType } from 'cvat-logger';
import { Canvas } from 'cvat-canvas-wrapper';
import { Canvas3d } from 'cvat-canvas3d-wrapper';
import { getCore } from 'cvat-core-wrapper';
import consts from 'consts';
import config from 'config';
import CVATTooltip from 'components/common/cvat-tooltip';
import FrameTags from 'components/annotation-page/tag-annotation-workspace/frame-tags';
import {
Expand Down Expand Up @@ -369,7 +369,7 @@ class CanvasWrapperComponent extends React.PureComponent<Props> {

canvasInstance.configure({
forceDisableEditing: workspace === Workspace.REVIEW_WORKSPACE,
undefinedAttrValue: consts.UNDEFINED_ATTRIBUTE_VALUE,
undefinedAttrValue: config.UNDEFINED_ATTRIBUTE_VALUE,
displayAllText: showObjectsTextAlways,
autoborders: automaticBordering,
showProjections,
Expand Down Expand Up @@ -442,7 +442,7 @@ class CanvasWrapperComponent extends React.PureComponent<Props> {
prevProps.outlined !== outlined
) {
canvasInstance.configure({
undefinedAttrValue: consts.UNDEFINED_ATTRIBUTE_VALUE,
undefinedAttrValue: config.UNDEFINED_ATTRIBUTE_VALUE,
displayAllText: showObjectsTextAlways,
autoborders: automaticBordering,
showProjections,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Input from 'antd/lib/input';
import InputNumber from 'antd/lib/input-number';
import Text from 'antd/lib/typography/Text';

import consts from 'consts';
import config from 'config';
import { clamp } from 'utils/math';

interface Props {
Expand Down Expand Up @@ -84,7 +84,7 @@ function ItemAttributeComponent(props: Props): JSX.Element {
{attrValues.map(
(value: string): JSX.Element => (
<Radio key={value} value={value}>
{value === consts.UNDEFINED_ATTRIBUTE_VALUE ? consts.NO_BREAK_SPACE : value}
{value === config.UNDEFINED_ATTRIBUTE_VALUE ? config.NO_BREAK_SPACE : value}
</Radio>
),
)}
Expand Down Expand Up @@ -113,7 +113,7 @@ function ItemAttributeComponent(props: Props): JSX.Element {
{attrValues.map(
(value: string): JSX.Element => (
<Select.Option key={value} value={value}>
{value === consts.UNDEFINED_ATTRIBUTE_VALUE ? consts.NO_BREAK_SPACE : value}
{value === config.UNDEFINED_ATTRIBUTE_VALUE ? config.NO_BREAK_SPACE : value}
</Select.Option>
),
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CombinedState, ObjectType } from 'reducers';
import Text from 'antd/lib/typography/Text';
import Modal from 'antd/lib/modal';

import consts from 'consts';
import config from 'config';
import { removeObjectAsync, removeObject as removeObjectAction } from 'actions/annotation-actions';

export default function RemoveConfirmComponent(): JSX.Element | null {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function RemoveConfirmComponent(): JSX.Element | null {
</Text>
<div className='cvat-remove-object-confirm-wrapper'>
{/* eslint-disable-next-line */}
<img src={consts.OUTSIDE_PIC_URL} />
<img src={config.OUTSIDE_PIC_URL} />
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import React from 'react';
import config from 'config';
import Location from './location';
import consts from '../../consts';

interface Props {
selectedRegion: any;
Expand All @@ -22,7 +24,7 @@ export default function GCSLocation(props: Props): JSX.Element {
selectedRegion={selectedRegion}
onSelectRegion={onSelectRegion}
internalCommonProps={internalCommonProps}
values={consts.DEFAULT_GOOGLE_CLOUD_STORAGE_LOCATIONS}
values={config.DEFAULT_GOOGLE_CLOUD_STORAGE_LOCATIONS}
name='location'
label='Location'
href='https://cloud.google.com/storage/docs/locations#available-locations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Input from 'antd/lib/input';
import Row from 'antd/lib/row';
import notification from 'antd/lib/notification';
import Tooltip from 'antd/lib/tooltip';
import consts from 'consts';
import config from 'config';

interface Props {
form: any;
Expand All @@ -24,7 +24,7 @@ export default function ManifestsManager(props: Props): JSX.Element {
const { form, manifestNames, setManifestNames } = props;
const maxManifestsCount = useRef(5);
const [limitingAddingManifestNotification, setLimitingAddingManifestNotification] = useState(false);
const { DATASET_MANIFEST_GUIDE_URL } = consts;
const { DATASET_MANIFEST_GUIDE_URL } = config;

const updateManifestFields = (): void => {
const newManifestFormItems = manifestNames.map((name, idx) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

import React from 'react';
import config from 'config';
import Location from './location';
import consts from '../../consts';

interface Props {
selectedRegion: any;
Expand All @@ -22,7 +24,7 @@ export default function S3Region(props: Props): JSX.Element {
selectedRegion={selectedRegion}
onSelectRegion={onSelectRegion}
internalCommonProps={internalCommonProps}
values={consts.DEFAULT_AWS_S3_REGIONS}
values={config.DEFAULT_AWS_S3_REGIONS}
name='region'
label='Region'
href='https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import React, { useEffect, useState } from 'react';
import Autocomplete from 'antd/lib/auto-complete';

import consts from 'consts';
import config from 'config';
import { getCore } from 'cvat-core-wrapper';

const core = getCore();
Expand Down Expand Up @@ -38,7 +38,7 @@ export default function ProjectSubsetField(props: Props): JSX.Element {
setInternalSubsets(
new Set([
...(internalValue ? [internalValue] : []),
...consts.DEFAULT_PROJECT_SUBSETS,
...config.DEFAULT_PROJECT_SUBSETS,
...project.subsets,
]),
);
Expand All @@ -48,7 +48,7 @@ export default function ProjectSubsetField(props: Props): JSX.Element {
setInternalSubsets(
new Set([
...(internalValue ? [internalValue] : []),
...consts.DEFAULT_PROJECT_SUBSETS,
...config.DEFAULT_PROJECT_SUBSETS,
...(projectSubsets || []),
]),
);
Expand Down
Loading

0 comments on commit 3fa6f35

Please sign in to comment.