feat: admit captured snapshot deletes from the public CLI

This commit is contained in:
pingqiu committed 2026-12-01 20:05:17 -08:00
1 parent 2aa31e3be5
commit b5e940da0c
6 files changed
+281 -31

No files matched your search

@@ -3,10 +3,12 @@ package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore"
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
)
// chunkRunCatalogSnapshotDelete is the CLI-owned execution/observation seam.
@@ -14,28 +16,73 @@ import (
// catalog's shared atomic unlink/intent adapter. No background server or
// process-local progress is added.
func chunkRunCatalogSnapshotDelete(ctx context.Context, cat *chunkstore.BCatalog, volume chunkstore.VolumeRef, op chunkstore.SnapshotOperation, work chunkstore.SnapshotDeleteWork, noWait bool, stdout, stderr io.Writer) int {
answer, err := chunkCatalogSnapshotDeleteAnswer(ctx, cat, volume, op, work, noWait, stderr)
if err != nil {
return chunkResult("snapshot-delete", nil, err, stdout, stderr)
}
if raw, ok := answer.(json.RawMessage); ok {
if err := writeAll(stdout, raw); err != nil {
return chunkExitFailed
}
return 0
}
return chunkResult("snapshot-delete", answer, nil, stdout, stderr)
}
func chunkCatalogSnapshotDeleteAnswer(ctx context.Context, cat *chunkstore.BCatalog, volume chunkstore.VolumeRef, op chunkstore.SnapshotOperation, work chunkstore.SnapshotDeleteWork, noWait bool, stderr io.Writer) (any, error) {
fmt.Fprintf(stderr, "snapshot-delete request id %s instance %s sequence %d; repeat with the same --request-id to resume\n", op.ID, op.Instance, op.Sequence)
if op.State == "refused" {
return nil, &chunkstore.CatalogError{Code: op.ErrorCode, Message: op.ErrorMessage}
}
if noWait {
return chunkResult("snapshot-delete", struct {
ID string `json:"operation_id"`
Volume string `json:"volume_id"`
Instance string `json:"instance"`
Sequence uint64 `json:"sequence"`
State string `json:"state"`
}{op.ID, op.VolumeID.String(), op.Instance, op.Sequence, op.State}, nil, stdout, stderr)
return map[string]any{"operation_id": op.ID, "volume_id": op.VolumeID.String(), "instance": op.Instance, "sequence": op.Sequence, "state": op.State}, nil
}
answer, err := cat.RunSnapshotDeleteOperation(ctx, volume, op, work)
if err != nil {
return chunkFail("snapshot-delete", stdout, stderr, chunkExitFailed, "no_progress", err.Error()+"; resume with --request-id "+op.ID, true)
return nil, &chunkstore.CatalogError{Code: "no_progress", Message: err.Error() + "; resume with --request-id " + op.ID, Retryable: true, Err: err}
}
if answer.State == "refused" {
return chunkFail("snapshot-delete", stdout, stderr, chunkExitFailed, answer.ErrorCode, answer.ErrorMessage, false)
return nil, &chunkstore.CatalogError{Code: answer.ErrorCode, Message: answer.ErrorMessage}
}
if answer.State != "succeeded" || len(answer.Result) == 0 || !json.Valid(answer.Result) {
return chunkFail("snapshot-delete", stdout, stderr, chunkExitFailed, codeInternalCLI, "operation has no terminal result", false)
return nil, &chunkstore.CatalogError{Code: codeInternalCLI, Message: "operation has no terminal result"}
}
if err := writeAll(stdout, answer.Result); err != nil {
return chunkExitFailed
return answer.Result, nil
}
func chunkAdmitCatalogSnapshotDelete(ctx context.Context, cat *chunkstore.BCatalog, volume chunkstore.VolumeRef, id, name string, noWait bool, stderr io.Writer) (any, error) {
st, err := cat.Store(volume)
if err != nil {
return nil, err
}
return 0
op, err := st.AdmitSnapshotDeleteOperation(ctx, id, name, func(ctx context.Context) (uint64, error) {
h, found, err := st.ReadHead(ctx)
if err != nil {
return 0, err
}
if !found {
return 0, layout.ErrHeadAbsent
}
if h.Version != layout.HeadVersion1 {
return 0, &chunkstore.CatalogError{Code: "snapshot_generation_unavailable", Message: "attach with a v1.1 holder to stamp snapshot generations before operation-based deletion", Retryable: true}
}
target, found := h.Snapshots[name]
if !found {
return 0, nil
}
if target.Gen == 0 {
return 0, &chunkstore.CatalogError{Code: "snapshot_generation_unavailable", Message: "snapshot has no publishing generation; attach with a v1.1 holder first", Retryable: true}
}
return target.Gen, nil
})
if err != nil {
if errors.Is(err, chunkstore.ErrSnapshotOperationIntent) {
return nil, &chunkstore.CatalogError{Code: "operation_intent_conflict", Message: err.Error(), Err: err}
}
if errors.Is(err, chunkstore.ErrSnapshotOperationRetired) {
return nil, &chunkstore.CatalogError{Code: "operation_retired", Message: err.Error(), Err: err}
}
return nil, err
}
return chunkCatalogSnapshotDeleteAnswer(ctx, cat, volume, op, nil, noWait, stderr)
}
@@ -131,3 +131,169 @@ func TestSnapshotDeleteOfflineCLIUsesAtomicLogicalStep(t *testing.T) {
t.Fatalf("CLI did not use atomic unlink/intent: %+v %v", h, err)
}
}
func TestSnapshotDeletePublicOperationKeepsTargetAcrossRecreation(t *testing.T) {
ctx := context.Background()
mem := newMemChunkStore()
useMemChunkStore(t, mem)
v := cliVolume(t, mem, "v1", "daily")
cat, _ := chunkstore.NewBCatalog(mem, mem, defaultChunkPathCLI)
st, _ := cat.Store(v)
h, _, err := st.ReadHead(ctx)
if err != nil {
t.Fatal(err)
}
target := h.Snapshots["daily"]
target.Gen = h.Gen + 1
h.Version = layout.HeadVersion1
h.Snapshots["daily"] = target
if err = st.UpdateHead(ctx, h.Gen, h, layout.CauseCommit); err != nil {
t.Fatal(err)
}
args := cliArgs("snapshot-delete", volArgs("volume", v), []string{"--name", "daily", "--request-id", "delete-original"})
code, first, logs := runChunk(args...)
if code != 0 {
t.Fatalf("delete admission: %d %s %s", code, first, logs)
}
if !strings.Contains(logs, "delete-original") {
t.Fatalf("missing resumable identity: %s", logs)
}
h, _, err = st.ReadHead(ctx)
if err != nil || len(h.Snapshots) != 0 || h.List == nil {
t.Fatalf("logical delete: %+v %v", h, err)
}
replacement := target
replacement.Gen = h.Gen + 1
h.Snapshots = map[string]layout.Snapshot{"daily": replacement}
if err = st.UpdateHead(ctx, h.Gen, h, layout.CauseCommit); err != nil {
t.Fatal(err)
}
code, replay, logs := runChunk(args...)
if code != 0 || replay != first {
t.Fatalf("original reply changed: code=%d first=%s replay=%s logs=%s", code, first, replay, logs)
}
h, _, err = st.ReadHead(ctx)
if err != nil || h.Snapshots["daily"].Gen != replacement.Gen {
t.Fatalf("retry removed replacement: %+v %v", h, err)
}
}
func TestSnapshotDeletePublicNoWaitResumesSameAdmission(t *testing.T) {
ctx := context.Background()
mem := newMemChunkStore()
useMemChunkStore(t, mem)
v := cliVolume(t, mem, "v1", "daily")
cat, _ := chunkstore.NewBCatalog(mem, mem, defaultChunkPathCLI)
st, _ := cat.Store(v)
h, _, err := st.ReadHead(ctx)
if err != nil {
t.Fatal(err)
}
snap := h.Snapshots["daily"]
snap.Gen = h.Gen + 1
h.Version = layout.HeadVersion1
h.Snapshots["daily"] = snap
if err = st.UpdateHead(ctx, h.Gen, h, layout.CauseCommit); err != nil {
t.Fatal(err)
}
args := cliArgs("snapshot-delete", volArgs("volume", v), []string{"--name", "daily", "--request-id", "queued-delete"})
code, out, logs := runChunk(append(args, "--no-wait")...)
if code != 0 || !strings.Contains(out, `"operation_id":"queued-delete"`) {
t.Fatalf("admission: %d %s %s", code, out, logs)
}
after, _, err := st.ReadHead(ctx)
if err != nil || after.Gen != h.Gen+1 || len(after.Snapshots) != 1 {
t.Fatalf("no-wait executed: %+v %v", after, err)
}
op, found, err := st.ReadSnapshotOperation(ctx, "queued-delete", "delete")
if err != nil || !found || *op.TargetGeneration != snap.Gen {
t.Fatalf("missing durable target: %+v %v", op, err)
}
code, out, logs = runChunk(args...)
if code != 0 || !strings.Contains(out, `"gen":`) {
t.Fatalf("resume: %d %s %s", code, out, logs)
}
after, _, err = st.ReadHead(ctx)
if err != nil || len(after.Snapshots) != 0 || after.List == nil {
t.Fatalf("resume not logical: %+v %v", after, err)
}
}
func TestSnapshotDeletePublicAbsentHeadRefuses(t *testing.T) {
mem := newMemChunkStore()
useMemChunkStore(t, mem)
id, _ := layout.ParseVolumeID("00000000000000000000000000000001")
v := chunkstore.VolumeRef{Name: "missing", ID: id}
args := cliArgs("snapshot-delete", volArgs("volume", v), []string{"--name", "daily", "--request-id", "absent"})
code, out, _ := runChunk(args...)
if code != chunkExitFailed || chunkErrorOut(t, out).Code != "volume_not_found" {
t.Fatalf("absent HEAD accepted: %d %s", code, out)
}
}
func TestSnapshotDeletePublicRefusesUnstampedLegacyAndChangedIntent(t *testing.T) {
ctx := context.Background()
mem := newMemChunkStore()
useMemChunkStore(t, mem)
v := cliVolume(t, mem, "v1", "daily")
args := cliArgs("snapshot-delete", volArgs("volume", v), []string{"--name", "daily", "--request-id", "kept"})
code, out, _ := runChunk(args...)
if code != chunkExitFailed || chunkErrorOut(t, out).Code != "snapshot_generation_unavailable" || !chunkErrorOut(t, out).Retryable {
t.Fatalf("legacy target admitted: %d %s", code, out)
}
cat, _ := chunkstore.NewBCatalog(mem, mem, defaultChunkPathCLI)
st, _ := cat.Store(v)
h, _, err := st.ReadHead(ctx)
if err != nil {
t.Fatal(err)
}
snap := h.Snapshots["daily"]
snap.Gen = h.Gen + 1
h.Version = layout.HeadVersion1
h.Snapshots["daily"] = snap
if err = st.UpdateHead(ctx, h.Gen, h, layout.CauseCommit); err != nil {
t.Fatal(err)
}
code, out, _ = runChunk(append(args, "--no-wait")...)
if code != 0 {
t.Fatalf("admission: %d %s", code, out)
}
changed := cliArgs("snapshot-delete", volArgs("volume", v), []string{"--name", "other", "--request-id", "kept"})
code, out, _ = runChunk(changed...)
if code != chunkExitFailed || chunkErrorOut(t, out).Code != "operation_intent_conflict" || chunkErrorOut(t, out).Retryable {
t.Fatalf("changed intent accepted: %d %s", code, out)
}
h, _, err = st.ReadHead(ctx)
if err != nil || h.Snapshots["daily"].Gen != snap.Gen {
t.Fatalf("changed intent wrote HEAD: %+v %v", h, err)
}
}
func TestSnapshotDeletePublicInitiallyAbsentIsRetainedRefusal(t *testing.T) {
ctx := context.Background()
mem := newMemChunkStore()
useMemChunkStore(t, mem)
v := cliVolume(t, mem, "v1", "daily")
cat, _ := chunkstore.NewBCatalog(mem, mem, defaultChunkPathCLI)
st, _ := cat.Store(v)
h, _, err := st.ReadHead(ctx)
if err != nil {
t.Fatal(err)
}
snap := h.Snapshots["daily"]
snap.Gen = h.Gen + 1
h.Version = layout.HeadVersion1
h.Snapshots["daily"] = snap
if err = st.UpdateHead(ctx, h.Gen, h, layout.CauseCommit); err != nil {
t.Fatal(err)
}
args := cliArgs("snapshot-delete", volArgs("volume", v), []string{"--name", "absent", "--request-id", "missing-delete", "--no-wait"})
code, out, _ := runChunk(args...)
if code != chunkExitFailed || chunkErrorOut(t, out).Code != "not_found" {
t.Fatalf("absence reported accepted: %d %s", code, out)
}
op, found, err := st.ReadSnapshotOperation(ctx, "missing-delete", "delete")
if err != nil || !found || op.State != "refused" || *op.TargetGeneration != 0 {
t.Fatalf("absence not retained: %+v %v", op, err)
}
}
+10 -1
View File
@@ -205,17 +205,26 @@ func chunkSnapshots(args []string, stdout, stderr io.Writer) int {
func chunkSnapshotDelete(args []string, stdout, stderr io.Writer) int {
c := newBCommand("snapshot-delete", 30*time.Second, stdout, stderr)
var vol volumeFlags
var name string
var name, requestID string
var noWait bool
c.bindVolume(&vol, "volume", "volume")
c.fs.StringVar(&name, "name", "", "snapshot name")
c.fs.StringVar(&requestID, "request-id", "", "stable identity for operation-based snapshot deletion; reuse on retry")
c.fs.BoolVar(&noWait, "no-wait", false, "persist the delete operation without executing it; requires --request-id")
var ref chunkstore.VolumeRef
return c.run(args, true, func() (err error) {
if name == "" {
return errors.New("--name is required")
}
if noWait && requestID == "" {
return errors.New("--no-wait requires --request-id")
}
ref, err = vol.ref("volume")
return err
}, func(ctx context.Context, cat *chunkstore.BCatalog) (any, error) {
if requestID != "" {
return chunkAdmitCatalogSnapshotDelete(ctx, cat, ref, requestID, name, noWait, stderr)
}
if _, err := cat.DeleteSnapshot(ctx, ref, name); err != nil {
return nil, err
}
@@ -78,16 +78,17 @@ var headReaders = map[string]string{
"core/frontend/chunkstore/snapshot_operation_cleanup.go deleteSnapshotOperations -> ReadHead": "absent or not-deleted HEAD refuses cleanup without deleting operation authority (TestSnapshotOperationCleanupRequiresDeletedHead)",
// above the chunk store: they read through the layout remote's GetHead, so an
// absent HEAD reaches them as ErrHeadAbsent, never as a zero HEAD (probe LayoutRemote)
"cmd/sw-block/chunk_b.go chunkShowContext -> ReadHead": "found=false: prints a null head, including via the chunkShow wrapper (probe TestOpsChunk_AbsentVolume)",
"cmd/sw-block/chunk_b.go chunkSnapshots -> ReadHead": "refuses volume_not_found (probe TestOpsChunk_AbsentVolume)",
"core/frontend/durable/provider_chunk.go GetHead -> GetHead": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/frontend/durable/provider_chunk.go EachSegment -> GetHead": "a remote without a segment read: ErrHeadAbsent from its GetHead, as GetHead (probe LayoutRemote)",
"core/frontend/durable/provider_chunk.go GetHeadRoot -> GetHeadRoot": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/storage/chunk_head_belt.go confirmChunkHead -> GetHead": "ErrHeadAbsent from the layout remote: not confirmed (probe LayoutRemote)",
"core/storage/chunk_head_belt.go confirmChunkHead -> GetHeadRoot": "ErrHeadAbsent from the layout remote: not confirmed (probe LayoutRemote)",
"core/storage/chunk_head_belt.go readChunkHead -> GetHead": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/storage/chunk_head_belt.go readChunkHeadRoot -> GetHeadRoot": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/storage/chunk_layer.go readAttachHead -> GetHead": "ErrHeadAbsent from the layout remote; its segment read (EachSegment) reads HEAD as GetHead does (headIdentityLocked) (probe LayoutRemote)",
"cmd/sw-block/chunk_b.go chunkShowContext -> ReadHead": "found=false: prints a null head, including via the chunkShow wrapper (probe TestOpsChunk_AbsentVolume)",
"cmd/sw-block/chunk_b.go chunkSnapshots -> ReadHead": "refuses volume_not_found (probe TestOpsChunk_AbsentVolume)",
"cmd/sw-block/catalog_snapshot_operation.go chunkAdmitCatalogSnapshotDelete -> ReadHead": "refuses volume_not_found before operation admission when HEAD is absent (probe TestSnapshotDeletePublicAbsentHeadRefuses)",
"core/frontend/durable/provider_chunk.go GetHead -> GetHead": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/frontend/durable/provider_chunk.go EachSegment -> GetHead": "a remote without a segment read: ErrHeadAbsent from its GetHead, as GetHead (probe LayoutRemote)",
"core/frontend/durable/provider_chunk.go GetHeadRoot -> GetHeadRoot": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/storage/chunk_head_belt.go confirmChunkHead -> GetHead": "ErrHeadAbsent from the layout remote: not confirmed (probe LayoutRemote)",
"core/storage/chunk_head_belt.go confirmChunkHead -> GetHeadRoot": "ErrHeadAbsent from the layout remote: not confirmed (probe LayoutRemote)",
"core/storage/chunk_head_belt.go readChunkHead -> GetHead": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/storage/chunk_head_belt.go readChunkHeadRoot -> GetHeadRoot": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/storage/chunk_layer.go readAttachHead -> GetHead": "ErrHeadAbsent from the layout remote; its segment read (EachSegment) reads HEAD as GetHead does (headIdentityLocked) (probe LayoutRemote)",
}
// TestHeadReaders_Enumeration lists every HEAD reader in core/ and cmd/ from
+5 -3
View File
@@ -605,8 +605,10 @@ Delete admission fixes the target's publishing generation in its durable
receipt and canonical intent commitment (SnapDelete rows 241–245). A retained
receipt is read before resolving the name; a torn admission may re-resolve only
to verify the same committed target. The resolver must finish the legacy stamp
before returning an entry generation. The catalog/kernel target-qualified
removal and legacy-stamp callers are not wired yet; delete rows remain STUB.
before returning an entry generation. The CLI admits a retained target only after the holder has stamped its generation;
unstamped legacy entries refuse with a retryable diagnostic. Its executor uses
the catalog/kernel atomic unlink-and-intent adapter; native qualification of
the public command remains pending, so delete rows remain STUB.
A request ID and canonical intent identify a durable receipt under the immutable
volume directory. A compact CAS index admits at most 4096 sequences and binds
@@ -1344,7 +1346,7 @@ Notes:
| `INV-SNAP-OP-FINGERPRINT-001` | A retained operation ID reused with changed snapshot intent refuses before any cut or HEAD write. | M9 operation admission (planned) | `CreateSnapshotOperation` canonical fingerprint; create executor wired; delete executor pending | `TestSnapshotOperationSameIDChangedIntentRefusesBeforeWrite` (`core/host/volume/snapshot_operation_red_test.go`) | SnapOps.Send; rows 211–219 | STUB |
| `INV-SNAP-OP-READMIT-001` | A create whose HEAD publication applied before its answer was lost reconciles that original outcome on re-admission; later removal cannot cause another execution under its retained operation ID. | M9 operation re-admission (planned) | `SnapshotOperationBinding`, `LayoutStore.GuardSnapshotOperations`; create executor and compact index wired; native qualification pending | `TestSnapshotOperationLostPublishAnswerReadmitDeleteCannotRepublish`, `TestSnapshotOperationRemovalBeforeReadmitKeepsPublishedOutcome` (`core/host/volume/snapshot_operation_red_test.go`) | SnapOps.Send/Publish/Settle/Delete; rows 211–219 (persisted-stall removal controls included; concurrent-owner controls pending) | STUB |
| `INV-SNAP-OP-CLI-001` | Snapshot observation preserves the printed operation ID across retries, polling, interruption and no-wait submission; observing an operation never admits another identity. | M9 operation observation (planned) | `chunkObserveSnapshot`, holder asynchronous create executor | `TestSnapshotOperationCLIUsesPrintedIDForAsyncObservation`, `TestSnapshotOperationCLIInterruptThenResumeUsesPrintedID` (`cmd/sw-block/snapshot_operation_red_test.go`, `cmd/sw-block/snapshot_operation_interrupt_unix_test.go`) | SnapOps.Send/Start; rows 211–219 (server crash controls owed) | STUB |
| `INV-SNAP-DELETE-NAME-001` | Name-only snapshot deletion refuses v1.1 HEAD without a HEAD write. A lost-reply retry cannot delete a same-name replacement; a v1.1 delete needs a retained target and its durable intent. | M9 legacy delete admission | `layout.RunDeleteSnapshot`; catalog, CLI and host delete routes | `TestSnapshotDeleteLegacyCLIRetryCannotDeleteV11Replacement`, `TestSnapshotDeleteLegacyHostRetryCannotDeleteV11Replacement` | SnapDelete row 242; rows 241-245 | STUB |
| `INV-SNAP-DELETE-NAME-001` | Name-only snapshot deletion refuses v1.1 HEAD without a HEAD write. A lost-reply retry cannot delete a same-name replacement; a v1.1 delete needs a retained target and its durable intent. | M9 legacy delete admission | `layout.RunDeleteSnapshot`; catalog, CLI and host delete routes | `TestSnapshotDeleteLegacyCLIRetryCannotDeleteV11Replacement`, `TestSnapshotDeleteLegacyHostRetryCannotDeleteV11Replacement`, `TestSnapshotDeletePublicOperationKeepsTargetAcrossRecreation`, `TestSnapshotDeletePublicNoWaitResumesSameAdmission`, `TestSnapshotDeletePublicAbsentHeadRefuses` | SnapDelete row 242; rows 241-245 | STUB |
| `INV-SNAP-DELETE-LOGICAL-001` | A delete receipt succeeds only after its retained target is proven absent. Actual unlink and its durable reclamation intent publish in one HEAD CAS; physical continuation depends on HEAD/pages, not the receipt. | M9 delete running to succeeded | `snapshotDeleteLogicalStep`, `RunDeleteSnapshotWithIntent` | `TestSnapshotDeleteLogicalCommitKeepsIndependentIntent`, `TestSnapshotDeleteLogicalCommitResumesAcrossLostAnswers`, `TestSnapshotDeleteLogicalCommitSparesReplacement` | SnapDelete rows 241-245; PageChain rows 246-253 | STUB |
| `INV-SNAP-DELETE-EXECUTOR-001` | A catalog delete attempt reads its issued handle before work, takes ownership by receipt CAS, and persists uncertain work as stalled. It never infers terminal success from a callback return; terminal replay reads the same incarnation. | M9 delete attempt transport | `BCatalog.RunSnapshotDeleteOperation`; CLI execution seam | `TestSnapshotDeleteCatalogResumesDurableIntentOnAnotherExecutor`, `TestSnapshotDeleteCatalogRefusesWrongIntentBeforeWork`, `TestSnapshotDeleteCatalogCannotInferSuccessFromWorkReturn`, `TestSnapshotDeleteOfflineCLILeavesProgressInFiler` | SnapDelete retained target; SnapOps owner/state refinement; V8 completion adapter and public command activation owed | STUB |
| `INV-SNAP-OP-ADMISSION-CLOSE-001` | Admission checks HEAD after receipt publication and refuses a deleting/deleted or absent volume. Closed incarnations cannot answer retained operation queries; their terminal receipt bytes are not rewritten by closing. | M9 admission and observation | `checkSnapshotOperationAdmission`, `readOperationIndex`, create/delete admission | `TestSnapshotOperationAdmissionRechecksHeadAfterPublication`, `TestSnapshotOperationClosedVolumeRefusesReceipts`, `TestSnapshotOperationTerminalReadmissionRechecksHeadAfterFlag` | SnapVolDel rows 257-260 (per-incarnation) | STUB |
+29 -4
View File
@@ -478,14 +478,28 @@ sw-block ops chunk snapshot-delete --master MASTER --volume v1 --chunk-filer FIL
For a v1.1 HEAD, the name-only `snapshot-delete` command and holder API refuse
with `snapshot_delete_requires_operation` (non-retryable). They cannot distinguish
a retry of a lost delete reply from deleting a same-name replacement. A v1.1
delete requires a retained operation and its captured snapshot identity; public
command admission for that path is not enabled yet. The example above applies
to legacy v1.0 HEADs.
delete requires its own retained operation and captured snapshot identity:
```bash
sw-block ops chunk snapshot-delete --master MASTER --volume v1 --chunk-filer FILER --name s1 --request-id delete-s1-1
```
Keep the printed request ID and repeat it after an interrupted or lost answer.
The original delete outcome is replayed even if the name has been recreated;
the replacement is not removed. `--no-wait` persists admission only; a later CLI
invocation with the same ID and without `--no-wait` executes or resumes it.
The CLI is the offline executor: no daemon continues a no-wait delete. Success
means the logical unlink and durable reclamation intent committed; physical
reclamation continues independently. A legacy snapshot must first be stamped by
a v1.1 holder; `snapshot_generation_unavailable` is retryable and does not delete.
The name-only example above applies to legacy v1.0 HEADs.
`snapshots` answers a JSON array with one entry per published snapshot, in name
order: `[{"name":"s1","root":"<64 hex>"}]`. An entry also lists
`"dependents":["v2-<id8>"]` while restore targets depend on that snapshot. An
entry has no state or cut position: a listed snapshot is published. Each delete
entry has no state or cut position: a listed snapshot is published. An operation-based
delete returns `{"volume_id":"<full layout id>","name":"s1","gen":G}`, where G identifies
the admitted snapshot incarnation. A legacy name-only delete
answers `{"volume":"v1-<id8>","name":"s1","state":"absent"}`. Here `v1-<id8>` is
the volume's store directory: its name and the first 8 hex digits of its layout id.
A delete is one conditional update of HEAD. If another change of HEAD (the
@@ -542,6 +556,17 @@ it then completes. In this release the delete waits for that time
## Snapshot names and retries
For v1.1, create and delete use separate operation IDs. An operation is
idempotent for the volume's most recent 4096 snapshot operations; a stalled
operation is kept until it settles. Repeating a retained create answers its
original outcome even after deletion. A delete targets the exact snapshot
incarnation captured at admission and never changes the create's outcome.
When only pending or stalled operations fill the index, a new admission refuses
retryably rather than retiring one. Keep the printed ID; observation or retry
must not generate a new one.
The following name-reservation rules describe legacy v1.0 HEADs:
A snapshot request first takes its name, then publishes the snapshot. Three rules
follow from that order: