A cloud infrastructure monitoring and remediation system inspired by Uber's Crane. Crane OSS automatically detects problematic hosts in your infrastructure and takes corrective actions to maintain system reliability.
Crane OSS is a distributed system that continuously monitors your cloud infrastructure for host-level issues, detects problematic hosts, and automatically orchestrates remediation actions like draining, replacing, or recreating hosts.
The system consists of several key components:
- Bad Host Detector (BHD): Continuously scans hosts for various problems using configurable checks
- Activity Manager: Analyzes detected problems and makes decisions about remediation actions
- Action Executor: Executes remediation actions (drain, replace, create hosts)
- Host Catalog: Maintains a centralized registry of all hosts
- Problem Store: Persists detected problems for trend analysis and decision making
- Dominator: Receives heartbeats from hosts and returns desired state
- Subd: Agent that runs on hosts to report status and apply desired state
- Drain Host: Gracefully remove host from service while maintaining availability
- Replace Host: Replace problematic host with a new instance
- Create Host: Provision new hosts when needed
- Go 1.21+
- PostgreSQL database
- AWS credentials (for AWS EC2 integration)
- Docker and Docker Compose (for local development)
Create a PostgreSQL database named crane and ensure it's accessible. The default connection is:
- Host: localhost (or
dbwhen using Docker) - Port: 5432
- User: postgres
- Password: mysecretpassword
- Database: crane
Create a bhd.json configuration file:
{
"zone": "us-west-2",
"scan_interval": 1,
"checks": [
"aws.ec2.unhealthy",
"host.store.check"
]
}Configuration Fields:
zone: AWS region (e.g.,us-west-2)scan_interval: Scan interval in minutes (integer)checks: Array of check names to run
Available Checks:
aws.ec2.unhealthy: Checks EC2 instance health status in AWShost.store.check: Checks host health and heartbeat in the database
docker compose upThe crane-api service will start on port 43060 and begin monitoring hosts in the configured zone.
GET /health- Health check endpointGET /v1/db/health- Database health check
POST /v1/heartbeat?hostID=<host-id>- Receives host state and returns desired stateGET /v1/health- Health checkGET /v1/db/health- Database health check
├── cmd/
│ ├── crane-api/ # Main application entry point
│ ├── dominator/ # Dominator service
│ └── subd/ # Host agent
├── internal/
│ ├── activitymanager/ # Problem analysis and decision making
│ ├── badhost/ # Bad host detection and problem scanning
│ │ ├── checks/ # Check implementations (AWS, host store)
│ │ └── problem/ # Problem storage
│ ├── dominator/ # Receives heartbeats from hosts
│ ├── execute/ # Action execution and worker management
│ ├── hostcatalog/ # Host registry and management
│ │ ├── http/ # HTTP handlers
│ │ └── store/ # Database repository
│ ├── provider/ # Cloud provider abstractions
│ │ ├── awscompute/ # AWS EC2 provider
│ │ └── noop_provider/ # No-op provider for testing
│ └── subd/ # Host agent
├── postgres_data/ # SQL scripts and data
└── pkg/
└── api/ # Shared API types and interfaces
The Activity Manager uses the following decision logic:
- SMART Failure or Cycling Host → Replace Host
- Unreachable Host → Drain Host
- 2+ Critical Problems → Replace Host
- 1 Critical Problem → Drain Host
- Warning/Info Only → No Action
| Variable | Default | Description |
|---|---|---|
| DB_HOST | localhost | Database host |
| DB_PORT | 5432 | Database port |
| DB_USER | postgres | Database user |
| DB_PASSWORD | mysecretpassword | Database password |
| DB_NAME | crane | Database name |
| AWS_ACCESS_KEY_ID | - | AWS access key |
| AWS_SECRET_ACCESS_KEY | - | AWS secret key |
| AWS_REGION | us-west-2 | AWS region |
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
People who wrote Crane: Uber's Next-Gen Infrastructure Stack
- Kurtis Nusbaum
- Tim Miller
- Brandon Bercovich
- Bharath Siravara
People from PlatformCon and PlatformEngineering.org