How percona/orchestrator works
Project Overview and Type
• This is a backend service written in Go. Its primary purpose is to monitor, map, and manage MySQL replication topologies. It provides three interfaces: a command-line interface (CLI), an HTTP API, and a Web interface.
• Key functional areas include discovery (crawling MySQL topologies), refactoring (restructuring replication relationships), and recovery (handling failovers and automated/manual recovery).
Analyzing the File Structure
• The “go” directory contains the core business logic. Look at subdirectories like:
– go/app and go/cmd/orchestrator for entry points (CLI and main execution).
– go/agent and go/inst for interacting with MySQL instances and maintaining topology information.
– go/discovery for modules that probe and discover replication status.
– go/logic for recovery and refactoring algorithms.
– go/http for HTTP API endpoints and web server functionality.
– go/raft, which suggests a Raft implementation is used for leader election and state replication.
• There are additional directories for configuration (conf), templates (resources/templates), public resources for the Web UI (resources/public), and extensive tests (tests/*), which indicate robust integration and system testing.
• Dockerfiles and Vagrant files point to containerized and virtualized environments used for deployment/testing.
Key Components to Represent (Main Components and Their Interactions)
a. Orchestrator Service Core
– State Management & Coordination: The Raft module that handles internal coordination and leader election.
– Business Logic: Modules under “go/logic”, “go/inst”, “go/attributes”, etc., which manage topology evaluation and replication state.
b. API and Interface Layers
– HTTP API Component: Handles incoming RESTful API calls and serves JSON responses.
– Web Interface: Uses resources from “resources/public” and “resources/templates” to render the UI.
– CLI Tool: Represented by the command-line interface as well as “go/app/cli.go”.
c. Data Access Layer
– Database Interaction: The “go/db” modules, which support migration, patch generation, and TLS configuration when interacting with MySQL.
d. External Dependencies
– MySQL Servers: External MySQL instances that the Orchestrator monitors, discovers, and upon which it occasionally executes change commands during disaster recovery, refactoring, or troubleshooting tasks.
– Configuration Files: Shown as an external “conf” source of configurations for different deployment scenarios (e.g., sample configs provided for different modes such as “raft”, “system”, “simple”).
– Logging/Metrics: Modules under “go/golib/log” and “go/metrics” indicate integration with external monitoring or logging systems.
– Integration with CI tools and container orchestration (Docker and Vagrant). These may be depicted as the deployment and testing envelopes.