Sfoglia il codice sorgente

Revert "Split healthCheck out into separate module"

This reverts commit 96061812977d5c854e494cd44163b16a96722b17.

GitOrigin-RevId: f30a185b65a4f1346ed13fa0c6e9ea0852d44335
Andrew Rumble 1 anno fa
parent
commit
087a9daf34

+ 1 - 1
services/history-v1/backup-verifier-app.mjs

@@ -7,9 +7,9 @@ import { promisify } from 'node:util'
 import express from 'express'
 import logger from '@overleaf/logger'
 import Metrics from '@overleaf/metrics'
-import { healthCheck } from './backupVerifier/healthCheck.mjs'
 import {
   BackupCorruptedError,
+  healthCheck,
   verifyBlob,
 } from './storage/lib/backupVerifier.mjs'
 import { mongodb } from './storage/index.js'

+ 0 - 24
services/history-v1/backupVerifier/healthCheck.mjs

@@ -1,24 +0,0 @@
-import config from 'config'
-import { verifyProjectWithErrorContext } from '../storage/lib/backupVerifier.mjs'
-
-/** @type {Array<string>} */
-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')
-  }
-  if (HEALTH_CHECK_PROJECTS.length !== 2) {
-    throw new Error('expected 2 healthCheckProjects')
-  }
-  if (!HEALTH_CHECK_PROJECTS.some(id => id.length === 24)) {
-    throw new Error('expected mongo id in healthCheckProjects')
-  }
-  if (!HEALTH_CHECK_PROJECTS.some(id => id.length < 24)) {
-    throw new Error('expected postgres id in healthCheckProjects')
-  }
-
-  for (const historyId of HEALTH_CHECK_PROJECTS) {
-    await verifyProjectWithErrorContext(historyId)
-  }
-}

+ 20 - 0
services/history-v1/storage/lib/backupVerifier.mjs

@@ -220,6 +220,26 @@ 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')
+  }
+  if (HEALTH_CHECK_PROJECTS.length !== 2) {
+    throw new Error('expected 2 healthCheckProjects')
+  }
+  if (!HEALTH_CHECK_PROJECTS.some(id => id.length === 24)) {
+    throw new Error('expected mongo id in healthCheckProjects')
+  }
+  if (!HEALTH_CHECK_PROJECTS.some(id => id.length < 24)) {
+    throw new Error('expected postgres id in healthCheckProjects')
+  }
+
+  for (const historyId of HEALTH_CHECK_PROJECTS) {
+    await verifyProjectWithErrorContext(historyId)
+  }
+}
 export class BackupCorruptedMissingBlobError extends BackupCorruptedError {}
 export class BackupCorruptedInvalidBlobError extends BackupCorruptedError {}
 export class BackupRPOViolationChunkNotBackedUpError extends OError {}