refactor: allow the server to start, even in case of migration failure
This commit is contained in:
parent
b0a1e4b3d7
commit
3eb07ef924
1 changed files with 42 additions and 34 deletions
|
|
@ -40,14 +40,18 @@ export const retagSnapshots = async () => {
|
|||
const allErrors = [...result.errors];
|
||||
|
||||
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) {
|
||||
logger.error(`Migration failure - ${err.name}: ${err.error}`);
|
||||
}
|
||||
throw new MigrationError(MIGRATION_VERSION, allErrors);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await recordMigrationCheckpoint(MIGRATION_VERSION);
|
||||
|
||||
logger.info(`Snapshots retagging migration (${MIGRATION_VERSION}) complete.`);
|
||||
};
|
||||
|
||||
|
|
@ -82,6 +86,7 @@ const migrateSnapshotsToShortIdTag = async (): Promise<MigrationResult> => {
|
|||
const backupSchedules = await db.query.backupSchedulesTable.findMany({});
|
||||
|
||||
for (const schedule of backupSchedules) {
|
||||
try {
|
||||
const oldTag = schedule.id.toString();
|
||||
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}'`);
|
||||
} catch (err) {
|
||||
errors.push({ name: `schedule:${schedule.name}`, error: toMessage(err) });
|
||||
}
|
||||
}
|
||||
|
||||
return { success: errors.length === 0, errors };
|
||||
|
|
|
|||
Loading…
Reference in a new issue