Revert "Switch health check to use projects instead of blobs"

This reverts commit c318b70397ed5e2fcbb07fa019412b56844260ef.

GitOrigin-RevId: 087ae9d21be83bf3dae47c4e6d27eb4e74f387df
This commit is contained in:
Andrew Rumble
2025-03-11 15:31:05 +00:00
committed by Copybot
parent 087a9daf34
commit 19eefebe95

View File

@@ -221,23 +221,25 @@ export async function verifyProject(historyId, endTimestamp) {
export class BackupCorruptedError extends OError {}
export class BackupRPOViolationError extends OError {}
const HEALTH_CHECK_PROJECTS = JSON.parse(config.get('healthCheckProjects'))
export async function healthCheck() {
if (!Array.isArray(HEALTH_CHECK_PROJECTS)) {
throw new Error('expected healthCheckProjects to be an array')
/** @type {Array<string>} */
const HEALTH_CHECK_BLOBS = JSON.parse(config.get('healthCheckBlobs'))
if (HEALTH_CHECK_BLOBS.length !== 2) {
throw new Error('expected 2 healthCheckBlobs')
}
if (HEALTH_CHECK_PROJECTS.length !== 2) {
throw new Error('expected 2 healthCheckProjects')
if (!HEALTH_CHECK_BLOBS.some(path => path.split('/')[0].length === 24)) {
throw new Error('expected mongo id in healthCheckBlobs')
}
if (!HEALTH_CHECK_PROJECTS.some(id => id.length === 24)) {
throw new Error('expected mongo id in healthCheckProjects')
if (!HEALTH_CHECK_BLOBS.some(path => path.split('/')[0].length < 24)) {
throw new Error('expected postgres id in healthCheckBlobs')
}
if (!HEALTH_CHECK_PROJECTS.some(id => id.length < 24)) {
throw new Error('expected postgres id in healthCheckProjects')
if (HEALTH_CHECK_BLOBS.some(path => path.split('/')[1]?.length !== 40)) {
throw new Error('expected hash in healthCheckBlobs')
}
for (const historyId of HEALTH_CHECK_PROJECTS) {
await verifyProjectWithErrorContext(historyId)
for (const path of HEALTH_CHECK_BLOBS) {
const [historyId, hash] = path.split('/')
await verifyBlob(historyId, hash)
}
}
export class BackupCorruptedMissingBlobError extends BackupCorruptedError {}