mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
Merge pull request #532 from seaweedfs/docs/template-source-retirement
docs: qualify template source retirement with a dedicated holder
This commit is contained in:
commit
c8bcbc7c21
2 files changed
+99
No files matched your search
@@ -0,0 +1,61 @@
|
||||
//go:build subprocess && chunkstore_integration
|
||||
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestProcedureRetireTemplateSource runs the template-holder procedure:
|
||||
// fork the seed, publish the template on the holder, fork a consumer, then
|
||||
// seal/revoke/ACK and delete the original source. No GC grace is advanced;
|
||||
// the final ordinary pass proves its command and reads, not reclamation.
|
||||
func TestProcedureRetireTemplateSource(t *testing.T) {
|
||||
env := startHandoffEnvWith(t, 1, []string{"template-holder", "consumer"})
|
||||
env.volExtra = []string{"--chunk-capture-interval", "0", "--chunk-snapshot-schedule", "off"}
|
||||
source := env.start(t, "blockvolume-source", "s1")
|
||||
e := env.adopt(t, source, "s1")
|
||||
const template = "template-holder"
|
||||
want := map[uint64][]byte{5: pattern("template-seed!!!")}
|
||||
env.writeBlock(t, "s1", 5, want[5])
|
||||
env.snapshot(t, "s1", "v1", "seed")
|
||||
for _, step := range []struct{ source, snapshot, target string }{
|
||||
{"v1", "seed", template}, {template, "template-v1", "consumer"},
|
||||
} {
|
||||
env.h.command(t, "ops", "chunk", "fork", "--source", step.source, "--snapshot", step.snapshot,
|
||||
"--target", step.target, "--chunk-filer", env.cluster.filerGRPC, "--chunk-path", env.chunkPath,
|
||||
"--request-id", "fork-"+step.target)
|
||||
env.startTarget(t, step.target, "blockvolume-"+step.target)
|
||||
env.requireBlocks(t, "n-"+step.target, 0, 16, want)
|
||||
env.requireEdges(t, "n-"+step.target)
|
||||
if step.target == template {
|
||||
env.snapshot(t, "n-"+template, template, "template-v1")
|
||||
}
|
||||
}
|
||||
g := env.seal(t, "s1", e)
|
||||
env.revoke(t, e, g)
|
||||
// The process must ACK and exit naturally; a signal would skip the ACK.
|
||||
if err := source.wait(30 * time.Second); err != nil {
|
||||
t.Fatalf("source did not exit naturally after revocation: %v", err)
|
||||
}
|
||||
env.waitAck(t, e, g)
|
||||
env.deleteSnapshot(t, "v1", "seed")
|
||||
out, stderr, code := env.volumeDelete(t, "delete-template-source")
|
||||
requireDeleteCompleted(t, out, stderr, code, false)
|
||||
env.requireDeletedForGood(t, "delete-template-source")
|
||||
check := func() {
|
||||
for _, vol := range []string{template, "consumer"} {
|
||||
env.h.command(t, "ops", "chunk", "verify", "--volume", vol, "--all-snapshots", "--depth", "data", "--timeout", "2m",
|
||||
"--chunk-filer", env.cluster.filerGRPC, "--chunk-path", env.chunkPath)
|
||||
env.requireBlocks(t, "n-"+vol, 0, 16, want)
|
||||
env.requireEdges(t, "n-"+vol)
|
||||
}
|
||||
env.requireSnapshotNames(t, template, "template-v1")
|
||||
}
|
||||
check()
|
||||
env.h.command(t, "ops", "chunk", "gc", "--chunk-filer", env.cluster.filerGRPC, "--chunk-path", env.chunkPath,
|
||||
"--master", env.h.masterAddr, "--apply")
|
||||
check()
|
||||
t.Logf("template source retired; %s/template-v1 and consumer read unchanged after a default-grace GC pass", template)
|
||||
}
|
||||
@@ -574,6 +574,44 @@ sw-block ops chunk fork --source v1 --snapshot before-upgrade --target v2 --chun
|
||||
|
||||
Keep the request id to retry an uncertain result. The new HEAD contains a complete image map; reads do not walk back through parent volumes or snapshots. A fork of a fork preserves the original object owners without adding a backing chain. Deleting the source snapshot does not delete objects still referenced by the fork. Use restore when the target must eventually own its data independently.
|
||||
|
||||
### Retiring the source of a template
|
||||
|
||||
A template is an ordinary immutable snapshot, not a separate volume kind. Keep the volume holding an offered template snapshot: volume deletion refuses while any snapshot name exists. To retire the original source instead, first move the template image into a dedicated holder using existing fork and snapshot operations.
|
||||
|
||||
Prerequisites: `v1` is serving, its only snapshot is `seed`, and the standalone cluster spec has new volume placements for `template-holder` and `consumer`. Neither target blockvolume has started yet. Use the same filer and chunk namespace throughout.
|
||||
|
||||
1. Create the holder:
|
||||
|
||||
```bash
|
||||
sw-block ops chunk fork --source v1 --snapshot seed --target template-holder --chunk-filer FILER --request-id fork-template-holder
|
||||
```
|
||||
|
||||
2. Start `template-holder` with the normal standalone blockvolume command and its own volume id, endpoints and local root. Wait for its frontend readiness; read back the seed's known data before proceeding. Take the template snapshot:
|
||||
|
||||
```bash
|
||||
sw-block ops chunk snapshot --volume template-holder --status-addr HOLDER_STATUS --name template-v1
|
||||
```
|
||||
|
||||
3. Create a consumer, start its blockvolume on its own placement and root, and verify its known data:
|
||||
|
||||
```bash
|
||||
sw-block ops chunk fork --source template-holder --snapshot template-v1 --target consumer --chunk-filer FILER --request-id fork-consumer
|
||||
```
|
||||
|
||||
4. Stop the source writer. Follow [Delete a volume](volume-lifecycle.md#delete-a-volume) for `v1`: plain detach, revoke its exact replica/epoch/sealed generation, wait for its recorded ACK and natural exit, delete `seed`, then delete `v1`. Do not signal the process in place of waiting for its ACK. Require the completed delete answer and `show` state `deleted` before continuing.
|
||||
|
||||
5. Verify both surviving images, including the holder's template snapshot:
|
||||
|
||||
```bash
|
||||
sw-block ops chunk verify --volume template-holder --all-snapshots --depth data --timeout 2m --chunk-filer FILER
|
||||
sw-block ops chunk verify --volume consumer --all-snapshots --depth data --timeout 2m --chunk-filer FILER
|
||||
sw-block ops chunk gc --chunk-filer FILER --master MASTER --apply
|
||||
```
|
||||
|
||||
Read back the known data again and repeat both verify commands after the pass. This immediate pass is not a reclamation measurement: its default grace has not elapsed. Continue namespace-wide GC as described above for unused objects; attached-volume maintenance alone does not collect a deleted source's namespace.
|
||||
|
||||
Keep `template-holder/template-v1` while it is offered for new consumers. Retiring that snapshot later does not delete objects still referenced by existing consumers. Deleting the holder volume itself still requires the ordinary seal/revoke/ACK and snapshot-deletion procedure; do not remove its backing filer directory or object bindings by hand.
|
||||
|
||||
### Restoring a snapshot into a new volume
|
||||
|
||||
A restore makes a new, independent volume from a snapshot. The source volume and its snapshot can be deleted afterwards.
|
||||
|
||||
Reference in new issue
Block a user