Workflow Architecture
Infrahub workflows are Prefect flows defined in the backend:Workflow Types
Workflows are categorized by type:Workflow Catalogue
All workflows are registered in the catalogue:Key Workflow Definitions
Git Operations
GIT_REPOSITORY_ADD: Add and clone repositoryGIT_REPOSITORIES_SYNC: Sync all repositories (scheduled)GIT_REPOSITORIES_CREATE_BRANCH: Create branch across reposGIT_REPOSITORIES_MERGE: Merge Git branchesGIT_REPOSITORY_USER_CHECKS_TRIGGER: Run user-defined checks
Artifact Generation
REQUEST_ARTIFACT_DEFINITION_GENERATE: Trigger artifact generationREQUEST_ARTIFACT_GENERATE: Generate single artifactTRIGGER_ARTIFACT_DEFINITION_GENERATE: Batch artifact generation
Branch Operations
BRANCH_CREATE: Create new branchBRANCH_MERGE: Merge branchBRANCH_REBASE: Rebase branchBRANCH_DELETE: Delete branchBRANCH_VALIDATE: Validate branch state
Proposed Changes
PROPOSED_CHANGE_MERGE: Merge proposed changeREQUEST_PROPOSED_CHANGE_PIPELINE: Run full validation pipelineREQUEST_PROPOSED_CHANGE_DATA_INTEGRITY: Data integrity checksREQUEST_PROPOSED_CHANGE_SCHEMA_INTEGRITY: Schema integrity checks
Creating Workflows
Define a Flow
Define Tasks
Register Workflow
Submitting Workflows
Via Workflow Service
Execute and Wait
Batch Execution
Workflow Composition
Parent-Child Flows
Task Dependencies
Scheduled Workflows
Cron Schedule
Scheduled Examples
- Repository Sync: Every minute (
* * * * *) - Telemetry: Daily at random time
- Webhook Config: Daily at 3:XX AM
- Lock Cleanup: Every minute
Concurrency Control
Limit Concurrent Runs
Lock Resources
Error Handling
Task Retries
Exception Handling
Workflow Tags
Tags help categorize and filter workflows:Branch Tags
Tag workflow runs with branches:Workflow Models
WorkflowDefinition
WorkflowInfo
Real-World Examples
Proposed Change Pipeline
Artifact Generation
Best Practices
Design Principles
- Single Responsibility: Each workflow should have one clear purpose
- Idempotent: Workflows should be safe to retry
- Composable: Build complex workflows from simple tasks
- Observable: Add logging and tags for monitoring
Performance
- Use batch operations for parallel execution
- Set appropriate concurrency limits
- Cache task results when appropriate
- Use task retries for transient failures
Monitoring
- Use descriptive flow and task run names
- Add tags for filtering in Prefect UI
- Log important state changes
- Track execution times for bottlenecks
Troubleshooting
Workflow Not Running
- Check workflow is registered in catalogue
- Verify worker pool is running
- Check Prefect server connectivity
- Review workflow deployment status
Task Failures
- Review task logs in Prefect UI
- Check error messages and stack traces
- Verify input parameters
- Test task function independently
Performance Issues
- Profile workflow execution times
- Identify slow tasks
- Parallelize independent operations
- Optimize database queries