Files
seaweedfs/seaweed-block/cmd/sw-block/chunk_plain.go
T
Ping QiuandClaude Opus 5.5 a5686e7fa7 Sync seaweed-block v1.1.1 into seaweed-block/ (#13411)
Brings seaweed-block main (v1.1.1 plus the docs and a test fix after it)
into seaweed-block/ as one commit. Only files under seaweed-block/ change,
and the subtree equals seaweed-block main exactly. The module's full
history stays in the seaweed-block repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 19:04:53 -08:00

40 lines
1.5 KiB
Go

package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"time"
"github.com/seaweedfs/seaweed-block/core/ops"
)
// M5 PlainStop -> Quiesce, INV-CUT-PLAIN-DETACH-001. Keep stdout JSON
// unchanged; the separate human readout identifies the seal to the operator.
func chunkPlainDetachPost(addr, volume string, timeout time.Duration, deadline time.Time, body map[string]any, stdout, stderr io.Writer) int {
var out bytes.Buffer
// CutTime r7: one admission, then the detach's handle is polled; only its
// sequence rises renew the wait, and --deadline is the only total bound.
code := chunkObserveHandle("detach", "/chunk/detach", addr, timeout, deadline, body, &out, stderr)
if code != ops.VolumeStatusExitOK {
if err := writeAll(stdout, out.Bytes()); err != nil {
fmt.Fprintf(stderr, "sw-block ops chunk detach: write result: %v\n", err)
}
return code
}
var seal struct {
VolumeID string `json:"volumeID"`
HeadGen uint64 `json:"headGen"`
}
if err := json.Unmarshal(out.Bytes(), &seal); err != nil || seal.VolumeID != volume || seal.HeadGen == 0 {
return chunkFail("detach", stdout, stderr, chunkExitFailed, codeInternalCLI, "plain detach outcome unknown: reply has no matching volume and sealed HEAD generation", false)
}
if err := writeAll(stdout, out.Bytes()); err != nil {
fmt.Fprintf(stderr, "sw-block ops chunk detach: write result: %v\n", err)
return chunkExitFailed
}
fmt.Fprintf(stderr, "sealed HEAD generation: %d\n", seal.HeadGen)
return ops.VolumeStatusExitOK
}