MANTA-5496

Migrate to monitor-reef

Status:
Open
Created:
2026-01-08T12:50:14.671-0500
Updated:
2026-01-08T12:53:13.397-0500

Description

Rust Repository Migration Plan

This document outlines the plan for migrating several Rust repositories into the monitor-reef-monorepo.

Repositories to Migrate

Repository

HTTP API

rust-fast

No

rust-cueball

No

rust-libmanta

No

rust-moray

No

rust-utils

No

quickcheck-helpers

No

rust-sharkspotter

No

manta-rebalancer

Yes (Migrate from Gotham to Dropshot)

Dependency Graph

The migration order is determined by dependencies:

manta-rebalancer
├── rebalancer (lib)
├── agent (service)
├── manager (service)
└── rebalancer-adm (cli)
    └── depends on:
        ├── rust-moray
        │   ├── rust-cueball
        │   ├── rust-libmanta
        │   └── rust-fast
        └── rust-libmanta

Migration order (bottom-up): fast → cueball → libmanta → moray → rebalancer

Target Directory Structure

monitor-reef-monorepo/
├── apis/                              # Dropshot API traits
│   ├── rebalancer-agent-api/          # ✅ Agent API trait
│   └── rebalancer-manager-api/        # ✅ Manager API trait
├── clients/internal/
│   ├── rebalancer-agent-client/       # ✅ Progenitor-generated client
│   └── rebalancer-manager-client/     # ✅ Progenitor-generated client
├── cli/
│   └── rebalancer-adm/                # ✅ Admin CLI
├── libs/
│   ├── fast/                          # ✅ Streaming JSON RPC
│   ├── cueball/                       # ✅ Connection pooling core
│   ├── cueball-static-resolver/       # ✅ Static backend list
│   ├── cueball-tcp-stream-connection/ # ✅ TCP stream connections
│   ├── cueball-postgres-connection/   # ✅ PostgreSQL connections
│   ├── libmanta/                      # ✅ Common Manta utilities
│   ├── moray/                         # ✅ Moray k/v store client
│   ├── quickcheck-helpers/            # ✅ Test utilities
│   ├── rebalancer/                    # ✅ Shared types library
│   ├── rust-utils/                    # ✅ File MD5 + DNS utilities
│   └── sharkspotter/                  # ✅ Storage node discovery
└── services/
    ├── rebalancer-agent/              # ✅ Agent HTTP service (Dropshot)
    └── rebalancer-manager/            # ✅ Manager HTTP service (Dropshot)

Phase 1: Create libs/ and Migrate rust-fast

Source: rust-fast

Why first: rust-fast has no Triton dependencies; rust-moray requires it.

What is rust-fast?

Steps

  1. Create libs/ directory

  2. Clone rust-fast repository

  3. Copy source to libs/fast/

  4. Update libs/fast/Cargo.toml:

    • Set edition.workspace = true

    • Convert dependencies to workspace references

  5. Add to root Cargo.toml workspace members

  6. Add required workspace dependencies

  7. Build and test: cargo build -p fast && cargo test -p fast

Expected Workspace Dependencies

# From rust-fast (to be verified during migration)
bytes = "1.0"
futures = "0.3"

Commit Message

Add fast library (rust-fast migration)

Migrate rust-fast into the monorepo as libs/fast.
This provides streaming JSON RPC over TCP, required by moray.

Source: https://github.com/TritonDataCenter/rust-fast

Phase 2: Migrate rust-cueball (7 crates)

Source: rust-cueball

Why second: rust-moray depends on cueball for connection pooling.

What is rust-cueball?

Crates to Migrate

Crate

Internal Dependencies

Purpose

cueball

(none)

Core connection pooling

cueball-dns-resolver

cueball

DNS-based service discovery

cueball-static-resolver

cueball

Static backend list

cueball-tcp-stream-connection

cueball

TCP stream connections

cueball-postgres-connection

cueball

PostgreSQL connections

manatee-primary-resolver

cueball

Manatee primary detection

manatee-echo-resolver

cueball, manatee-primary-resolver

Echo resolver tool

Steps

  1. Clone rust-cueball repository

  2. Copy each crate into libs/ (flatten the nested workspace)

  3. Update inter-crate dependencies to use path references:

    cueball = { path = "../cueball" }
  4. Update each Cargo.toml for workspace conventions

  5. Add all 7 crates to workspace members

  6. Add required workspace dependencies

  7. Build and test all crates

Expected Workspace Dependencies

# From rust-cueball (to be verified during migration)
arc-swap = "1.0"
trust-dns-resolver = "0.23"
tokio-postgres = "0.7"

Commit Message

Add cueball connection pooling libraries

Migrate rust-cueball workspace (7 crates) into the monorepo:
- cueball: Core connection pooling
- cueball-dns-resolver: DNS-based service discovery
- cueball-static-resolver: Static backend list
- cueball-tcp-stream-connection: TCP stream connections
- cueball-postgres-connection: PostgreSQL connections
- manatee-primary-resolver: Manatee primary detection
- manatee-echo-resolver: Echo resolver tool

Source: https://github.com/TritonDataCenter/rust-cueball

Phase 3a: Migrate rust-libmanta

Source: rust-libmanta

What is rust-libmanta?

Steps

  1. Clone rust-libmanta repository

  2. Copy to libs/libmanta/

  3. Preserve feature flags (diesel/postgres, diesel/sqlite)

  4. Update to workspace conventions

  5. Build and test

Expected Workspace Dependencies

# From rust-libmanta (to be verified during migration)
md5 = "0.7"
# diesel already in workspace

Commit Message

Add libmanta common utilities

Migrate rust-libmanta into the monorepo as libs/libmanta.
Provides common Manta utilities including data serialization and database support.

Source: https://github.com/TritonDataCenter/rust-libmanta

Phase 3b: Migrate rust-moray

Source: rust-moray

What is rust-moray?

Steps

  1. Clone rust-moray repository

  2. Copy to libs/moray/

  3. Update dependencies to use internal paths:

    cueball = { path = "../cueball" }
    libmanta = { path = "../libmanta" }
    fast = { path = "../fast" }
  4. Build and test integration with internal dependencies

Commit Message

Add moray key-value store library

Migrate rust-moray into the monorepo as libs/moray.
Provides Moray client using Fast protocol over cueball connections.

Source: https://github.com/TritonDataCenter/rust-moray

Phase 4a: Migrate Utility Libraries (COMPLETE)

Status: ✅ Committed

Migrated supporting utility libraries required by manta-rebalancer:

Library

Description

Updates

libs/rust-utils

File MD5 + DNS lookup

base64 0.22, hickory-resolver 0.25

libs/quickcheck-helpers

Random string generation

quickcheck 1.0, rand 0.9

Phase 4b: Migrate rust-sharkspotter (COMPLETE)

Status: ✅ Committed

Source: rust-sharkspotter

Migration Complexity: HIGH (completed)

Sharkspotter required significant refactoring:

Dependency

From

To

Effort

clap

2.x

4.x

High (API rewrite)

trust-dns-resolver

0.11

hickory-resolver 0.25

Medium

tokio

0.2

1.x

Medium

tokio-postgres

0.5

0.7

Low

serde_postgres

0.2

(removed)

Low

Changes Made

  1. clap 2 → 4: AppCommand, value_t!.get_one(), Arg::with_name()Arg::new(), .short("x").short('x')

  2. trust-dns-resolver → hickory-resolver: Async API with sync wrapper using tokio::task::block_in_place

  3. tokio 0.2 → 1.x: basic_scheduler()new_current_thread()

  4. serde_postgres removed: Replaced with manual column extraction (incompatible with tokio-postgres 0.7)

Phase 4c: Migrate manta-rebalancer (COMPLETE)

Source: manta-rebalancer

Migration Strategy: Full Dropshot Rewrite

Rather than attempting to migrate the legacy gotham 0.4 code (which uses pre-async/await futures 0.1), we chose to do a complete Dropshot rewrite. This approach:

What is manta-rebalancer?

Completed Components

Component

Location

Status

Shared types library

libs/rebalancer/

✅ Complete

Agent API trait

apis/rebalancer-agent-api/

✅ Complete

Manager API trait

apis/rebalancer-manager-api/

✅ Complete

Agent client

clients/internal/rebalancer-agent-client/

✅ Complete

Manager client

clients/internal/rebalancer-manager-client/

✅ Complete

Admin CLI

cli/rebalancer-adm/

✅ Complete

Agent service

services/rebalancer-agent/

✅ Complete

Manager service

services/rebalancer-manager/

✅ Complete

HTTP APIs (Dropshot)

Manager API (apis/rebalancer-manager-api/):

Agent API (apis/rebalancer-agent-api/):

CLI Commands (cli/rebalancer-adm/)

# Job management (via manager service)
rebalancer-adm job --manager-url URL create --from-shark <shark>
rebalancer-adm job --manager-url URL list
rebalancer-adm job --manager-url URL status <uuid>
rebalancer-adm job --manager-url URL update <uuid> --metadata-threads <n>
rebalancer-adm job --manager-url URL retry <uuid>

# Assignment queries (via agent)
rebalancer-adm assignment --agent-url URL status <uuid>

Implementation Notes

The services are implemented with in-memory state. Future enhancements may include:

Agent Service (services/rebalancer-agent/):

Manager Service (services/rebalancer-manager/):

Commits

  1. a76e2f6 - Add rebalancer API types and Dropshot traits

  2. 20be4a1 - Add rebalancer client libraries and CLI

  3. (current) - Add rebalancer service implementations

Phase 5: Future Enhancements

Status: All core migrations complete

The migration is functionally complete. Future work includes:

Risks and Mitigations

Risk

Mitigation

Rust edition mismatch (2018/2021 → 2024)

Update edition, fix compilation issues

Dependency version conflicts

Update to workspace versions, test thoroughly

Tests requiring external services

Mark with #[ignore], document requirements

Breaking changes during Dropshot conversion

Compare OpenAPI specs, integration tests

Naming Conventions

Success Criteria

All success criteria have been met:

# Full workspace builds
cargo build --workspace
cargo test --workspace
cargo clippy --workspace

# All rebalancer components
cargo build -p rebalancer
cargo build -p rebalancer-agent-api
cargo build -p rebalancer-manager-api
cargo build -p rebalancer-agent-client
cargo build -p rebalancer-manager-client
cargo build -p rebalancer-agent
cargo build -p rebalancer-manager
cargo build -p rebalancer-adm
cargo test -p rebalancer -p rebalancer-agent -p rebalancer-manager

References