Component Validation System
Learn how to define and use component validations in AICR.
Note: This document covers component validations — condition-based checks that run during bundle generation (e.g., missing config, incompatible settings). For the container-per-validator engine used by
aicr validate, see the Validator Development Guide and Validator Extension Guide.
Overview
The component validation system allows components to register validation checks that run automatically during bundle generation. Validations can check for missing configuration, incompatible settings, or other conditions that might cause deployment issues.
Key Features:
- Component-Driven: Validations are defined in the component registry (
recipes/registry.yaml) - Condition-Based: Validations run only when specific conditions are met (e.g., intent, service)
- Severity Levels: Each validation can be a “warning” (non-blocking) or “error” (blocking)
- Custom Messages: Optional detail messages provide actionable guidance
- Extensible: New validation functions can be added without modifying core bundler code
Architecture
Defining Validations
Validations are defined in the component registry (recipes/registry.yaml) under each component’s configuration.
Validation Configuration Structure
Validation Fields
Conditions
Conditions use arrays of strings for OR matching. A single-element array is equivalent to a single value:
Supported Condition Keys:
intent: Workload intent (training, inference)service: Kubernetes service (eks, gke, aks, oke, kind, lke)accelerator: GPU type (h100, gb200, b200, a100, l40, rtx-pro-6000)os: Operating system (ubuntu, rhel, cos, amazonlinux, talos)platform: Platform/framework (kubeflow)
Example: Nodewright Customizations Validations
Available Validation Functions
CheckWorkloadSelectorMissing
Checks if --workload-selector is missing when conditions are met.
Use Case: Prevent nodewright from evicting running training jobs by ensuring workload selector is configured.
Example:
CheckAcceleratedSelectorMissing
Checks if --accelerated-node-selector is missing when conditions are met.
Use Case: Ensure node selectors are configured to target specific nodes rather than running on all nodes.
Example:
CheckHostMofedWithoutNetworkOperator
Flags components requesting host-mode MOFED when the network-operator component is not in the recipe (host MOFED requires the network operator to manage the kernel modules).
Creating New Validation Functions
To add a new validation function, follow these steps:
Step 1: Implement the Validation Function
Create a new function in pkg/bundler/validations/checks.go:
Step 2: Register the Function
Add the function to the auto-registration in pkg/bundler/validations/checks.go:
Step 3: Add to Component Registry
Add the validation to your component’s configuration in recipes/registry.yaml:
Step 4: Add Tests
Create tests in pkg/bundler/validations/checks_test.go:
Validation Function Interface
All validation functions must implement the ValidationFunc signature:
Parameters:
ctx: Context for cancellation/timeoutcomponentName: Name of the component being validated (from recipe)recipeResult: The recipe result containing component refs and criteriabundlerConfig: The bundler configuration (for accessing CLI flags)conditions: Conditions from the validation config (map of criteria field to array of values)
Returns:
warnings: List of warning messages (non-blocking, displayed to user)errors: List of error messages (blocking, stops bundle generation)
Condition Matching Logic
The checkConditions function uses the matching logic from recipe/criteria.go for consistency:
- Empty conditions: Validation always runs (no conditions to check)
- Array values: OR matching - actual value must match any value in the array
- Multiple conditions: AND matching - all conditions must match
- Criteria matching: Uses
matchesCriteriaFieldfor consistent field matching
Example:
This validation runs when:
- Intent is “training” OR “inference” AND
- Service is “eks”
Severity Levels
Warning (Non-Blocking)
Warnings are displayed to the user but do not stop bundle generation. Use for missing optional configuration, best-practice recommendations, potential performance issues, or informational messages.
Output:
Error (Blocking)
Errors stop bundle generation and return an error. Use for missing required configuration, incompatible settings, critical deployment issues, or security concerns.
Output:
Best Practices
- Be Specific: Provide clear, actionable messages that explain what’s wrong and how to fix it
- Use Conditions Wisely: Only run validations when they’re relevant to avoid noise
- Prefer Warnings: Use warnings for non-critical issues; reserve errors for blocking problems
- Reuse Existing Checks: Use generic checks like
CheckWorkloadSelectorMissingwhen possible - Test Thoroughly: Add comprehensive tests covering all condition combinations
- Document Usage: Include examples in component documentation
Examples
Example 1: Simple Condition Check
Example 2: Multiple Conditions
Example 3: Error Severity
Troubleshooting
Validation not running:
- Check that the component is in the recipe’s
componentRefs - Verify conditions match the recipe’s criteria
- Check that the validation function is registered in
checks.goinit()
Warning not displayed:
- Verify the validation function returns warnings (not empty slice)
- Check that severity is “warning” (not “error”)
- Ensure the bundler is collecting warnings correctly
Error stopping bundle:
- Check that severity is “error” (not “warning”)
- Verify the validation function returns errors
- Review the error message for details
Related Documentation
- Component Development Guide - How to add new components
- CLI Reference - User-facing validation documentation
- Recipe Criteria - Understanding recipe criteria