Skip to content

Implement pageserver drain via storage-controller API #21

Description

@bittermandel

Summary

Currently, the pageserver drain functionality in the operator uses a placeholder implementation with annotations. This needs to be replaced with actual calls to the storage-controller API to properly drain pageservers before deletion.

Current Implementation

The current implementation in crates/neon_cluster/src/controllers/pageserver/pod.rs has two TODO functions:

  • is_pageserver_drained() - Currently checks for a neon.io/drained annotation
  • trigger_pageserver_drain() - Currently only logs the drain request

Required Implementation

Based on the storage controller API (found in storcon_cli), the drain operation should:

  1. Trigger drain: Make a PUT request to control/v1/node/{node_id}/drain
  2. Check drain status: Poll the node status to verify drain completion

API Details

// Trigger drain
storcon_client.dispatch::<(), ()>(
    Method::PUT,
    format\!("control/v1/node/{node_id}/drain"),
    None,
).await?;

Implementation Tasks

  • Add drain methods to StorageControllerClient in crates/neon_cluster/src/storage_controller/client.rs
  • Update trigger_pageserver_drain() to call storage controller API
  • Update is_pageserver_drained() to check actual drain status from storage controller
  • Handle error cases and retries appropriately
  • Add tests for the new functionality

Files to Modify

  • crates/neon_cluster/src/controllers/pageserver/pod.rs - Update drain functions
  • crates/neon_cluster/src/storage_controller/client.rs - Add drain API methods

Additional Context

The pageserver ID is available in the pod labels as neon.io/pageserver-id.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions