From 938d267e70415ffb865f03c5c647fb49674a8a3e Mon Sep 17 00:00:00 2001 From: Dimitrios Vasilas Date: Mon, 23 Nov 2026 09:25:51 +0200 Subject: [PATCH 1/3] CLDSRV-1043: Bump arsenal to 8.6.4 --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 3f0639084c..4a349a8bb1 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@opentelemetry/instrumentation-http": "~0.222.0", "@opentelemetry/instrumentation-ioredis": "~0.70.0", "@opentelemetry/instrumentation-mongodb": "~0.75.0", - "@scality/arsenal": "^8.6.1", + "@scality/arsenal": "^8.6.4", "@scality/bucketclient": "scality/bucketclient#8.3.0", "@scality/cloudserverclient": "1.0.13", "@scality/scubaclient": "1.2.2", diff --git a/yarn.lock b/yarn.lock index 5f8adf0211..fe5627d39c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1314,10 +1314,10 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.2.tgz#78d476333d85d5b1c792e257bca74ba080da49a4" integrity sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug== -"@scality/arsenal@^8.6.0", "@scality/arsenal@^8.6.1": - version "8.6.1" - resolved "https://registry.yarnpkg.com/@scality/arsenal/-/arsenal-8.6.1.tgz#f2db3ec8184646282872850d1cce3c16870f053c" - integrity sha512-EwKYj0htAbDvDmu4h3EeIG1RwwxGCRvUixQN8NHx9bJIHS5qucQLvNCQ45BNR0q4MDIza3fyE6Xn7DF5hxBBUQ== +"@scality/arsenal@^8.6.0", "@scality/arsenal@^8.6.4": + version "8.6.4" + resolved "https://registry.yarnpkg.com/@scality/arsenal/-/arsenal-8.6.4.tgz#f1ebb196835f103a613632c42b6ba3ba8ca13008" + integrity sha512-tAFQ8Xq7ukRR64Y+JGKTpX+3AfcdDK6Q1RC7Np8couFElhn0OpRz7p6mP7MgmMeUfC4J4d/5S8/DG2BFNVPINQ== dependencies: "@aws-sdk/client-kms" "^3.975.0" "@aws-sdk/client-s3" "^3.975.0" @@ -1332,7 +1332,7 @@ "@opentelemetry/sdk-node" "^0.223.0" "@opentelemetry/sdk-trace-base" "^2.12.0" "@scality/hdclient" "^1.3.2" - "@smithy/node-http-handler" "^4.3.0" + "@smithy/node-http-handler" "^4.4.0" "@smithy/protocol-http" "^5.3.5" JSONStream "^1.3.5" agentkeepalive "^4.6.0" @@ -1585,7 +1585,7 @@ "@smithy/types" "^3.7.2" tslib "^2.6.2" -"@smithy/node-http-handler@^4.12.1", "@smithy/node-http-handler@^4.3.0": +"@smithy/node-http-handler@^4.12.1", "@smithy/node-http-handler@^4.4.0": version "4.13.0" resolved "https://registry.yarnpkg.com/@smithy/node-http-handler/-/node-http-handler-4.13.0.tgz#cc26fbea5572a482b35cb43ca55c0d182e4eff70" integrity sha512-/GGcPoNJ2nzGytdAanpbx7mpp9Coa8LP+/Rpmbktr8YeLuIXs9B0SEz+X3AeonHdyzOIFJdKbN7jOZ+Tj+pMGw== From 7f52fa01db7a0eff2bfafdd35377b895f0fd96b8 Mon Sep 17 00:00:00 2001 From: Dimitrios Vasilas Date: Mon, 9 Nov 2026 11:04:14 +0200 Subject: [PATCH 2/3] CLDSRV-1043: Limit the time of each request to a KMIP or AWS KMS Set by requestTimeoutMs on a kmip or aws_kms entry, 5000 ms by default. --- CLAUDE.md | 2 ++ lib/Config.js | 38 +++++++++++++++++++++--- tests/unit/testConfigs/parseKms.js | 42 +++++++++++++++++++++++++++ tests/unit/testConfigs/parseKmsAWS.js | 3 ++ 4 files changed, 81 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 2fb6b0a230..a9418cc0fc 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -136,6 +136,8 @@ the default KMS. With `kmsHideScalityArn` (on by default), responses return key IDs without ARN only for keys of the default KMS, so a returned key ID names the same key when sent back. The deep health check has one entry per KMS, keyed by `kms:` and its `providerName`; a failing KMS never fails start-up or readiness. +Each attempt of a request to a `kmip` or `aws_kms` KMS fails after +`requestTimeoutMs` of its entry, 5000 by default. | Protocol | Description | | --------- | ------------------------------------------------------ | diff --git a/lib/Config.js b/lib/Config.js index 6770e4e525..442213aba6 100644 --- a/lib/Config.js +++ b/lib/Config.js @@ -56,6 +56,10 @@ function findConfigFile(fileName) { const defaultHealthChecks = { allowFrom: ['127.0.0.1/8', '::1'] }; const defaultLocalCache = { host: '127.0.0.1', port: 6379 }; + +// Time limit of each attempt of a request to a kmip or aws_kms KMS +const defaultKmsRequestTimeoutMs = 5000; + const defaultExternalBackendsConfig = { // eslint-disable-next-line camelcase aws_s3: { @@ -691,6 +695,24 @@ class Config extends EventEmitter { return kms; } + /** + * @param {object} block - the settings of a kmip or aws_kms kms entry + * @returns {number} the time limit of each attempt of a request to that + * KMS, in milliseconds + */ + _parseKmsRequestTimeout(block) { + const { requestTimeoutMs } = block; + if (requestTimeoutMs === undefined) { + return defaultKmsRequestTimeoutMs; + } + assert( + Number.isInteger(requestTimeoutMs) && requestTimeoutMs > 0, + 'bad config: kms entry requestTimeoutMs must be a positive integer, ' + + `got ${JSON.stringify(requestTimeoutMs)}`, + ); + return requestTimeoutMs; + } + _parseKmsAWS(block) { const { providerName, region, endpoint, ak, sk, tls, noAwsArn } = block; @@ -707,6 +729,7 @@ class Config extends EventEmitter { endpoint, ak, sk, + requestTimeoutMs: this._parseKmsRequestTimeout(block), }; if (region) { @@ -751,9 +774,10 @@ class Config extends EventEmitter { * @param {object} transportKmip - a KMIP transport from the config * @param {object} environment - `process.env` for the default kms entry, * whose settings override the S3KMIP_* variables, `{}` for the others + * @param {number} requestTimeoutMs - time limit of each request * @returns {object} the transport passed to the KMIP client */ - _parseKmipTransport(transportKmip, environment) { + _parseKmipTransport(transportKmip, environment, requestTimeoutMs) { const transport = { /** Specify the request pipeline depth here. * If for some reason the server sends the replies @@ -764,6 +788,7 @@ class Config extends EventEmitter { * Note: 0 is not an appropriate value and will fall back to 1. */ pipelineDepth: environment.S3KMIP_PIPELINE_DEPTH || 8, + requestTimeoutMs, tls: { port: environment.S3KMIP_PORT || 5696, // ignore multiple hosts via env @@ -848,10 +873,11 @@ class Config extends EventEmitter { kmip.client.bucketNameAttributeName = block.client.bucketNameAttributeName; } } + const requestTimeoutMs = this._parseKmsRequestTimeout(block); if (!block.transport) { - kmip.transport = this._parseKmipTransport({}, environment); + kmip.transport = this._parseKmipTransport({}, environment, requestTimeoutMs); } else if (Array.isArray(block.transport)) { - kmip.transport = block.transport.map(t => this._parseKmipTransport(t, environment)); + kmip.transport = block.transport.map(t => this._parseKmipTransport(t, environment, requestTimeoutMs)); if (block.retries !== undefined) { assert( Number.isInteger(block.retries) && block.retries >= 0, @@ -866,7 +892,7 @@ class Config extends EventEmitter { kmip.retries = kmip.transport.length - 1; } } else { - kmip.transport = this._parseKmipTransport(block.transport, environment); + kmip.transport = this._parseKmipTransport(block.transport, environment, requestTimeoutMs); } return kmip; } @@ -898,6 +924,10 @@ class Config extends EventEmitter { isDefault === undefined || typeof isDefault === 'boolean', 'bad config: kms entry default must be a boolean', ); + assert( + block.requestTimeoutMs === undefined || [KmsProtocol.kmip, KmsProtocol.aws_kms].includes(protocol), + 'bad config: requestTimeoutMs is only for kmip and aws_kms kms entries', + ); const { providerName } = block; assert(providerName, `bad config: ${protocol} kms entry must define providerName`); assert(isValidProvider(providerName), 'bad config: kms entry providerName must be lowercase alphanumeric only'); diff --git a/tests/unit/testConfigs/parseKms.js b/tests/unit/testConfigs/parseKms.js index cc45ed80a2..390d3b9dab 100644 --- a/tests/unit/testConfigs/parseKms.js +++ b/tests/unit/testConfigs/parseKms.js @@ -90,6 +90,7 @@ describe('parseKms Function', () => { assert.strictEqual(entry.settings.transport.tls.host, 'kmip.example.com'); assert.strictEqual(entry.settings.transport.tls.port, 5696); assert.strictEqual(entry.settings.transport.pipelineDepth, 8); + assert.strictEqual(entry.settings.transport.requestTimeoutMs, 5000); assert.deepStrictEqual(entry.settings.client, { compoundCreateActivate: false, bucketNameAttributeName: '', @@ -129,9 +130,31 @@ describe('parseKms Function', () => { endpoint: 'https://kms.example.com', ak: 'accessKey', sk: 'secretKey', + requestTimeoutMs: 5000, }); }); + it('should apply the requestTimeoutMs of a kmip entry to every transport of its cluster', () => { + configInstance._parseKms({ + kms: [ + { + ...kmipEntry, + requestTimeoutMs: 2000, + transport: [{ tls: { host: 'kmip1' } }, { tls: { host: 'kmip2' } }], + }, + ], + }); + assert.deepStrictEqual( + configInstance.kms[0].settings.transport.map(transport => transport.requestTimeoutMs), + [2000, 2000], + ); + }); + + it('should apply the requestTimeoutMs of an aws_kms entry', () => { + configInstance._parseKms({ kms: [{ ...awsEntry, default: true, requestTimeoutMs: 2000 }] }); + assert.strictEqual(configInstance.kms[0].settings.requestTimeoutMs, 2000); + }); + it('should parse a file entry', () => { configInstance._parseKms({ kms: [{ ...fileEntry, default: true }] }); assert.deepStrictEqual(configInstance.kms, [ @@ -236,6 +259,24 @@ describe('parseKms Function', () => { ); }); + [0, '2000'].forEach(requestTimeoutMs => { + it(`should reject requestTimeoutMs ${JSON.stringify(requestTimeoutMs)}`, () => { + assert.throws( + () => configInstance._parseKms({ kms: [{ ...kmipEntry, requestTimeoutMs }] }), + /kms entry requestTimeoutMs must be a positive integer/, + ); + }); + }); + + [{ ...fileEntry, default: true }, safeNetEntry].forEach(entry => { + it(`should reject requestTimeoutMs on a ${entry.protocol} entry`, () => { + assert.throws( + () => configInstance._parseKms({ kms: [{ ...entry, requestTimeoutMs: 2000 }] }), + /requestTimeoutMs is only for kmip and aws_kms kms entries/, + ); + }); + }); + it('should reject a default that is not a boolean', () => { assert.throws( () => configInstance._parseKms({ kms: [{ ...kmipEntry, default: 'true' }] }), @@ -367,6 +408,7 @@ describe('parseKms Function', () => { assert.strictEqual(settings.transport.tls.host, 'kmip.example.com'); assert.strictEqual(settings.transport.tls.port, '5697'); assert.strictEqual(settings.transport.pipelineDepth, '4'); + assert.strictEqual(settings.transport.requestTimeoutMs, 5000); assert.deepStrictEqual(settings.client, { compoundCreateActivate: true, bucketNameAttributeName: 'bucket', diff --git a/tests/unit/testConfigs/parseKmsAWS.js b/tests/unit/testConfigs/parseKmsAWS.js index d8747b6415..cdaa84da44 100644 --- a/tests/unit/testConfigs/parseKmsAWS.js +++ b/tests/unit/testConfigs/parseKmsAWS.js @@ -42,6 +42,7 @@ describe('parseKmsAWS Function', () => { endpoint: 'https://example.com', ak: 'accessKey', sk: 'secretKey', + requestTimeoutMs: 5000, }); }); @@ -61,6 +62,7 @@ describe('parseKmsAWS Function', () => { endpoint: 'https://example.com', ak: 'accessKey', sk: 'secretKey', + requestTimeoutMs: 5000, region: 'us-west-2', }); }); @@ -85,6 +87,7 @@ describe('parseKmsAWS Function', () => { endpoint: 'https://example.com', ak: 'accessKey', sk: 'secretKey', + requestTimeoutMs: 5000, tls: { rejectUnauthorized: true, minVersion: 'TLSv1.2', From a4f176ab990a9f678a29c7b2ea6c4c0d9d41425c Mon Sep 17 00:00:00 2001 From: Dimitrios Vasilas Date: Mon, 9 Nov 2026 11:04:14 +0200 Subject: [PATCH 3/3] CLDSRV-1043: Test a KMS that does not answer The KMIP functional job gets a KMS that accepts connections and never answers. --- .github/docker/docker-compose.yaml | 8 ++++ .github/workflows/tests.yaml | 6 ++- .../functional/kmip/serverside_encryption.js | 48 +++++++++++++++---- .../configs/nonDefaultKmsEntries.json | 6 +++ 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/.github/docker/docker-compose.yaml b/.github/docker/docker-compose.yaml index 7b3782b81c..c22f24737d 100644 --- a/.github/docker/docker-compose.yaml +++ b/.github/docker/docker-compose.yaml @@ -85,6 +85,14 @@ services: - ../pykmip/certs:/ssl - ../pykmip/policy.json:/etc/pykmip/policies/policy.json - ../pykmip/server.conf:/etc/pykmip/server.conf + # A KMS that accepts connections and never answers + unresponsive-kmip: + network_mode: host + profiles: ['pykmip'] + image: ${CLOUDSERVER_IMAGE} + # node does not stop on SIGTERM as PID 1 + init: true + entrypoint: ['node', '-e', "require('net').createServer(() => {}).listen(5697)"] localkms: network_mode: host profiles: ['localkms'] diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index e62fabf22b..cc8f9e7a8a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -899,7 +899,11 @@ jobs: > config.json working-directory: tests/functional/sse-kms-migration - name: Setup CI services - run: docker compose up -d --quiet-pull redis pykmip localkms cloudserver-sse-before-migration + # The KMS that never answers must listen before cloudserver checks every KMS at start-up + run: | + docker compose up -d --quiet-pull unresponsive-kmip + bash ../../wait_for_local_port.bash 5697 40 + docker compose up -d --quiet-pull redis pykmip localkms cloudserver-sse-before-migration working-directory: .github/docker - name: Run file KMIP tests env: diff --git a/tests/functional/kmip/serverside_encryption.js b/tests/functional/kmip/serverside_encryption.js index 832299a7ee..c965e74328 100644 --- a/tests/functional/kmip/serverside_encryption.js +++ b/tests/functional/kmip/serverside_encryption.js @@ -25,6 +25,9 @@ const http = require('http'); const https = require('https'); const assert = require('assert'); const logger = { info: msg => process.stdout.write(`${msg}\n`) }; + +// A KMS of the server config that accepts connections and never answers +const unresponsiveKmsProviderName = 'unresponsive'; const async = require('async'); function _createBucketWithHeaders(name, headers, done) { @@ -228,7 +231,9 @@ describe('KMIP backed server-side encryption', () => { describe('KMIP backed server-side encryption with other KMSs configured', () => { const createBucket = promisify(_createBucket); const createBucketWithHeaders = promisify(_createBucketWithHeaders); - const nonDefaultEntries = serverConfig.kms.filter(entry => !entry.default); + const nonDefaultEntries = serverConfig.kms.filter( + entry => !entry.default && entry.providerName !== unresponsiveKmsProviderName, + ); const body = 'I am the best content ever'; let bucketName; let objectName; @@ -490,6 +495,18 @@ describe('KMIP backed server-side encryption with other KMSs configured', () => await assertStoredAndRefusedOnWrite(encryptedBucketName); }); }); + + describe('with a key of a KMS that does not answer', () => { + const keyArn = `${makeScalityArnPrefix(KmsType.external, KmsProtocol.kmip, unresponsiveKmsProviderName)}1`; + + it('should fail PutObject with an internal error after the time limit of the KMS', () => + assert.rejects(putObject(bucketName, objectName, keyArn), err => { + assert.strictEqual(err.name, 'InternalError'); + assert.strictEqual(err.$metadata.httpStatusCode, 500); + assert.match(err.message, /ETIMEDOUT/); + return true; + })); + }); }); describe('KMS health in the deep health check', () => { @@ -506,16 +523,29 @@ describe('KMS health in the deep health check', () => { }); } - it('should report every configured KMS, keyed by kms: and the provider name', async () => { + it('should report every configured KMS that answers, keyed by kms: and the provider name', async () => { const { statusCode, body } = await getDeepHealthcheck(); assert.strictEqual(statusCode, 200); - serverConfig.kms.forEach(({ protocol, providerName }) => { - const { lastChecked, ...health } = body[`kms:${providerName}`]; - assert.deepStrictEqual(health, { code: 200, message: 'OK' }, `KMS ${providerName}`); - // A KMS whose client has no health check reports OK without being checked; - // today only the KMIP client has one - assert.strictEqual(lastChecked !== undefined, protocol === KmsProtocol.kmip, `KMS ${providerName}`); - }); + serverConfig.kms + .filter(({ providerName }) => providerName !== unresponsiveKmsProviderName) + .forEach(({ protocol, providerName }) => { + const { lastChecked, ...health } = body[`kms:${providerName}`]; + assert.deepStrictEqual(health, { code: 200, message: 'OK' }, `KMS ${providerName}`); + // A KMS whose client has no health check reports OK without being checked; + // today only the KMIP client has one + assert.strictEqual(lastChecked !== undefined, protocol === KmsProtocol.kmip, `KMS ${providerName}`); + }); + }); + + it('should report an unresponsive KMS as failed after its time limit, without blocking start-up', async () => { + const { statusCode, body } = await getDeepHealthcheck(); + + assert.strictEqual(statusCode, 200); + const { code, message, description } = body[`kms:${unresponsiveKmsProviderName}`]; + assert.strictEqual(code, 500); + assert.strictEqual(message, 'KMS health check failed'); + // Checked at start-up, while the KMS was already listening + assert.match(description, /ETIMEDOUT/); }); }); diff --git a/tests/functional/sse-kms-migration/configs/nonDefaultKmsEntries.json b/tests/functional/sse-kms-migration/configs/nonDefaultKmsEntries.json index d19a9c6dd2..53902346fc 100644 --- a/tests/functional/sse-kms-migration/configs/nonDefaultKmsEntries.json +++ b/tests/functional/sse-kms-migration/configs/nonDefaultKmsEntries.json @@ -12,6 +12,12 @@ { "protocol": "file", "providerName": "scality" + }, + { + "protocol": "kmip", + "providerName": "unresponsive", + "requestTimeoutMs": 1000, + "transport": { "tls": { "host": "127.0.0.1", "port": 5697 } } } ] }