From 4be139c64a7538e038443cdd8100150c1b8a00f8 Mon Sep 17 00:00:00 2001 From: simbiozizv Date: Wed, 15 May 2024 14:07:40 +0300 Subject: [PATCH] fix(Bundles): memory limit [YTFRONT-4170] --- .../tablet-cell-bundle-editor.ts | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/ui/store/actions/tablet_cell_bundles/tablet-cell-bundle-editor.ts b/packages/ui/src/ui/store/actions/tablet_cell_bundles/tablet-cell-bundle-editor.ts index 32157224c..f2e5e8ba6 100644 --- a/packages/ui/src/ui/store/actions/tablet_cell_bundles/tablet-cell-bundle-editor.ts +++ b/packages/ui/src/ui/store/actions/tablet_cell_bundles/tablet-cell-bundle-editor.ts @@ -58,6 +58,13 @@ export function fetchTabletCellBundleEditor(bundleName: string): TabletCellBundl }, ]; + requests.push({ + command: 'get', + parameters: { + path: '//sys/bundle_controller/controller/zones/zone_default/@tablet_node_sizes/nextgen/default_config/memory_limits/reserved', + }, + }); + if (toEdit.enable_bundle_controller) { requests.push({ command: 'get', @@ -73,7 +80,7 @@ export function fetchTabletCellBundleEditor(bundleName: string): TabletCellBundl .then((results) => { const bundleControllerIsUnavailable = toEdit.enable_bundle_controller && - results[1]?.error?.code === yt.codes.NODE_DOES_NOT_EXIST; + results[2]?.error?.code === yt.codes.NODE_DOES_NOT_EXIST; const error = getBatchError( bundleControllerIsUnavailable ? [results[0]] : results, 'Failed to get bundle edit data', @@ -91,13 +98,31 @@ export function fetchTabletCellBundleEditor(bundleName: string): TabletCellBundl }, ) .then((results) => { - const [{output: data}, {output: bundleControllerData} = {output: undefined}] = - results as BatchResults<[unknown, OrchidBundlesData]>; + const [ + {output: data}, + {output: defaultReservedMemoryLimit}, + {output: bundleControllerData} = {output: undefined}, + ] = results as BatchResults<[unknown, number, OrchidBundlesData]>; + + let bundleData = toEdit; + + if (!toEdit.bundle_controller_target_config.memory_limits.reserved) { + bundleData = { + ...toEdit, + bundle_controller_target_config: { + ...toEdit.bundle_controller_target_config, + memory_limits: { + ...toEdit.bundle_controller_target_config.memory_limits, + reserved: defaultReservedMemoryLimit, + }, + }, + }; + } dispatch({ type: TABLETS_BUNDLES_EDITOR_LOAD_SUCCESS, data: { - bundleData: toEdit, + bundleData, data, bundleControllerData, },