@@ -14,6 +14,7 @@ var _ = Describe("backup failure", Label("backup-failure"), func() {
1414 backupName := util .GetUniqueName ("mb-" )
1515
1616 SetupEnvironment (namespace )
17+ DeferCleanup (func () { TearDownEnvironment (namespace ) })
1718
1819 // Pause the object storage to make backups fail.
1920 PauseObjectStorage (ctx )
@@ -55,6 +56,7 @@ var _ = Describe("backup failure", Label("backup-failure"), func() {
5556 restoreName := util .GetUniqueName ("mr-" )
5657
5758 SetupEnvironment (namespace )
59+ DeferCleanup (func () { TearDownEnvironment (namespace ) })
5860
5961 // Pause the object storage to make backups fail.
6062 PauseObjectStorage (ctx )
@@ -106,6 +108,7 @@ var _ = Describe("backup failure", Label("backup-failure"), func() {
106108 restoreName0 := util .GetUniqueName ("mr-" )
107109
108110 SetupEnvironment (namespace )
111+ DeferCleanup (func () { TearDownEnvironment (namespace ) })
109112
110113 // Create MantleBackup M0.
111114 CreatePVC (ctx , PrimaryK8sCluster , namespace , pvcName )
@@ -150,6 +153,11 @@ var _ = Describe("backup failure", Label("backup-failure"), func() {
150153
151154 It ("should handle removal of MantleBackup in secondary k8s cluster during an incremental backup" ,
152155 func (ctx SpecContext ) {
156+ // このテストが検証するシナリオ:
157+ // 「インクリメンタルバックアップの upload が進行中(S3 に届く前)に、
158+ // 管理者が secondary の MantleBackup を手動削除しても、
159+ // S3 が回復すれば最終的に正しい状態に戻れるか?」
160+
153161 namespace := util .GetUniqueName ("ns-" )
154162 pvcName := util .GetUniqueName ("pvc-" )
155163 backupName0 := util .GetUniqueName ("mb-" )
@@ -158,50 +166,69 @@ var _ = Describe("backup failure", Label("backup-failure"), func() {
158166 restoreName1 := util .GetUniqueName ("mr-" )
159167
160168 SetupEnvironment (namespace )
169+ DeferCleanup (func () { TearDownEnvironment (namespace ) })
161170
162- // Create MantleBackup M0.
171+ // [Step 1] フルバックアップ M0 を作成し、primary/secondary 両方への同期が
172+ // 完了するまで待つ。この時点で M0, M0' が SyncedToRemote 状態になっている。
163173 CreatePVC (ctx , PrimaryK8sCluster , namespace , pvcName )
164174 writtenDataHash0 := WriteRandomDataToPV (ctx , PrimaryK8sCluster , namespace , pvcName )
165175 CreateMantleBackup (PrimaryK8sCluster , namespace , pvcName , backupName0 )
166176 WaitMantleBackupSynced (namespace , backupName0 )
167177
168- // Pause the object storage to make backups fail.
178+ // [Step 2] RGW(オブジェクトストレージ)を停止する。
179+ // これにより、以降の upload Job が S3 に届かず詰まるようになる。
180+ // defer で最終的に必ず再開されるが、テスト途中は停止したまま。
169181 PauseObjectStorage (ctx )
170182 defer ResumeObjectStorage (ctx )
171183
172- // Create MantleBackup M1.
184+ // [Step 3] インクリメンタルバックアップ M1 を作成する。
185+ // primary 側では RBD スナップショット取得・エクスポートが行われるが、
186+ // upload は RGW 停止中のため S3 に届かず止まる。
173187 CreatePVC (ctx , PrimaryK8sCluster , namespace , pvcName )
174188 writtenDataHash1 := WriteRandomDataToPV (ctx , PrimaryK8sCluster , namespace , pvcName )
175189 CreateMantleBackup (PrimaryK8sCluster , namespace , pvcName , backupName1 )
176190
177- // Wait until an upload Job is created.
191+ // [Step 4] upload Job が作られるまで待つ。
192+ // この時点の状態:
193+ // primary: RBD スナップショット取得済み・エクスポート済み・upload Job 実行中(詰まってる)
194+ // S3: データはまだ届いていない
195+ // secondary: M1' の K8s オブジェクトは存在するが、import データが S3 にないため待機中
178196 WaitUploadJobCreated (ctx , PrimaryK8sCluster , namespace , backupName1 , 0 )
179197
180198 primaryMB1 , err := GetMB (PrimaryK8sCluster , namespace , backupName1 )
181199 Expect (err ).NotTo (HaveOccurred ())
182200 secondaryMB10 , err := GetMB (SecondaryK8sCluster , namespace , backupName1 )
183201 Expect (err ).NotTo (HaveOccurred ())
184202
185- // Delete MantleBackup M1'.
203+ // [Step 5] secondary の M1' を手動削除する(管理者操作のシミュレーション)。
204+ // --timeout=3m で削除完了(finalizer 除去)まで待機する。
205+ // ※ システムが自動削除するわけではなく、テストが意図的に行う操作。
186206 DeleteMantleBackup (SecondaryK8sCluster , namespace , backupName1 )
187207
188- // Resume the object storage so that M1' will be deleted correctly after its finalization.
208+ // [Step 6] RGW を再開する。
209+ // M1' の finalization(finalizeSecondary)は deleteExportData=false で呼ばれるため
210+ // S3 アクセスは不要だが、その後 primary が M1' を再作成して upload を再試行するため
211+ // RGW が必要になる。
189212 ResumeObjectStorage (ctx )
190213
191- // M1' should be re-created and synced.
214+ // [Step 7] M1' が再作成・同期されることを確認する。
215+ // primary の reconcile ループが CreateMantleBackup RPC を毎回呼ぶため、
216+ // M1' が削除されていても自動的に再作成される(冪等な動作)。
217+ // RGW が戻ったことで upload が完了し、secondary が import して SyncedToRemote になる。
192218 WaitMantleBackupSynced (namespace , backupName1 )
193219
194- // Make sure the PVC in the primary and secondary cluster DOES have a snapshot.
220+ // [Step 8] primary/ secondary 両方の PVC に M1 相当のスナップショットが存在することを確認。
195221 EnsurePVCHasSnapshot (PrimaryK8sCluster , namespace , pvcName , backupName1 )
196222 EnsurePVCHasSnapshot (SecondaryK8sCluster , namespace , pvcName , backupName1 )
197223
198- // Make sure we can restore correct data from M0, M0', M1, and M1'.
224+ // [Step 9] M0/ M0'/M1/ M1' の全てから正しいデータを復元できることを確認。
199225 EnsureCorrectRestoration (PrimaryK8sCluster , ctx , namespace , backupName0 , restoreName0 , writtenDataHash0 )
200226 EnsureCorrectRestoration (SecondaryK8sCluster , ctx , namespace , backupName0 , restoreName0 , writtenDataHash0 )
201227 EnsureCorrectRestoration (PrimaryK8sCluster , ctx , namespace , backupName1 , restoreName1 , writtenDataHash1 )
202228 EnsureCorrectRestoration (SecondaryK8sCluster , ctx , namespace , backupName1 , restoreName1 , writtenDataHash1 )
203229
204- // Make sure all unnecessary resources are removed.
230+ // [Step 10] 一時リソース(import Job, export/import 用 PVC 等)が正しく削除されることを確認。
231+ // secondaryMB10: 削除された旧 M1'、secondaryMB11: 再作成された新 M1'
205232 secondaryMB11 , err := GetMB (SecondaryK8sCluster , namespace , backupName1 )
206233 Expect (err ).NotTo (HaveOccurred ())
207234 WaitTemporaryResourcesDeleted (ctx , primaryMB1 , secondaryMB10 )
0 commit comments