refactor: allow the server to start, even in case of migration failure
Some checks failed
Release Workflow / checks (push) Has been cancelled
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled

This commit is contained in:
Nicolas Meienberger 2026-01-03 00:16:42 +01:00
parent b0a1e4b3d7
commit 3eb07ef924

View file

@ -40,14 +40,18 @@ export const retagSnapshots = async () => {
const allErrors = [...result.errors]; const allErrors = [...result.errors];
if (allErrors.length > 0) { if (allErrors.length > 0) {
logger.error(`Migration ${MIGRATION_VERSION} completed with errors: ${allErrors.length} items failed.`);
logger.error(
`Some snapshots could not be retagged. Please check the logs for details. Fix any repository in error state and re-start zerobyte to retry the migration for failed items.`,
);
for (const err of allErrors) { for (const err of allErrors) {
logger.error(`Migration failure - ${err.name}: ${err.error}`); logger.error(`Migration failure - ${err.name}: ${err.error}`);
} }
throw new MigrationError(MIGRATION_VERSION, allErrors);
return;
} }
await recordMigrationCheckpoint(MIGRATION_VERSION); await recordMigrationCheckpoint(MIGRATION_VERSION);
logger.info(`Snapshots retagging migration (${MIGRATION_VERSION}) complete.`); logger.info(`Snapshots retagging migration (${MIGRATION_VERSION}) complete.`);
}; };
@ -82,6 +86,7 @@ const migrateSnapshotsToShortIdTag = async (): Promise<MigrationResult> => {
const backupSchedules = await db.query.backupSchedulesTable.findMany({}); const backupSchedules = await db.query.backupSchedulesTable.findMany({});
for (const schedule of backupSchedules) { for (const schedule of backupSchedules) {
try {
const oldTag = schedule.id.toString(); const oldTag = schedule.id.toString();
const newTag = schedule.shortId; const newTag = schedule.shortId;
@ -122,6 +127,9 @@ const migrateSnapshotsToShortIdTag = async (): Promise<MigrationResult> => {
} }
logger.info(`Migrated snapshots for schedule '${schedule.name}' from tag '${oldTag}' to '${newTag}'`); logger.info(`Migrated snapshots for schedule '${schedule.name}' from tag '${oldTag}' to '${newTag}'`);
} catch (err) {
errors.push({ name: `schedule:${schedule.name}`, error: toMessage(err) });
}
} }
return { success: errors.length === 0, errors }; return { success: errors.length === 0, errors };