A plan's cut takes the backups before asking its first tier, and a machine it cannot ask holds it (issue 1086)

The cut asked tier 0 itself, so the step before a first tier never ran and gitea was sent to novox with no restore point. A machine with no backup holder is now a failed backup that holds the plan.
This commit is contained in:
2026-10-18 01:54:10 +02:00
parent 47f9290b37
commit 7103e33294
3 changed files with 89 additions and 10 deletions
+20 -1
View File
@@ -1224,7 +1224,9 @@ func planBatch(ctx context.Context, open *stores, batch *inventory.Plan, carry [
return nil
}
// Written and its first tier asked as one act on the plans (novox/hq issue 213), under the caller's hold.
if err := askTier(ctx, inv, &plan, plan.Tiers[plan.Tier]); err != nil {
if err := askFirstTierAtCut(&plan,
func(p *inventory.Plan) (bool, error) { return backupsFirst(ctx, inv, p) },
func() error { return askTier(ctx, inv, &plan, plan.Tiers[plan.Tier]) }); err != nil {
return err
}
if err := inv.SavePlan(ctx, &plan); err != nil {
@@ -1234,6 +1236,23 @@ func planBatch(ctx context.Context, open *stores, batch *inventory.Plan, carry [
return nil
}
// askFirstTierAtCut asks a freshly cut plan's first tier, after the backups of the data it moves (novox/hq ADR 0404,
// issue 1086): the cut asks the tier itself, so advanceOnce, which asks the backups before a first tier, finds it
// asked and never takes them. A plan whose backups wait, failed or could not be worked out asks nothing; it is saved
// unasked and the walk's own step goes on from its record.
func askFirstTierAtCut(p *inventory.Plan, backups func(*inventory.Plan) (bool, error), ask func() error) error {
proceed, err := backups(p)
if err != nil {
p.Note = backupsNote + "not asked, the backups of the plan could not be worked out: " + err.Error() +
"; nothing is asked or sent, and the plan tries again"
return nil
}
if !proceed {
return nil
}
return ask()
}
// placedBy writes on each module of a plan the edges of its order that put it after another module of the plan, with the
// rule that drew each (novox/hq ADR 0419 clause 5).
func placedBy(plan *inventory.Plan, ordered []inventory.Edge) {