---
title: "cordon and drain the server (preemption simulation)"
method: PUT
path: "/mockserver/preemption"
tags: ["chaos"]
---

# cordon and drain the server (preemption simulation)

`PUT /mockserver/preemption`

## Request

- Base URL: `http://localhost:1080`
- URL: `http://localhost:1080/mockserver/preemption`
- Auth: none declared

Simulates a connection-lifecycle preemption (e.g. a Kubernetes node drain or spot reclamation). While cordoned, new exchanges are signalled to back off — by a 503 + Connection: close, an HTTP/2 GOAWAY frame, or both — while in-flight requests are allowed to drain. The simulation is server-scoped and does not stop the JVM. An empty body uses defaults (mode "both", drainMillis from stopDrainMillis, no TTL). drainMillis and ttlMillis are clamped to preemptionSimulationMaxDrainMillis.

## Request body

- PreemptionRequest: preemption simulation parameters (all fields optional)
  - `mode` 'reject503' | 'goaway' | 'both': how draining is signalled: reject503 = 503 + Connection: close; goaway = HTTP/2 GOAWAY frame; both = both
  - `drainMillis` integer: how long in-flight requests are allowed to drain; defaults to the stopDrainMillis property, clamped to preemptionSimulationMaxDrainMillis
  - `ttlMillis` integer: auto-uncordon after this many milliseconds (dead-man's switch); 0 (default) means no auto-uncordon
  - `lastStreamId` integer: HTTP/2 GOAWAY last_stream_id to advertise; -1 (default) lets the server choose

## Response `200`

preemption simulation started or replaced

- PreemptionStatus: current cordon/drain status of the server
  - `state` 'inactive' | 'draining' | 'drained'
  - `inFlight` integer: number of requests currently in flight
  - `drainRemainingMillis` integer: milliseconds left in the drain window
  - `mode` 'reject503' | 'goaway' | 'both': active signalling mode (omitted when inactive)

## Other responses

- `400`: invalid preemption request

---

[API](https://skmtc.dev/mock-server/apis/mockserver-api.md) · [All operations](https://skmtc.dev/mock-server/apis/mockserver-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mock-server/apis/mockserver-api/revisions/9239b693996e?raw)
