v0.253.0 — errors carry the key of the sentence they are (R-557 slice 2 release B)
gates / gates (push) Successful in 24s
gates / gates (push) Successful in 24s
179 Hungarian sentences were built deep inside a package with fmt.Errorf and printed by whoever caught them: too late to translate where they are shown, too early where they are made. Every one now carries its key across that gap. ZERO Hungarian error literals remain. util.MsgError does three things at once, each earned: - Error() is the Hungarian, byte for byte, so every un-converted printer is unchanged; - errors.Is answers for the kind AND for a wrapped cause (KindErrorf dropped the cause); - an error ARGUMENT renders recursively, so "formázás sikertelen: %w" translates whole. A foreign error — restic, docker, ssh, the stdlib — prints verbatim. It is not ours. 76 display sites go through errText, and TestNoErrErrorInPageOutput convicts any that do not. memoryVerdict returns an error rather than a sentence, so the deploy's 409 and the household's language come from one value; UpdateRefusal gained a Cause to carry it. Plurals, one rule, stated once: a key with .one/.other takes its COUNT first. Not a per-call-site flag — the producer somebody forgot would read "3 app is not running". The guard caught a real key collision (alert.deadapp.one) the day the rule landed. TWO DEFECTS FOUND IN MY OWN TOOLING, recorded rather than quietly fixed. The bulk converter silently dropped multi-line concatenations, damaging 7 producers — and the parity gate could not see it, because every surviving fragment WAS a real base literal while the CALL had lost text; two behaviour tests caught it. And the counting script was case-sensitive, so it said "0 left" while five remained. MinAgent: 0.131.0 (unchanged). No hub release needed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -3,6 +3,7 @@ package backup
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/util"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -213,7 +214,7 @@ func (m *Manager) writeSafetyDump(ctx context.Context, stackName, nsRoot string)
|
||||
}
|
||||
dbs, err := discover(ctx)
|
||||
if err != nil {
|
||||
return safetyDumpSet{}, fmt.Errorf("a biztonsági mentés előtt nem sikerült felderíteni az adatbázisokat: %w", err)
|
||||
return safetyDumpSet{}, util.MsgError("err.backup.a_biztonsagi_mentes_elott_nem_sikerult", err)
|
||||
}
|
||||
var mine []DiscoveredDB
|
||||
for _, db := range dbs {
|
||||
@@ -227,7 +228,7 @@ func (m *Manager) writeSafetyDump(ctx context.Context, stackName, nsRoot string)
|
||||
|
||||
dumpDir := AppDBDumpPath(nsRoot, stackName)
|
||||
if err := os.MkdirAll(dumpDir, 0755); err != nil {
|
||||
return safetyDumpSet{}, fmt.Errorf("a biztonsági mentés könyvtára nem hozható létre: %w", err)
|
||||
return safetyDumpSet{}, util.MsgError("err.backup.a_biztonsagi_mentes_konyvtara_nem_hozhato", err)
|
||||
}
|
||||
set := safetyDumpSet{Stamp: time.Now().UTC().Format("20060102T150405Z")}
|
||||
for _, db := range mine {
|
||||
@@ -248,7 +249,7 @@ func (m *Manager) writeSafetyDump(ctx context.Context, stackName, nsRoot string)
|
||||
safe := filepath.Join(dumpDir, fmt.Sprintf("%s%s-%s-%s.sql", preRestoreDumpPrefix, set.Stamp, stackName, db.DBType))
|
||||
res := m.dumpForSafety(ctx, db, safe)
|
||||
if res.Error != nil {
|
||||
return safetyDumpSet{}, fmt.Errorf("a jelenlegi adatbázis biztonsági mentése sikertelen (%s): %w — a visszaállítás nem indult el", db.ContainerName, res.Error)
|
||||
return safetyDumpSet{}, util.MsgError("err.backup.a_jelenlegi_adatbazis_biztonsagi_mentese_sikertelen", db.ContainerName, res.Error)
|
||||
}
|
||||
// EVERY file, not just the first — R-379, and the reason is on safetyDumpSet.
|
||||
set.Files = append(set.Files, safetyDumpFile{DB: db, Path: safe})
|
||||
@@ -440,7 +441,7 @@ func (m *Manager) rollbackSafetyDump(ctx context.Context, stack string, set safe
|
||||
}
|
||||
live, dErr := discover(ctx)
|
||||
if dErr != nil {
|
||||
return fmt.Errorf("a visszavonás előtt nem sikerült felderíteni az adatbázisokat: %w", dErr)
|
||||
return util.MsgError("err.backup.a_visszavonas_elott_nem_sikerult_felderiteni", dErr)
|
||||
}
|
||||
liveFor := func(want DiscoveredDB) (DiscoveredDB, bool) {
|
||||
for _, db := range live {
|
||||
@@ -453,13 +454,13 @@ func (m *Manager) rollbackSafetyDump(ctx context.Context, stack string, set safe
|
||||
|
||||
for _, f := range set.Files {
|
||||
if _, sErr := os.Stat(f.Path); sErr != nil {
|
||||
return fmt.Errorf("a visszavonáshoz szükséges mentés nem található (%s): %w", filepath.Base(f.Path), sErr)
|
||||
return util.MsgError("err.backup.a_visszavonashoz_szukseges_mentes_nem_talalhato", filepath.Base(f.Path), sErr)
|
||||
}
|
||||
target, ok := liveFor(f.DB)
|
||||
if !ok {
|
||||
// Fail closed: pouring an undo into a container we cannot identify is worse than saying
|
||||
// we could not do it.
|
||||
return fmt.Errorf("a(z) %s adatbázis-tárolója nem található a visszavonáshoz", f.DB.ContainerName)
|
||||
return util.MsgError("err.backup.a_z_adatbazis_taroloja_nem_talalhato", f.DB.ContainerName)
|
||||
}
|
||||
if target.ContainerID != f.DB.ContainerID {
|
||||
m.logger.Printf("[DEBUG] [offbox] %s: %s was re-created during the restore (%s → %s) — rolling back into the live container",
|
||||
@@ -467,7 +468,7 @@ func (m *Manager) rollbackSafetyDump(ctx context.Context, stack string, set safe
|
||||
}
|
||||
m.logger.Printf("[INFO] [offbox] %s: rolling back to the pre-restore state from %s", stack, filepath.Base(f.Path))
|
||||
if err := imp(ctx, target, f.Path); err != nil {
|
||||
return fmt.Errorf("a korábbi állapot visszaállítása sikertelen (%s): %w", target.ContainerName, err)
|
||||
return util.MsgError("err.backup.a_korabbi_allapot_visszaallitasa_sikertelen", target.ContainerName, err)
|
||||
}
|
||||
}
|
||||
m.logger.Printf("[INFO] [offbox] %s: rollback complete — %d database(s) returned to the pre-restore state", stack, len(set.Files))
|
||||
@@ -505,7 +506,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
return res, fmt.Errorf("stack provider not configured")
|
||||
}
|
||||
if err := m.acquireRunning(); err != nil {
|
||||
return res, fmt.Errorf("egy másik mentési/visszaállítási művelet már fut")
|
||||
return res, util.MsgError("err.backup.egy_masik_mentesi_visszaallitasi_muvelet_mar")
|
||||
}
|
||||
defer m.releaseRunning()
|
||||
|
||||
@@ -514,7 +515,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
return res, err
|
||||
}
|
||||
if _, sErr := os.Stat(scratch); sErr != nil {
|
||||
return res, fmt.Errorf("nincs előkészített teljes visszaállítás — futtass előbb egy teljes visszaállítást")
|
||||
return res, util.MsgError("err.backup.nincs_elokeszitett_teljes_visszaallitas_futtass_elobb")
|
||||
}
|
||||
id, paths, err := m.offboxLatestSnapshot(ctx, stack)
|
||||
if err != nil {
|
||||
@@ -541,12 +542,9 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
// above is untouched for the 13 apps that DO have a drive to get wrong.
|
||||
if !m.isStackDeployed(stack) {
|
||||
if rec := m.recordedPlacementFromScratch(scratch); rec.Known() {
|
||||
return res, fmt.Errorf("a(z) %s nincs telepítve, ezért nincs hová visszaállítani az adatait. "+
|
||||
"A mentése szerint az adatai itt voltak: %s. Telepítsd újra az alkalmazást (Alkalmazások) "+
|
||||
"ugyanerre a helyre, utána ez a visszaállítás működni fog", stack, rec.Drive)
|
||||
return res, util.MsgError("err.backup.not_installed_known_drive", stack, rec.Drive)
|
||||
}
|
||||
return res, fmt.Errorf("a(z) %s nincs telepítve, ezért nincs hová visszaállítani az adatait — "+
|
||||
"telepítsd újra az alkalmazást (Alkalmazások), utána ez a visszaállítás működni fog", stack)
|
||||
return res, util.MsgError("err.backup.not_installed", stack)
|
||||
}
|
||||
// The destination is resolved by the SAME rule the capture side used to write this snapshot
|
||||
// (CaptureRecoveryUnit → GetAppDrivePath): the app's drive if it has one, the system data path
|
||||
@@ -558,8 +556,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
// installed, but the box cannot name its own data root (systemDataPath unset). Saying
|
||||
// "nincs telepítve" here would send the customer to reinstall an app that is already
|
||||
// running, and the real fault would stay invisible.
|
||||
return res, fmt.Errorf("a(z) %s telepítve van, de a vezérlő nem tudja megállapítani, hová tartoznak az adatai "+
|
||||
"(nincs beállítva rendszer-adatterület). Ellenőrizd a tárhely beállításait (Tárhely), utána indítsd újra a visszaállítást", stack)
|
||||
return res, util.MsgError("err.backup.no_data_root", stack)
|
||||
}
|
||||
liveNs := m.namespaceRoot(hdd)
|
||||
|
||||
@@ -609,7 +606,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
// unit-only restore was run) refuses with ZERO copies.
|
||||
for _, pl := range placements {
|
||||
if _, sErr := os.Stat(pl.src); sErr != nil {
|
||||
return res, fmt.Errorf("a teljes visszaállítás hiányos (%s nincs meg) — futtass előbb egy teljes visszaállítást", filepath.Base(pl.src))
|
||||
return res, util.MsgError("err.backup.a_teljes_visszaallitas_hianyos_nincs_meg", filepath.Base(pl.src))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,7 +619,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
}
|
||||
}
|
||||
if scratchUnit == "" {
|
||||
return res, fmt.Errorf("a pillanatképben nincs mentési egység — a visszaállítás nem indítható")
|
||||
return res, util.MsgError("err.backup.a_pillanatkepben_nincs_mentesi_egyseg_a")
|
||||
}
|
||||
scratchDumpDir := filepath.Join(scratchUnit, "db-dumps")
|
||||
man := readManifest(filepath.Join(scratchUnit, "manifest.json"))
|
||||
@@ -684,13 +681,13 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
if hasDB {
|
||||
if _, sErr := os.Stat(safety); sErr != nil {
|
||||
// Fail-closed: never replay when the undo is not verifiably on disk.
|
||||
return res, fmt.Errorf("a biztonsági mentés nem található a lemezen — a visszaállítás biztonsági okból nem indult el")
|
||||
return res, util.MsgError("err.backup.a_biztonsagi_mentes_nem_talalhato_a")
|
||||
}
|
||||
// Fail-closed (R-47): the app HAS a database but no compose service can be identified to
|
||||
// start alone for the replay. The only alternative would be to start everything and replay
|
||||
// into the race that produced H4 — refusing with the live app untouched is the better outcome.
|
||||
if len(dbServices) == 0 {
|
||||
return res, fmt.Errorf("Az adatbázis-szolgáltatás nem azonosítható a(z) %s alkalmazásban — a visszaállítás biztonsági okból nem indult el.", stack)
|
||||
return res, util.MsgError("err.backup.az_adatbazis_szolgaltatas_nem_azonosithato_a", stack)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,7 +696,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
// it used to leave the app down with nothing on disk recording that it was owed a restart — and a
|
||||
// full offsite restore is a LONG window, so this is the shape most likely to be interrupted.
|
||||
if err := m.appStop.Begin("offbox-reconstitute:"+stack, ReasonOffboxReconstitute, []string{stack}); err != nil {
|
||||
return res, fmt.Errorf("a(z) %s leállítása előtti jelölő nem menthető: %w", stack, err)
|
||||
return res, util.MsgError("err.backup.a_z_leallitasa_elotti_jelolo_nem", stack, err)
|
||||
}
|
||||
// restartStack starts the app and clears the marker ONLY when the start actually succeeded — a
|
||||
// failed start leaves the marker so the next startup retries. Every bring-up below goes through
|
||||
@@ -744,7 +741,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
if sErr := restartStack(); sErr != nil {
|
||||
m.logger.Printf("[WARN] [offbox] %s: restart after failed placement also failed: %v", stack, sErr)
|
||||
}
|
||||
return res, fmt.Errorf("a(z) %s fájljainak visszaállítása sikertelen: %w", stack, cErr)
|
||||
return res, util.MsgError("err.backup.a_z_fajljainak_visszaallitasa_sikertelen", stack, cErr)
|
||||
}
|
||||
res.FilesPlaced += n
|
||||
}
|
||||
@@ -770,7 +767,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
if sErr := restartStack(); sErr != nil {
|
||||
m.logger.Printf("[WARN] [offbox] %s: restart after failed volume replay also failed: %v", stack, sErr)
|
||||
}
|
||||
return res, fmt.Errorf("a(z) %s adatkötetének visszaállítása sikertelen: %w", stack, vErr)
|
||||
return res, util.MsgError("err.backup.a_z_adatkotetenek_visszaallitasa_sikertelen", stack, vErr)
|
||||
}
|
||||
|
||||
// --- DATABASE -------------------------------------------------------------------------------
|
||||
@@ -785,7 +782,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
if sErr := restartStack(); sErr != nil {
|
||||
m.logger.Printf("[WARN] [offbox] %s: full start after failed DB-only start also failed: %v", stack, sErr)
|
||||
}
|
||||
return res, fmt.Errorf("a(z) %s adatbázis-szolgáltatásának indítása sikertelen: %w", stack, err)
|
||||
return res, util.MsgError("err.backup.a_z_adatbazis_szolgaltatasanak_inditasa_sikertelen", stack, err)
|
||||
}
|
||||
n, iErr := m.reimportDBDumpsFrom(ctx, stack, scratchDumpDir)
|
||||
res.DBsReplayed = n
|
||||
@@ -813,9 +810,7 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
// R-383: the undo copy is DESCRIBED FROM DISK, never from the path alone. See
|
||||
// undoCopyPhrase — this sentence used to assert the file existed in exactly the
|
||||
// branch where a missing file is one of the two causes.
|
||||
return res, fmt.Errorf("a(z) %s adatbázisának visszaállítása sikertelen, és a korábbi állapot visszatöltése sem sikerült. "+
|
||||
"Az alkalmazást biztonsági okból LEÁLLÍTVA hagytuk, hogy az adatai ne sérüljenek tovább. "+
|
||||
"Vedd fel velünk a kapcsolatot — %s", stack, undoCopyPhrase(safetySet))
|
||||
return res, util.MsgError("err.backup.db_restore_and_rollback_failed", stack, undoCopyPhrase(safetySet))
|
||||
}
|
||||
res.RolledBack = true
|
||||
if sErr := restartStack(); sErr != nil {
|
||||
@@ -824,12 +819,11 @@ func (m *Manager) ReconstituteFromOffsite(ctx context.Context, stack string, ack
|
||||
// Says BOTH things. A message that reported only the failure would leave the customer
|
||||
// believing their data was gone when it is back — the omission of a GAIN is as
|
||||
// misleading as the omission of a loss.
|
||||
return res, fmt.Errorf("a(z) %s adatbázisának visszaállítása sikertelen — az adataid visszakerültek a visszaállítás előtti állapotba, "+
|
||||
"az alkalmazás fut tovább. Ha újra megpróbálnád, előbb vedd fel velünk a kapcsolatot", stack)
|
||||
return res, util.MsgError("err.backup.db_restore_failed_rolled_back", stack)
|
||||
}
|
||||
}
|
||||
if err := restartStack(); err != nil {
|
||||
return res, fmt.Errorf("a(z) %s újraindítása sikertelen a fájlok visszaállítása után: %w", stack, err)
|
||||
return res, util.MsgError("err.backup.a_z_ujrainditasa_sikertelen_a_fajlok", stack, err)
|
||||
}
|
||||
// R-475: an update hold may now name the OFF-SITE copy, and this is the route back it names. The
|
||||
// unit restore clears it in RestoreFromRecoveryUnitAt; this path never went through that function,
|
||||
|
||||
Reference in New Issue
Block a user