From 4ccd2ecd6c9da6e66a034e5740b7df0e7b0b2577 Mon Sep 17 00:00:00 2001 From: Max Bischof <106820326+bischofmax@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:22:42 +0200 Subject: [PATCH 1/3] BC-7720 - Bump nodemon (#5135) --- package-lock.json | 49 ++++++++++++++--------------------------------- package.json | 2 +- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 44e369cb84d..8c48064c4e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -204,7 +204,7 @@ "mocha": "^9.1.3", "mockery": "^2.0.0", "nock": "^13.0.0", - "nodemon": "^2.0.2", + "nodemon": "^3.1.4", "nyc": "^15.0.1", "prettier": "^2.8.1", "prettier-eslint": "^12.0.0", @@ -17135,17 +17135,19 @@ "license": "MIT" }, "node_modules/nodemon": { - "version": "2.0.20", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.4.tgz", + "integrity": "sha512-wjPBbFhtpJwmIeY2yP7QF+UKzPfltVGtfce1g/bB15/8vCGZj8uxD62b/b9M9/WVgme0NZudpownKN+c0plXlQ==", "dev": true, "license": "MIT", "dependencies": { "chokidar": "^3.5.2", - "debug": "^3.2.7", + "debug": "^4", "ignore-by-default": "^1.0.1", "minimatch": "^3.1.2", "pstree.remy": "^1.1.8", - "semver": "^5.7.1", - "simple-update-notifier": "^1.0.7", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", "supports-color": "^5.5.0", "touch": "^3.1.0", "undefsafe": "^2.0.5" @@ -17154,21 +17156,13 @@ "nodemon": "bin/nodemon.js" }, "engines": { - "node": ">=8.10.0" + "node": ">=10" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/nodemon" } }, - "node_modules/nodemon/node_modules/debug": { - "version": "3.2.7", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.1" - } - }, "node_modules/nodemon/node_modules/has-flag": { "version": "3.0.0", "dev": true, @@ -17177,14 +17171,6 @@ "node": ">=4" } }, - "node_modules/nodemon/node_modules/semver": { - "version": "5.7.2", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver" - } - }, "node_modules/nodemon/node_modules/supports-color": { "version": "5.5.0", "dev": true, @@ -20378,23 +20364,16 @@ "license": "MIT" }, "node_modules/simple-update-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", - "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", "dev": true, + "license": "MIT", "dependencies": { - "semver": "~7.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/simple-update-notifier/node_modules/semver": { - "version": "7.0.0", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" + "node": ">=10" } }, "node_modules/sinon": { diff --git a/package.json b/package.json index 5a7d07f1fb4..0f27f05a772 100644 --- a/package.json +++ b/package.json @@ -320,7 +320,7 @@ "mocha": "^9.1.3", "mockery": "^2.0.0", "nock": "^13.0.0", - "nodemon": "^2.0.2", + "nodemon": "^3.1.4", "nyc": "^15.0.1", "prettier": "^2.8.1", "prettier-eslint": "^12.0.0", From 416947609901c5ea49070d951eb28693fe105625 Mon Sep 17 00:00:00 2001 From: Sergej Hoffmann <97111299+SevenWaysDP@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:22:14 +0200 Subject: [PATCH 2/3] BC-7207 - preview generator pod is crashlooping due to OOM (#5133) * add expiration to RPC message requests --- .../preview.producer.spec.ts | 18 ++++++++++------ .../rabbitmq/rpc-message-producer.spec.ts | 1 + .../infra/rabbitmq/rpc-message-producer.ts | 4 ++++ .../service/files-storage.producer.spec.ts | 21 +++++++++++++++---- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/apps/server/src/infra/preview-generator/preview.producer.spec.ts b/apps/server/src/infra/preview-generator/preview.producer.spec.ts index 47adea158a6..e6c5b680aff 100644 --- a/apps/server/src/infra/preview-generator/preview.producer.spec.ts +++ b/apps/server/src/infra/preview-generator/preview.producer.spec.ts @@ -12,9 +12,10 @@ import { PreviewProducer } from './preview.producer'; describe('PreviewProducer', () => { let module: TestingModule; let service: PreviewProducer; - let configService: DeepMocked; let amqpConnection: DeepMocked; + const timeout = 10000; + beforeAll(async () => { await setupEntities(); module = await Test.createTestingModule({ @@ -30,14 +31,20 @@ describe('PreviewProducer', () => { }, { provide: ConfigService, - useValue: createMock(), + useValue: createMock({ + get: jest.fn().mockImplementation((key: string) => { + if (key === 'INCOMING_REQUEST_TIMEOUT') { + return timeout; + } + throw new Error('Config key not found'); + }), + }), }, ], }).compile(); service = module.get(PreviewProducer); amqpConnection = module.get(AmqpConnection); - configService = module.get(ConfigService); }); afterAll(async () => { @@ -47,6 +54,7 @@ describe('PreviewProducer', () => { afterEach(() => { jest.resetAllMocks(); }); + it('should be defined', () => { expect(service).toBeDefined(); }); @@ -54,8 +62,6 @@ describe('PreviewProducer', () => { describe('generate', () => { describe('when valid params are passed and amqp connection return with a message', () => { const setup = () => { - const timeout = 10000; - const params: PreviewFileOptions = { originFilePath: 'file/test.jpeg', previewFilePath: 'preview/text.webp', @@ -67,13 +73,13 @@ describe('PreviewProducer', () => { const message = []; amqpConnection.request.mockResolvedValueOnce({ message }); - configService.get.mockReturnValue(timeout); const expectedParams = { exchange: FilesPreviewExchange, routingKey: FilesPreviewEvents.GENERATE_PREVIEW, payload: params, timeout, + expiration: timeout * 1.5, }; return { params, expectedParams, message }; diff --git a/apps/server/src/infra/rabbitmq/rpc-message-producer.spec.ts b/apps/server/src/infra/rabbitmq/rpc-message-producer.spec.ts index b2e94ea676b..fc0e2629485 100644 --- a/apps/server/src/infra/rabbitmq/rpc-message-producer.spec.ts +++ b/apps/server/src/infra/rabbitmq/rpc-message-producer.spec.ts @@ -59,6 +59,7 @@ describe('RpcMessageProducer', () => { routingKey: TestEvent, payload: params, timeout, + expiration: timeout * 1.5, }; return { params, expectedParams, message }; diff --git a/apps/server/src/infra/rabbitmq/rpc-message-producer.ts b/apps/server/src/infra/rabbitmq/rpc-message-producer.ts index 8a239b2cbcd..84b74f6e173 100644 --- a/apps/server/src/infra/rabbitmq/rpc-message-producer.ts +++ b/apps/server/src/infra/rabbitmq/rpc-message-producer.ts @@ -27,11 +27,15 @@ export abstract class RpcMessageProducer { } protected createRequest(event: string, payload: unknown) { + // expiration should be greater than timeout + const expiration = this.timeout > 0 ? this.timeout * 1.5 : undefined; + return { exchange: this.exchange, routingKey: event, payload, timeout: this.timeout, + expiration, }; } } diff --git a/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts b/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts index 12b476fb84c..517b0be1593 100644 --- a/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts +++ b/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts @@ -12,7 +12,6 @@ import { FilesStorageProducer } from './files-storage.producer'; describe('FilesStorageProducer', () => { let module: TestingModule; let service: FilesStorageProducer; - let configService: DeepMocked; let amqpConnection: DeepMocked; const timeout = 10000; @@ -32,21 +31,30 @@ describe('FilesStorageProducer', () => { }, { provide: ConfigService, - useValue: createMock(), + useValue: createMock({ + get: jest.fn().mockImplementation((key: string) => { + if (key === 'INCOMING_REQUEST_TIMEOUT_COPY_API') { + return timeout; + } + throw new Error('Config key not found'); + }), + }), }, ], }).compile(); service = module.get(FilesStorageProducer); amqpConnection = module.get(AmqpConnection); - configService = module.get(ConfigService); - configService.get.mockReturnValue(timeout); }); afterAll(async () => { await module.close(); }); + afterEach(() => { + jest.clearAllMocks(); + }); + describe('copyFilesOfParent', () => { describe('when amqpConnection return with error in response', () => { const setup = () => { @@ -111,6 +119,7 @@ describe('FilesStorageProducer', () => { routingKey: FilesStorageEvents.COPY_FILES_OF_PARENT, payload: params, timeout, + expiration: timeout * 1.5, }; return { params, expectedParams, message }; @@ -163,6 +172,7 @@ describe('FilesStorageProducer', () => { routingKey: FilesStorageEvents.LIST_FILES_OF_PARENT, payload: parentId, timeout, + expiration: timeout * 1.5, }; const message = []; @@ -221,6 +231,7 @@ describe('FilesStorageProducer', () => { routingKey: FilesStorageEvents.DELETE_FILES_OF_PARENT, payload: parentId, timeout, + expiration: timeout * 1.5, }; return { parentId, message, expectedParams }; @@ -275,6 +286,7 @@ describe('FilesStorageProducer', () => { routingKey: FilesStorageEvents.DELETE_FILES, payload: [recordId], timeout, + expiration: timeout * 1.5, }; return { recordId, message, expectedParams }; }; @@ -329,6 +341,7 @@ describe('FilesStorageProducer', () => { routingKey: FilesStorageEvents.REMOVE_CREATORID_OF_FILES, payload: creatorId, timeout, + expiration: timeout * 1.5, }; return { creatorId, message, expectedParams }; From b54cc3c26a5c2dca39689beaa7665b22e39f3851 Mon Sep 17 00:00:00 2001 From: Max Bischof <106820326+bischofmax@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:27:57 +0200 Subject: [PATCH 3/3] BC-7719 - Bump json webtoken (#5137) --- package-lock.json | 52 +++++++++++++++++++++++++---------------------- package.json | 2 +- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8c48064c4e3..f7daa471e75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,7 +91,7 @@ "ioredis": "^5.3.2", "jose": "^5.6.3", "jsdom": "^23.2.0", - "jsonwebtoken": "^9.0.0", + "jsonwebtoken": "^9.0.2", "jwks-rsa": "^2.0.5", "ldapjs": "git://github.com/hpi-schul-cloud/node-ldapjs.git", "lodash": "^4.17.19", @@ -2591,26 +2591,6 @@ "@types/node": "*" } }, - "node_modules/@feathersjs/authentication/node_modules/jsonwebtoken": { - "version": "9.0.2", - "license": "MIT", - "dependencies": { - "jws": "^3.2.2", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", - "ms": "^2.1.1", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=12", - "npm": ">=6" - } - }, "node_modules/@feathersjs/authentication/node_modules/typescript": { "version": "5.3.2", "license": "Apache-2.0", @@ -4815,6 +4795,22 @@ "@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0" } }, + "node_modules/@nestjs/jwt/node_modules/jsonwebtoken": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz", + "integrity": "sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw==", + "license": "MIT", + "dependencies": { + "jws": "^3.2.2", + "lodash": "^4.17.21", + "ms": "^2.1.1", + "semver": "^7.3.8" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, "node_modules/@nestjs/mapped-types": { "version": "2.0.2", "license": "MIT", @@ -15258,13 +15254,21 @@ } }, "node_modules/jsonwebtoken": { - "version": "9.0.0", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", "license": "MIT", "dependencies": { "jws": "^3.2.2", - "lodash": "^4.17.21", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", "ms": "^2.1.1", - "semver": "^7.3.8" + "semver": "^7.5.4" }, "engines": { "node": ">=12", diff --git a/package.json b/package.json index 0f27f05a772..a792816c932 100644 --- a/package.json +++ b/package.json @@ -207,7 +207,7 @@ "ioredis": "^5.3.2", "jose": "^5.6.3", "jsdom": "^23.2.0", - "jsonwebtoken": "^9.0.0", + "jsonwebtoken": "^9.0.2", "jwks-rsa": "^2.0.5", "ldapjs": "git://github.com/hpi-schul-cloud/node-ldapjs.git", "lodash": "^4.17.19",