mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 16:27:22 +00:00
UBERF-8122: Fix backup service (#6577)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
6704ec8183
commit
afbe37d7ef
@ -16,6 +16,7 @@
|
|||||||
"_phase:docker-staging": "rushx docker:staging",
|
"_phase:docker-staging": "rushx docker:staging",
|
||||||
"bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --sourcemap=inline --platform=node --external:*.node --external:bufferutil --external:snappy > bundle/bundle.js",
|
"bundle": "mkdir -p bundle && esbuild src/index.ts --bundle --sourcemap=inline --platform=node --external:*.node --external:bufferutil --external:snappy > bundle/bundle.js",
|
||||||
"docker:build": "../../common/scripts/docker_build.sh hardcoreeng/backup",
|
"docker:build": "../../common/scripts/docker_build.sh hardcoreeng/backup",
|
||||||
|
"docker:tbuild": "docker build -t hardcoreeng/backup . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/backup",
|
||||||
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/backup staging",
|
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/backup staging",
|
||||||
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/backup",
|
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/backup",
|
||||||
"run-local": "cross-env ACCOUNTS_URL=http://localhost:3000/ SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost BUCKET_NAME=backups INTERVAL=30 ts-node src/index.ts",
|
"run-local": "cross-env ACCOUNTS_URL=http://localhost:3000/ SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost BUCKET_NAME=backups INTERVAL=30 ts-node src/index.ts",
|
||||||
|
@ -106,7 +106,7 @@ class BackupWorker {
|
|||||||
})
|
})
|
||||||
const childLogger = rootCtx.logger.childLogger?.(ws.workspace, {
|
const childLogger = rootCtx.logger.childLogger?.(ws.workspace, {
|
||||||
workspace: ws.workspace,
|
workspace: ws.workspace,
|
||||||
enableConsole: 'false'
|
enableConsole: 'true'
|
||||||
})
|
})
|
||||||
const ctx = rootCtx.newChild(ws.workspace, { workspace: ws.workspace }, {}, childLogger)
|
const ctx = rootCtx.newChild(ws.workspace, { workspace: ws.workspace }, {}, childLogger)
|
||||||
try {
|
try {
|
||||||
@ -124,7 +124,7 @@ class BackupWorker {
|
|||||||
const pipeline = await this.pipelineFactory(ctx, wsUrl, true, () => {}, null)
|
const pipeline = await this.pipelineFactory(ctx, wsUrl, true, () => {}, null)
|
||||||
|
|
||||||
await ctx.with('backup', { workspace: ws.workspace }, async (ctx) => {
|
await ctx.with('backup', { workspace: ws.workspace }, async (ctx) => {
|
||||||
await backup(ctx, ws.endpoint, getWorkspaceId(ws.workspace), storage, {
|
await backup(ctx, '', getWorkspaceId(ws.workspace), storage, {
|
||||||
skipDomains: [],
|
skipDomains: [],
|
||||||
force: false,
|
force: false,
|
||||||
recheck: false,
|
recheck: false,
|
||||||
|
@ -173,7 +173,12 @@ export class BlobClient {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err?.code === 'NoSuchKey') {
|
if (
|
||||||
|
err?.code === 'NoSuchKey' ||
|
||||||
|
err?.code === 'NotFound' ||
|
||||||
|
err?.message === 'No such key' ||
|
||||||
|
err?.Code === 'NoSuchKey'
|
||||||
|
) {
|
||||||
ctx.info('No such key', { name })
|
ctx.info('No such key', { name })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,12 @@ async function getFileRange (
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err?.code === 'NoSuchKey' || err?.code === 'NotFound') {
|
if (
|
||||||
|
err?.code === 'NoSuchKey' ||
|
||||||
|
err?.code === 'NotFound' ||
|
||||||
|
err?.message === 'No such key' ||
|
||||||
|
err?.Code === 'NoSuchKey'
|
||||||
|
) {
|
||||||
ctx.info('No such key', { workspace: workspace.name, uuid })
|
ctx.info('No such key', { workspace: workspace.name, uuid })
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
return
|
return
|
||||||
@ -459,7 +464,12 @@ export function start (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error?.code === 'NoSuchKey' || error?.code === 'NotFound' || error?.message === 'No such key') {
|
if (
|
||||||
|
error?.code === 'NoSuchKey' ||
|
||||||
|
error?.code === 'NotFound' ||
|
||||||
|
error?.message === 'No such key' ||
|
||||||
|
error?.Code === 'NoSuchKey'
|
||||||
|
) {
|
||||||
ctx.error('No such storage key', {
|
ctx.error('No such storage key', {
|
||||||
file: req.query.file,
|
file: req.query.file,
|
||||||
workspace: payload?.workspace,
|
workspace: payload?.workspace,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { type DatalakeConfig, DatalakeService } from '@hcengineering/datalake'
|
import { DatalakeService, type DatalakeConfig } from '@hcengineering/datalake'
|
||||||
import { MinioConfig, MinioService, addMinioFallback } from '@hcengineering/minio'
|
import { MinioConfig, MinioService, addMinioFallback } from '@hcengineering/minio'
|
||||||
import { createRawMongoDBAdapter } from '@hcengineering/mongo'
|
import { createRawMongoDBAdapter } from '@hcengineering/mongo'
|
||||||
import { S3Service, type S3Config } from '@hcengineering/s3'
|
import { S3Service, type S3Config } from '@hcengineering/s3'
|
||||||
@ -30,10 +30,10 @@ import {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function storageConfigFromEnv (configEnv: string = 'STORAGE_CONFIG'): StorageConfiguration {
|
export function storageConfigFromEnv (configEnv?: string): StorageConfiguration {
|
||||||
const storageConfig: StorageConfiguration = { default: '', storages: [] }
|
const storageConfig: StorageConfiguration = { default: '', storages: [] }
|
||||||
|
|
||||||
const storageEnv = process.env[configEnv]
|
const storageEnv = configEnv ?? process.env.STORAGE_CONFIG
|
||||||
if (storageEnv !== undefined) {
|
if (storageEnv !== undefined) {
|
||||||
parseStorageEnv(storageEnv, storageConfig)
|
parseStorageEnv(storageEnv, storageConfig)
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,12 @@ export async function getFileRange (
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err?.code === 'NoSuchKey' || err?.code === 'NotFound') {
|
if (
|
||||||
|
err?.code === 'NoSuchKey' ||
|
||||||
|
err?.code === 'NotFound' ||
|
||||||
|
err?.message === 'No such key' ||
|
||||||
|
err?.Code === 'NoSuchKey'
|
||||||
|
) {
|
||||||
ctx.info('No such key', { workspace: workspace.name, uuid })
|
ctx.info('No such key', { workspace: workspace.name, uuid })
|
||||||
res.cork(() => {
|
res.cork(() => {
|
||||||
res.status(404)
|
res.status(404)
|
||||||
|
Loading…
Reference in New Issue
Block a user