Repository navigation
#466 を実装する(スプリント m8c) - #478
Merged
Merged
Conversation
世代の snar を写した仮の snar と仮の名前の差分 (incr.tar.zst.new) へ控え、 tar の 2 以上と zstd の失敗を検査してから、差分 → snar の順に改名で置く。 写し・控え・改名のどこで失敗しても仮のファイルを消して SnapshotError を返す。 差分の作成は snapshot.snar.bak を作らない。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
takemi-ohama
marked this pull request as ready for review
October 12, 2026 17:43
This was referenced Oct 12, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
差分の作成が途中で失敗しても、
snapshot.snarと差分の列を作成を始める前の状態のまま保つようにしました(#466)。あわせて、差分の作成の手順と失敗したときの扱いを確定仕様と CHANGELOG に書きました。利用者向けの変化
snapshot.snarと差分の列は作成を始める前の状態のまま残ります。backup_commandに渡します。除外の仕様にもこのことを書いています。移行の手順
変更の要点
lib/devbase/snapshot/manager.pysnapshot.snarと差分の列を更新するようにしました。snapshot.ymlの形は変えていません。docs/specifications/snapshot-series.mdに、差分の作成の手順と失敗したときの扱いを書きました。docs/specifications/snapshot-exclude.mdに、差分の作成でも仮の snar をbackup_commandに渡すことを書きました。CHANGELOG.mdに今回の変更を追記しました。tests/snapshot/test_incremental_failure.pyを新しく追加しました。test_archive_layout.pyとtest_rebuild_generation.pyを手直ししました。テスト
issues/issue-466-design.mdに名前の出るテスト 3 件が、すべて HEAD にある)設計と違う点
概要
既存の世代へ差分を積む経路(
devbase snapshot create --name <名前>・devbase upの自動スナップショット)で、控えが失敗してもsnapshot.snarが進まず、作りかけのincr-NNN.tar.zstも残らないようにした(#466)。設計はissues/issue-466-design.mdのとおり。_create_incremental: 検査の後に前の中断の仮のファイルを消し、ホストでsnapshot.snarをsnapshot.snar.newへ写してchecked_backup_command(backup_command('incr.tar.zst.new', …, snar='snapshot.snar.new'))を打つ。成功したら差分 → snar の順に改名で置く。写し・控え・改名のどこで失敗しても仮のファイルを消して
SnapshotError(改名と写しのOSErrorは世代 '{名前}' に差分を作れませんでした: {理由}に包む)_install_incremental・_discard_incremental_temps・定数INCR_ARCHIVE_TMP。snapshot.snar.bakは作らなくなった(前からあるものには触らない)docs/specifications/snapshot-series.md(構成要素・### 差分の作成・データ・エラー処理・運用・テスト観点・作り直しの常に成り立つ条件の絞り込み)とCHANGELOG.mdの### Fixed設計と違えたところ
test_create_and_restore_go_through_the_helpersだけは書き換えてよい)」だが、tests/snapshot/test_rebuild_generation.pyのtest_incremental_after_rebuild_starts_from_oneの 1 行も書き換えた。この行は作り直しの後の 差分 の控えのコマンドが
--listed-incremental=/backup/snapshot.snarを渡すことを縛っており、決定 1 で差分がsnapshot.snar.newを渡す形になるため、そのままでは通らない。SNAR_FILE_TMPを見る形へ変えた(作り直しの経路のコマンドは変えていない)。復元前バックアップが同じ秒の既存の世代と重なると、その世代を作り直す(復元元が pre-restore-* なら展開の前に置き換わる) #473 が触る
test_pre_restore_backup_rebuilds_an_existing_generationには触れていないbackup_commandの docstring(「差分はarchiveにincr-NNN.tar.zstを渡す」)は、両方が触らない関数の表に従って直していない確かめたこと
env -u DEVBASE_ROOT uv run --locked pytest tests/ -q: 4324 passed, 31 skipped。uvx ruff check --select=E9,F63,F7,F82 lib: 通過。固有の語の検査は、手元に語の一覧が無く飛んだ
python:3.12-slimのdocker run --rmにdevbase-snapshot:latestの zstd 1.5.7 を持ち込んで、
test_incremental_failure.py・test_backup_real_tar.py・test_rebuild_generation.pyを流した: 54 passed(飛ばしは 0)_create_incrementalだけを今の形(cp … .bak && backup_command(incr-NNN)、失敗で何も戻さない)に戻すと、test_incremental_failure.pyの受け入れ条件 1〜6 を縛るテスト 19 件が落ちる(通るのは tar 1 の成功・仮の名前の判定・復元の列・.bakの 5 件)devbase-snapshot:latest): 実装のSnapshotManagerをそのまま使い、volume_mount_argsだけを差し替えて作業用のディレクトリを
/source/ai:ro・/source/group:roに付けた(利用者のボリュームとdevbase upは使っていない)。失敗は控えのコマンドの前にulimit -f 100;(R1)・touch /backup/incr.tar.zst.new;(R3)を足すか、無いメンバーを足して(R5)起こしたincr-001(ai/b)full.tar.zst incr-001.tar.zst meta.yml snapshot.snar、snar 119 バイト・sha の先頭3761d1060df4ai/cを足し R1(zstd が書く途中に止まる)SnapshotError(File size limit exceeded)。一覧と各ファイルのバイト列が打つ前と同じ(snar は3761d1060df4のまま、作りかけの差分なし)ai/eを足し R3(zstd がすぐ失敗)SnapshotError(zstd: /backup/incr.tar.zst.new already exists)。世代は打つ前とバイト列が同じSnapshotError。世代は打つ前とバイト列が同じincr-002.tar.zstができ、中身はai/ group/ ai/c ai/e(失敗の前のcと後のeの両方)。snar は 125 バイトへ進んだincr-001→incr-002の展開diff -rで元のツリーと同じai/kだけを足し R3(tar が仮の snar を進め終えてから zstd が失敗する形)SnapshotError。世代は打つ前とバイト列が同じai/mを足して次の差分incr-003.tar.zstの中身はai/ group/ ai/k ai/m残した事項
incr.tar.zst.new・snapshot.snar.newをホストの利用者が改名・削除できること、root が書いたsnapshot.snarをホストで写せることは確かめていない(macOS の Docker Desktop だけ。作り直しの経路と同じ)利用者のボリュームでは確かめていない(触らない決まりのため)
モード: standard / 通した工程: 実装 → 完了判定 → Pull Request
🤖 Generated with Claude Code