hadoop-yarn-project/hadoop-yarn/hadoop-yarn-capacity-scheduler-ui/src/main/webapp/src/features/validation/README.md
This directory contains the validation engine for the YARN Capacity Scheduler UI. The validation system ensures that configuration changes meet YARN scheduler requirements before they are applied to the cluster.
The validation system is a multi-layered architecture that progressively validates configurations:
The validation service provides core validation functions:
validateField() - Validates a single field change with full contextvalidateQueue() - Validates all properties of a queuehasBlockingIssues() - Checks if any validation issues are blocking errorssplitIssues() - Separates issues into errors and warningsThe service coordinates between individual validation rules and the cross-queue logic in crossQueue.ts.
Contains the cross-queue validation engine that:
Key functions:
validatePropertyChange() - Validates a single property change with cross-queue awarenessvalidateStagedChanges() - Validates all staged changes, optionally filtering by affected queues/propertiesDefines validation rule categories that control validation behavior:
CROSS_QUEUE_RULES - Rules that affect multiple queues (parent/children/siblings)QUEUE_SPECIFIC_RULES - Rules that only validate a single queueWARNING_ONLY_RULES - Rules that produce warnings but never block changesThese categories are used by the validation service to determine which queues need re-validation and whether errors should block applying changes.
Implements the affected queue detection logic:
getAffectedQueuesForValidation() - Determines which queues are affected by a property changeProvides validation issue deduplication:
dedupeIssues() - Removes duplicate validation issues based on queuePath, field, rule, message, and severityservice.ts and crossQueue.ts to ensure unique issues are reportedUser edits property
↓
validateField(queuePath, fieldName, value)
↓
Apply schema-level validation (property descriptor rules)
↓
Apply business validation rules (validation-rules.ts)
↓
Detect affected queues
↓
Run cross-queue validation
↓
Return validation issues
User stages changes
↓
validateStagedChanges({ stagedChanges, schedulerData, configData })
↓
For each staged change:
- Merge staged changes with current config
- Validate affected queues with cross-queue awareness
↓
Return Map of change ID → validation issues
↓
Block "Apply" if blocking errors exist
The ValidationContext object provides all information needed for validation:
interface ValidationContext {
queuePath: string; // Queue being validated
fieldName: string; // Property being validated
fieldValue: unknown; // New value for the property
config: Map<string, string>; // Full config including staged changes
schedulerData: SchedulerInfo; // Current scheduler state
stagedChanges: StagedChange[]; // All pending changes
legacyModeEnabled: boolean; // Whether legacy mode is active
}
This context is passed to all validation rules, providing full visibility into the scheduler state.
Validation rules are defined in src/config/validation-rules.ts. Each rule:
See docs/development/adding-validation-rules.md for detailed guidance on adding new rules.
Rules that validate relationships between multiple queues:
These rules trigger re-validation of affected queues when changes occur.
Rules that only validate the queue being edited:
These rules don't trigger validation of other queues.
Rules that provide helpful feedback but never block changes:
These rules show as warnings in the UI but don't prevent applying changes.
The validation system is designed for efficiency:
Tests for the validation system are in __tests__/:
crossQueue.test.ts - Tests for cross-queue validation logicservice.test.ts - Tests for validation service orchestrationutils/affectedQueues.test.ts - Tests for affected queue detectionAdditional rule-specific tests are in src/config/__tests__/validation-rules.test.ts.
The validation system integrates with:
src/features/property-editor/) - Real-time validation as users editsrc/features/staged-changes/) - Validation before applying changessrc/stores/) - Validation state managementdocs/development/adding-validation-rules.md - Guide for adding new validation rulesdocs/development/extending-scheduler-properties.md - Adding new properties with schema validationsrc/config/validation-rules.ts - Validation rule definitions