mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Switch health check to use projects instead of blobs
Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com> GitOrigin-RevId: c318b70397ed5e2fcbb07fa019412b56844260ef
This commit is contained in:
committed by
Copybot
co-authored by
Jakob Ackermann
parent
3bc21faeaf
commit
c373db4f86
@@ -221,25 +221,23 @@ export async function verifyProject(historyId, endTimestamp) {
|
|||||||
export class BackupCorruptedError extends OError {}
|
export class BackupCorruptedError extends OError {}
|
||||||
export class BackupRPOViolationError extends OError {}
|
export class BackupRPOViolationError extends OError {}
|
||||||
|
|
||||||
|
const HEALTH_CHECK_PROJECTS = JSON.parse(config.get('healthCheckProjects'))
|
||||||
export async function healthCheck() {
|
export async function healthCheck() {
|
||||||
/** @type {Array<string>} */
|
if (!Array.isArray(HEALTH_CHECK_PROJECTS)) {
|
||||||
const HEALTH_CHECK_BLOBS = JSON.parse(config.get('healthCheckBlobs'))
|
throw new Error('expected healthCheckProjects to be an array')
|
||||||
if (HEALTH_CHECK_BLOBS.length !== 2) {
|
|
||||||
throw new Error('expected 2 healthCheckBlobs')
|
|
||||||
}
|
}
|
||||||
if (!HEALTH_CHECK_BLOBS.some(path => path.split('/')[0].length === 24)) {
|
if (HEALTH_CHECK_PROJECTS.length !== 2) {
|
||||||
throw new Error('expected mongo id in healthCheckBlobs')
|
throw new Error('expected 2 healthCheckProjects')
|
||||||
}
|
}
|
||||||
if (!HEALTH_CHECK_BLOBS.some(path => path.split('/')[0].length < 24)) {
|
if (!HEALTH_CHECK_PROJECTS.some(id => id.length === 24)) {
|
||||||
throw new Error('expected postgres id in healthCheckBlobs')
|
throw new Error('expected mongo id in healthCheckProjects')
|
||||||
}
|
}
|
||||||
if (HEALTH_CHECK_BLOBS.some(path => path.split('/')[1]?.length !== 40)) {
|
if (!HEALTH_CHECK_PROJECTS.some(id => id.length < 24)) {
|
||||||
throw new Error('expected hash in healthCheckBlobs')
|
throw new Error('expected postgres id in healthCheckProjects')
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const path of HEALTH_CHECK_BLOBS) {
|
for (const historyId of HEALTH_CHECK_PROJECTS) {
|
||||||
const [historyId, hash] = path.split('/')
|
await verifyProjectWithErrorContext(historyId)
|
||||||
await verifyBlob(historyId, hash)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class BackupCorruptedMissingBlobError extends BackupCorruptedError {}
|
export class BackupCorruptedMissingBlobError extends BackupCorruptedError {}
|
||||||
|
|||||||
Reference in New Issue
Block a user