From 7ab4e555bc5ebc3f242e064f1329eb2aa591b19b Mon Sep 17 00:00:00 2001 From: Hean-Chhinling Date: Tue, 18 Aug 2026 16:11:31 +0200 Subject: [PATCH 1/3] YARN-11982: Automatically stage weight capacity when dynamic queue creation on root queue is enabled --- .../src/config/properties/queue-properties.ts | 2 +- .../hooks/usePropertyEditor.test.tsx | 1 + .../hooks/usePropertyEditor.ts | 17 ++ .../utils/rootFlexibleAutoCreation.test.ts | 186 ++++++++++++++++++ .../utils/rootFlexibleAutoCreation.ts | 127 ++++++++++++ 5 files changed, 332 insertions(+), 1 deletion(-) create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/config/properties/queue-properties.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/config/properties/queue-properties.ts index 6fb1c87c7b6638..79552d09ac146d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/config/properties/queue-properties.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/config/properties/queue-properties.ts @@ -548,7 +548,7 @@ export const queuePropertyDefinitions: PropertyDescriptor[] = [ name: 'auto-queue-creation-v2.enabled', displayName: 'Flexible Queue Auto-Creation', description: - 'Enable flexible queue auto-creation (parent and leaf queues). In legacy queue mode, root queue requires all child queues to use weight-based capacity.', + 'Enable flexible queue auto-creation (parent and leaf queues). In legacy queue mode, root queue requires all child queues to use weight-based capacity; enabling or disabling on root automatically converts root capacity between 100% and 1w.', type: 'boolean' as PropertyType, category: 'dynamic-queues' as PropertyCategory, defaultValue: '', diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.test.tsx b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.test.tsx index 32657c2f39f0f9..856b456a3b6292 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.test.tsx +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.test.tsx @@ -34,6 +34,7 @@ vi.mock('sonner', () => ({ error: vi.fn(), success: vi.fn(), warning: vi.fn(), + info: vi.fn(), }, })); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts index 08de908fcba2f9..eb3548589c4e97 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts @@ -74,6 +74,7 @@ import { validatePropertyChange } from '~/features/validation/crossQueue'; import { buildPropertyKey } from '~/utils/propertyUtils'; import { CONFIG_PREFIXES } from '~/types'; import { resolveInheritedValue, type InheritedValueInfo } from '~/utils/resolveInheritedValue'; +import { resolveRootCapacityStagingForFlexibleAutoCreation } from '~/features/property-editor/utils/rootFlexibleAutoCreation'; function createFormSchema( properties: Array< @@ -461,6 +462,16 @@ export function usePropertyEditor({ } }); + const stagedRootCapacity = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath, + changedData, + getQueuePropertyValue, + configData, + }); + if (stagedRootCapacity) { + changedData.capacity = stagedRootCapacity.capacity; + } + const pendingEntries = Object.entries(changedData); const previewConfigData = new Map(configData); @@ -550,6 +561,12 @@ export function usePropertyEditor({ message: `${stagedCount} change${stagedCount !== 1 ? 's' : ''} staged successfully!`, }; + if (stagedRootCapacity?.direction === 'to-weight') { + toast.info('Root queue capacity was automatically converted from 100% to 1w for weight mode.'); + } else if (stagedRootCapacity?.direction === 'to-percentage') { + toast.info('Root queue capacity was automatically converted from 1w to 100%.'); + } + if (stagedCount > 0) { const latestValues = form.getValues(); reset(latestValues, { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts new file mode 100644 index 00000000000000..46ad5425e63875 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts @@ -0,0 +1,186 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from 'vitest'; +import { + resolveRootCapacityStagingForFlexibleAutoCreation, + resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation, + resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation, + ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY, + ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY, +} from './rootFlexibleAutoCreation'; +import { AUTO_CREATION_PROPS } from '~/types/constants/auto-creation'; +import { SPECIAL_VALUES } from '~/types/constants/special-values'; + +describe('root flexible auto-creation capacity staging', () => { + const createGetQueuePropertyValue = + (values: Record) => (_queuePath: string, propertyName: string) => ({ + value: values[propertyName] ?? '', + isStaged: false, + }); + + const legacyConfig = new Map([[SPECIAL_VALUES.LEGACY_MODE_PROPERTY, 'true']]); + + describe('resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation', () => { + it('returns 1w when enabling on root with percentage capacity', () => { + const result = resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), + configData: legacyConfig, + }); + + expect(result).toEqual({ + capacity: ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY, + direction: 'to-weight', + }); + }); + + it('returns null when root already uses weight capacity', () => { + const result = resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), + configData: legacyConfig, + }); + + expect(result).toBeNull(); + }); + + it('returns null when disabling flexible auto-creation', () => { + const result = resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), + configData: legacyConfig, + }); + + expect(result).toBeNull(); + }); + }); + + describe('resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation', () => { + it('returns 100 when disabling on root with weight capacity', () => { + const result = resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ + capacity: '1w', + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', + }), + configData: legacyConfig, + }); + + expect(result).toEqual({ + capacity: ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY, + direction: 'to-percentage', + }); + }); + + it('returns null when flexible auto-creation was not enabled', () => { + const result = resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ + capacity: '1w', + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false', + }), + configData: legacyConfig, + }); + + expect(result).toBeNull(); + }); + + it('returns null when root already uses percentage capacity', () => { + const result = resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ + capacity: '100', + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', + }), + configData: legacyConfig, + }); + + expect(result).toBeNull(); + }); + }); + + describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { + it('delegates to the enable handler when turning flexible auto-creation on', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), + configData: legacyConfig, + }); + + expect(result?.direction).toBe('to-weight'); + }); + + it('delegates to the disable handler when turning flexible auto-creation off', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ + capacity: '1w', + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', + }), + configData: legacyConfig, + }); + + expect(result?.direction).toBe('to-percentage'); + }); + + it('returns null for non-root queues', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: 'root.default', + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), + configData: legacyConfig, + }); + + expect(result).toBeNull(); + }); + + it('returns null when legacy mode is disabled', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), + configData: new Map([[SPECIAL_VALUES.LEGACY_MODE_PROPERTY, 'false']]), + }); + + expect(result).toBeNull(); + }); + + it('returns null when capacity is already being changed explicitly', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', + capacity: '2w', + }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), + configData: legacyConfig, + }); + + expect(result).toBeNull(); + }); + }); +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts new file mode 100644 index 00000000000000..3d34bdd771627c --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts @@ -0,0 +1,127 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AUTO_CREATION_PROPS } from '~/types/constants/auto-creation'; +import { SPECIAL_VALUES } from '~/types/constants/special-values'; +import { getCapacityType } from '~/utils/capacityUtils'; + +export const ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY = '1w'; +export const ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY = '100'; + +export type RootCapacityAutoStagingDirection = 'to-weight' | 'to-percentage'; + +export interface RootCapacityAutoStagingResult { + capacity: string; + direction: RootCapacityAutoStagingDirection; +} + +export interface ResolveRootCapacityStagingOptions { + queuePath: string; + changedData: Record; + getQueuePropertyValue: ( + queuePath: string, + propertyName: string, + ) => { value: string; isStaged: boolean }; + configData: Map; +} + +function canAutoStageRootCapacity({ + queuePath, + changedData, + configData, +}: ResolveRootCapacityStagingOptions): boolean { + if (queuePath !== SPECIAL_VALUES.ROOT_QUEUE_NAME) { + return false; + } + + if (changedData.capacity !== undefined) { + return false; + } + + return configData.get(SPECIAL_VALUES.LEGACY_MODE_PROPERTY) !== 'false'; +} + +/** + * Legacy mode requires root to use weight capacity when flexible auto-creation is enabled. + * Convert 100% -> 1w when the toggle is turned on. + */ +export function resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation( + options: ResolveRootCapacityStagingOptions, +): RootCapacityAutoStagingResult | null { + if (!canAutoStageRootCapacity(options)) { + return null; + } + + if (options.changedData[AUTO_CREATION_PROPS.FLEXIBLE_ENABLED] !== 'true') { + return null; + } + + const { value: currentCapacity } = options.getQueuePropertyValue(options.queuePath, 'capacity'); + if (getCapacityType(currentCapacity) !== 'percentage') { + return null; + } + + return { + capacity: ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY, + direction: 'to-weight', + }; +} + +/** + * Restore root to percentage capacity when flexible auto-creation is turned off. + * Convert 1w -> 100%. + */ +export function resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation( + options: ResolveRootCapacityStagingOptions, +): RootCapacityAutoStagingResult | null { + if (!canAutoStageRootCapacity(options)) { + return null; + } + + const flexibleEnabledChange = options.changedData[AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]; + if (flexibleEnabledChange === undefined || flexibleEnabledChange === 'true') { + return null; + } + + const { value: currentFlexibleEnabled } = options.getQueuePropertyValue( + options.queuePath, + AUTO_CREATION_PROPS.FLEXIBLE_ENABLED, + ); + if (currentFlexibleEnabled !== 'true') { + return null; + } + + const { value: currentCapacity } = options.getQueuePropertyValue(options.queuePath, 'capacity'); + if (getCapacityType(currentCapacity) !== 'weight') { + return null; + } + + return { + capacity: ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY, + direction: 'to-percentage', + }; +} + +export function resolveRootCapacityStagingForFlexibleAutoCreation( + options: ResolveRootCapacityStagingOptions, +): RootCapacityAutoStagingResult | null { + return ( + resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation(options) ?? + resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation(options) + ); +} From b9176b1bbaeb5351beb5338b6e1c974a722935c5 Mon Sep 17 00:00:00 2001 From: Hean-Chhinling Date: Tue, 18 Aug 2026 17:19:15 +0200 Subject: [PATCH 2/3] YARN-11982: Clean up code --- .../utils/rootFlexibleAutoCreation.test.ts | 202 ++++++------------ .../utils/rootFlexibleAutoCreation.ts | 27 +-- 2 files changed, 80 insertions(+), 149 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts index 46ad5425e63875..355887aeca4fad 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts @@ -17,17 +17,11 @@ */ import { describe, it, expect } from 'vitest'; -import { - resolveRootCapacityStagingForFlexibleAutoCreation, - resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation, - resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation, - ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY, - ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY, -} from './rootFlexibleAutoCreation'; +import { resolveRootCapacityStagingForFlexibleAutoCreation } from './rootFlexibleAutoCreation'; import { AUTO_CREATION_PROPS } from '~/types/constants/auto-creation'; import { SPECIAL_VALUES } from '~/types/constants/special-values'; -describe('root flexible auto-creation capacity staging', () => { +describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { const createGetQueuePropertyValue = (values: Record) => (_queuePath: string, propertyName: string) => ({ value: values[propertyName] ?? '', @@ -36,151 +30,95 @@ describe('root flexible auto-creation capacity staging', () => { const legacyConfig = new Map([[SPECIAL_VALUES.LEGACY_MODE_PROPERTY, 'true']]); - describe('resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation', () => { - it('returns 1w when enabling on root with percentage capacity', () => { - const result = resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, - getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), - configData: legacyConfig, - }); - - expect(result).toEqual({ - capacity: ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY, - direction: 'to-weight', - }); + it('returns 1w when enabling flexible auto-creation on root with percentage capacity', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), + configData: legacyConfig, }); - it('returns null when root already uses weight capacity', () => { - const result = resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, - getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), - configData: legacyConfig, - }); - - expect(result).toBeNull(); - }); - - it('returns null when disabling flexible auto-creation', () => { - const result = resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, - getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), - configData: legacyConfig, - }); - - expect(result).toBeNull(); + expect(result).toEqual({ + capacity: '1w', + direction: 'to-weight', }); }); - describe('resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation', () => { - it('returns 100 when disabling on root with weight capacity', () => { - const result = resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, - getQueuePropertyValue: createGetQueuePropertyValue({ - capacity: '1w', - [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', - }), - configData: legacyConfig, - }); - - expect(result).toEqual({ - capacity: ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY, - direction: 'to-percentage', - }); + it('returns 100 when disabling flexible auto-creation on root with weight capacity', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ + capacity: '1w', + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', + }), + configData: legacyConfig, }); - it('returns null when flexible auto-creation was not enabled', () => { - const result = resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, - getQueuePropertyValue: createGetQueuePropertyValue({ - capacity: '1w', - [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false', - }), - configData: legacyConfig, - }); - - expect(result).toBeNull(); + expect(result).toEqual({ + capacity: '100%', + direction: 'to-percentage', }); + }); - it('returns null when root already uses percentage capacity', () => { - const result = resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, - getQueuePropertyValue: createGetQueuePropertyValue({ - capacity: '100', - [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', - }), - configData: legacyConfig, - }); - - expect(result).toBeNull(); + it('returns null for non-root queues', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: 'root.default', + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), + configData: legacyConfig, }); - }); - describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { - it('delegates to the enable handler when turning flexible auto-creation on', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, - getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), - configData: legacyConfig, - }); + expect(result).toBeNull(); + }); - expect(result?.direction).toBe('to-weight'); + it('returns null when legacy mode is disabled', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), + configData: new Map([[SPECIAL_VALUES.LEGACY_MODE_PROPERTY, 'false']]), }); - it('delegates to the disable handler when turning flexible auto-creation off', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, - getQueuePropertyValue: createGetQueuePropertyValue({ - capacity: '1w', - [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', - }), - configData: legacyConfig, - }); - - expect(result?.direction).toBe('to-percentage'); + expect(result).toBeNull(); + }); + + it('returns null when root already uses weight capacity while enabling', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, + getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), + configData: legacyConfig, }); - it('returns null for non-root queues', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ - queuePath: 'root.default', - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, - getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), - configData: legacyConfig, - }); + expect(result).toBeNull(); + }); - expect(result).toBeNull(); + it('returns null when flexible auto-creation was not enabled while disabling', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ + capacity: '1w', + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false', + }), + configData: legacyConfig, }); - it('returns null when legacy mode is disabled', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, - getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), - configData: new Map([[SPECIAL_VALUES.LEGACY_MODE_PROPERTY, 'false']]), - }); + expect(result).toBeNull(); + }); - expect(result).toBeNull(); + it('returns null when root already uses percentage capacity while disabling', () => { + const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, + changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, + getQueuePropertyValue: createGetQueuePropertyValue({ + capacity: '100', + [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', + }), + configData: legacyConfig, }); - it('returns null when capacity is already being changed explicitly', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ - queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, - changedData: { - [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true', - capacity: '2w', - }, - getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), - configData: legacyConfig, - }); - - expect(result).toBeNull(); - }); + expect(result).toBeNull(); }); }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts index 3d34bdd771627c..befb5fa2e41652 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts @@ -20,14 +20,10 @@ import { AUTO_CREATION_PROPS } from '~/types/constants/auto-creation'; import { SPECIAL_VALUES } from '~/types/constants/special-values'; import { getCapacityType } from '~/utils/capacityUtils'; -export const ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY = '1w'; -export const ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY = '100'; - -export type RootCapacityAutoStagingDirection = 'to-weight' | 'to-percentage'; export interface RootCapacityAutoStagingResult { capacity: string; - direction: RootCapacityAutoStagingDirection; + direction: 'to-weight' | 'to-percentage'; } export interface ResolveRootCapacityStagingOptions { @@ -56,11 +52,7 @@ function canAutoStageRootCapacity({ return configData.get(SPECIAL_VALUES.LEGACY_MODE_PROPERTY) !== 'false'; } -/** - * Legacy mode requires root to use weight capacity when flexible auto-creation is enabled. - * Convert 100% -> 1w when the toggle is turned on. - */ -export function resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation( +function resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation( options: ResolveRootCapacityStagingOptions, ): RootCapacityAutoStagingResult | null { if (!canAutoStageRootCapacity(options)) { @@ -77,16 +69,12 @@ export function resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation( } return { - capacity: ROOT_FLEXIBLE_AUTO_CREATION_WEIGHT_CAPACITY, + capacity: '1w', direction: 'to-weight', }; } -/** - * Restore root to percentage capacity when flexible auto-creation is turned off. - * Convert 1w -> 100%. - */ -export function resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation( +function resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation( options: ResolveRootCapacityStagingOptions, ): RootCapacityAutoStagingResult | null { if (!canAutoStageRootCapacity(options)) { @@ -112,11 +100,16 @@ export function resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation( } return { - capacity: ROOT_FLEXIBLE_AUTO_CREATION_PERCENTAGE_CAPACITY, + capacity: '100%', direction: 'to-percentage', }; } +/** + * Restore root capacity when flexible auto-creation is toggled. + * Convert 100% -> 1w when the toggle is turned on. + * onvert 1w -> 100% when the toggle is turned off. + */ export function resolveRootCapacityStagingForFlexibleAutoCreation( options: ResolveRootCapacityStagingOptions, ): RootCapacityAutoStagingResult | null { From 61db1b42c0227a15b5f5e9e51e3af96961ac96de Mon Sep 17 00:00:00 2001 From: Hean-Chhinling Date: Thu, 27 Aug 2026 16:16:54 +0200 Subject: [PATCH 3/3] YARN-11982: Refactor code logic to stay at /store instead of /hooks --- .../hooks/usePropertyEditor.ts | 17 ++++++++------- .../rootCapacityAutoStaging.test.ts} | 20 +++++++++--------- .../slices/rootCapacityAutoStaging.ts} | 21 +++++++++---------- .../src/stores/slices/stagedChangesSlice.ts | 9 ++++++++ .../main/webapp/src/stores/slices/types.ts | 5 +++++ 5 files changed, 44 insertions(+), 28 deletions(-) rename hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/{features/property-editor/utils/rootFlexibleAutoCreation.test.ts => stores/slices/__tests__/rootCapacityAutoStaging.test.ts} (82%) rename hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/{features/property-editor/utils/rootFlexibleAutoCreation.ts => stores/slices/rootCapacityAutoStaging.ts} (86%) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts index eb3548589c4e97..e654578ba032fb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/hooks/usePropertyEditor.ts @@ -74,7 +74,6 @@ import { validatePropertyChange } from '~/features/validation/crossQueue'; import { buildPropertyKey } from '~/utils/propertyUtils'; import { CONFIG_PREFIXES } from '~/types'; import { resolveInheritedValue, type InheritedValueInfo } from '~/utils/resolveInheritedValue'; -import { resolveRootCapacityStagingForFlexibleAutoCreation } from '~/features/property-editor/utils/rootFlexibleAutoCreation'; function createFormSchema( properties: Array< @@ -143,8 +142,14 @@ export function usePropertyEditor({ queuePath, properties = queuePropertyDefinitions, }: UsePropertyEditorOptions) { - const { getQueuePropertyValue, stageQueueChange, clearQueueChanges, schedulerData, configData } = - useSchedulerStore(); + const { + getQueuePropertyValue, + stageQueueChange, + clearQueueChanges, + schedulerData, + configData, + resolveRootCapacityStagingForFlexibleAutoCreation, + } = useSchedulerStore(); const stagedChanges = useSchedulerStore((state) => state.stagedChanges); const cleanResetRef = useRef(false); @@ -462,12 +467,10 @@ export function usePropertyEditor({ } }); - const stagedRootCapacity = resolveRootCapacityStagingForFlexibleAutoCreation({ + const stagedRootCapacity = resolveRootCapacityStagingForFlexibleAutoCreation( queuePath, changedData, - getQueuePropertyValue, - configData, - }); + ); if (stagedRootCapacity) { changedData.capacity = stagedRootCapacity.capacity; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/__tests__/rootCapacityAutoStaging.test.ts similarity index 82% rename from hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts rename to hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/__tests__/rootCapacityAutoStaging.test.ts index 355887aeca4fad..1c3676a95ee370 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.test.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/__tests__/rootCapacityAutoStaging.test.ts @@ -17,11 +17,11 @@ */ import { describe, it, expect } from 'vitest'; -import { resolveRootCapacityStagingForFlexibleAutoCreation } from './rootFlexibleAutoCreation'; +import { resolveRootCapacityStagingWhenAutoQueueCreationIsToggled } from '~/stores/slices/rootCapacityAutoStaging'; import { AUTO_CREATION_PROPS } from '~/types/constants/auto-creation'; import { SPECIAL_VALUES } from '~/types/constants/special-values'; -describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { +describe('resolveRootCapacityStagingWhenAutoQueueCreationIsToggled', () => { const createGetQueuePropertyValue = (values: Record) => (_queuePath: string, propertyName: string) => ({ value: values[propertyName] ?? '', @@ -31,7 +31,7 @@ describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { const legacyConfig = new Map([[SPECIAL_VALUES.LEGACY_MODE_PROPERTY, 'true']]); it('returns 1w when enabling flexible auto-creation on root with percentage capacity', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + const result = resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), @@ -44,8 +44,8 @@ describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { }); }); - it('returns 100 when disabling flexible auto-creation on root with weight capacity', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + it('returns 100% when disabling flexible auto-creation on root with weight capacity', () => { + const result = resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, getQueuePropertyValue: createGetQueuePropertyValue({ @@ -62,7 +62,7 @@ describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { }); it('returns null for non-root queues', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + const result = resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ queuePath: 'root.default', changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), @@ -73,7 +73,7 @@ describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { }); it('returns null when legacy mode is disabled', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + const result = resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '100' }), @@ -84,7 +84,7 @@ describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { }); it('returns null when root already uses weight capacity while enabling', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + const result = resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'true' }, getQueuePropertyValue: createGetQueuePropertyValue({ capacity: '2w' }), @@ -95,7 +95,7 @@ describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { }); it('returns null when flexible auto-creation was not enabled while disabling', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + const result = resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, getQueuePropertyValue: createGetQueuePropertyValue({ @@ -109,7 +109,7 @@ describe('resolveRootCapacityStagingForFlexibleAutoCreation', () => { }); it('returns null when root already uses percentage capacity while disabling', () => { - const result = resolveRootCapacityStagingForFlexibleAutoCreation({ + const result = resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ queuePath: SPECIAL_VALUES.ROOT_QUEUE_NAME, changedData: { [AUTO_CREATION_PROPS.FLEXIBLE_ENABLED]: 'false' }, getQueuePropertyValue: createGetQueuePropertyValue({ diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/rootCapacityAutoStaging.ts similarity index 86% rename from hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts rename to hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/rootCapacityAutoStaging.ts index befb5fa2e41652..f2f540463c9fb6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/property-editor/utils/rootFlexibleAutoCreation.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/rootCapacityAutoStaging.ts @@ -20,13 +20,12 @@ import { AUTO_CREATION_PROPS } from '~/types/constants/auto-creation'; import { SPECIAL_VALUES } from '~/types/constants/special-values'; import { getCapacityType } from '~/utils/capacityUtils'; - export interface RootCapacityAutoStagingResult { capacity: string; direction: 'to-weight' | 'to-percentage'; } -export interface ResolveRootCapacityStagingOptions { +export interface RootCapacityAutoStagingContext { queuePath: string; changedData: Record; getQueuePropertyValue: ( @@ -40,7 +39,7 @@ function canAutoStageRootCapacity({ queuePath, changedData, configData, -}: ResolveRootCapacityStagingOptions): boolean { +}: RootCapacityAutoStagingContext): boolean { if (queuePath !== SPECIAL_VALUES.ROOT_QUEUE_NAME) { return false; } @@ -53,7 +52,7 @@ function canAutoStageRootCapacity({ } function resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation( - options: ResolveRootCapacityStagingOptions, + options: RootCapacityAutoStagingContext, ): RootCapacityAutoStagingResult | null { if (!canAutoStageRootCapacity(options)) { return null; @@ -75,7 +74,7 @@ function resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation( } function resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation( - options: ResolveRootCapacityStagingOptions, + options: RootCapacityAutoStagingContext, ): RootCapacityAutoStagingResult | null { if (!canAutoStageRootCapacity(options)) { return null; @@ -106,15 +105,15 @@ function resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation( } /** - * Restore root capacity when flexible auto-creation is toggled. + * Restore root capacity when flexible auto-queue-creation is toggled. * Convert 100% -> 1w when the toggle is turned on. - * onvert 1w -> 100% when the toggle is turned off. + * Convert 1w -> 100% when the toggle is turned off. */ -export function resolveRootCapacityStagingForFlexibleAutoCreation( - options: ResolveRootCapacityStagingOptions, +export function resolveRootCapacityStagingWhenAutoQueueCreationIsToggled( + context: RootCapacityAutoStagingContext, ): RootCapacityAutoStagingResult | null { return ( - resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation(options) ?? - resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation(options) + resolveRootCapacityStagingWhenEnablingFlexibleAutoCreation(context) ?? + resolveRootCapacityStagingWhenDisablingFlexibleAutoCreation(context) ); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/stagedChangesSlice.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/stagedChangesSlice.ts index cd9b02bccc7c18..dc4e6e2dd92ebc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/stagedChangesSlice.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/stagedChangesSlice.ts @@ -47,6 +47,7 @@ import { assertWritable } from '~/lib/errors/readOnlyGuard'; import type { StagedChangesSlice, SchedulerStore } from './types'; import { getAffectedQueuesForValidation } from '~/features/validation/utils/affectedQueues'; import { validateStagedChanges, validatePropertyChange } from '~/features/validation/crossQueue'; +import { resolveRootCapacityStagingWhenAutoQueueCreationIsToggled } from './rootCapacityAutoStaging'; type MutationErrorState = Pick; const clearMutationError = (state: MutationErrorState) => { @@ -582,6 +583,14 @@ export const createStagedChangesSlice: StateCreator< }); }, + resolveRootCapacityStagingForFlexibleAutoCreation: (queuePath, changedData) => + resolveRootCapacityStagingWhenAutoQueueCreationIsToggled({ + queuePath, + changedData, + getQueuePropertyValue: get().getQueuePropertyValue, + configData: get().configData, + }), + refreshAffectedValidationErrors: (triggeringQueuePath: string, triggeringProperty: string) => { const { stagedChanges, schedulerData, configData } = get(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/types.ts b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/types.ts index 02fb6b7900115b..cf28c51ec179dc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/types.ts +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/stores/slices/types.ts @@ -34,6 +34,7 @@ import type { } from '~/types'; import type { PlacementRulesSlice } from './placementRulesSlice'; import type { CapacityEditorSlice } from './capacityEditorSlice'; +import type { RootCapacityAutoStagingResult } from './rootCapacityAutoStaging'; export interface BaseStoreSlice { apiClient: YarnApiClient; @@ -107,6 +108,10 @@ export interface StagedChangesSlice { triggeringQueuePath: string, triggeringProperty: string, ) => void; + resolveRootCapacityStagingForFlexibleAutoCreation: ( + queuePath: string, + changedData: Record, + ) => RootCapacityAutoStagingResult | null; } export interface QueueSelectionSlice {