featuregood first issuehigh-priority
仓库指标
- Star
- (463 star)
- PR 合并指标
- (PR 指标待抓取)
描述
Task 4: BaseModel Controller PVC Handling
Overview
Update the BaseModel controller to handle the complete PVC storage flow: validation, job creation, and status management. This replaces the original design where model agent was involved.
Scope
- Add PVC validation logic to controller reconciliation
- Create metadata extraction jobs for PVC models
- Monitor job status and update BaseModel accordingly
- Handle all PVC-related errors and edge cases
Files to Modify
pkg/controller/v1beta1/basemodel/controller.go- Main implementationconfig/rbac/role.yaml- Add PVC and Job permissionspkg/controller/v1beta1/basemodel/controller_test.go- Tests
Implementation Details
Key Functions to Add
-
PVC Detection in Reconcile Loop
- Check if BaseModel uses PVC storage URI
- Route to PVC-specific reconciliation logic
- Maintain existing behavior for non-PVC models
-
PVC Validation
- Parse PVC URI to extract components
- Verify PVC exists in the same namespace
- Check PVC binding status
- Update BaseModel status with validation results
-
Metadata Extraction Job Management
- Create Kubernetes Job for metadata extraction
- Job should mount PVC read-only
- Monitor job status (running, succeeded, failed)
- Handle job lifecycle (creation, monitoring, cleanup)
-
Status Updates
- Update BaseModel status based on PVC and job states
- Store PVC information in status annotations
- Clear node-related status fields (not applicable for PVC)
- Handle error messages and failure reasons
Job Specification Requirements
The metadata extraction job should:
- Use the ome-agent image with
model-metadatacommand - Mount the PVC at a specific path with subpath support
- Run with appropriate resource limits
- Have a reasonable timeout (e.g., 5 minutes)
- Include TTL for automatic cleanup
- Use dedicated ServiceAccount with minimal permissions
Controller Watch Configuration
Update the controller to:
- Watch owned Jobs for status updates
- Filter ConfigMap watches to exclude PVC models
- Add appropriate event handlers
Test Cases
-
Valid PVC Flow:
- PVC exists and is bound
- Job created successfully
- Metadata extracted and updated
- Status becomes Ready
-
PVC Validation:
- PVC not found
- PVC not bound
- Invalid PVC URI
-
Job Management:
- Job creation
- Job success handling
- Job failure handling
- Job already exists
-
Edge Cases:
- Metadata already populated
- Job timeout
- Controller restart during job
Acceptance Criteria
- Controller validates PVC existence and binding
- Creates metadata extraction job with correct spec
- Monitors job status and updates BaseModel accordingly
- Handles all error cases gracefully
- Status reflects PVC storage accurately
- No interference with non-PVC models
- Comprehensive test coverage
Dependencies
- Task 1: Storage URI Parsing
- Task 3: Model Metadata Agent
Estimated Effort
5-6 hours (increased due to complete flow ownership)