Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make probeserver config optional for bucket notification processes in S3C #2587

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion extensions/notification/NotificationConfigValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const joiSchema = joi.object({
concurrency: joi.number().greater(0).default(1000),
},
destinations: joi.array().items(destinationSchema).default([]),
probeServer: probeServerJoi.default()
// TODO: BB-625 reset to being required after supporting probeserver in S3C
// for bucket notification proceses
probeServer: probeServerJoi.optional()
});

function configValidator(backbeatConfig, extConfig) {
Expand Down
15 changes: 11 additions & 4 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const assert = require('assert');
const { EventEmitter } = require('events');
const joi = require('joi');

const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -54,10 +55,16 @@ class Config extends EventEmitter {
throw new Error(`could not parse config file: ${err.message}`);
}

const { value: parsedConfig, err } = backbeatConfigJoi.validate(config);
if (err) {
throw new Error(`could not validate config file: ${err.message}`);
}
this._parseConfig(config);
}

/**
* Parses Backbeat's configuration
* @param {Object} config backbeat configuration
* @returns {undefined}
*/
_parseConfig(config) {
const parsedConfig = joi.attempt(config, backbeatConfigJoi);
francoisferrand marked this conversation as resolved.
Show resolved Hide resolved

if (parsedConfig.extensions) {
Object.keys(parsedConfig.extensions).forEach(extName => {
Expand Down
8 changes: 7 additions & 1 deletion lib/config.joi.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ const joiSchema = joi.object({
}).when('logSource', { is: 'dmd', then: joi.required() }),
mongo: mongoJoi,
kafka: qpKafkaJoi.when('logSource', { is: 'kafka', then: joi.required() }),
probeServer: probeServerJoi.default(),
// TODO: BB-625 reset to being required after supporting probeserver in S3C
// for bucket notification proceses
probeServer: probeServerJoi.when('...extensions', {
is: joi.object().keys({ notification: joi.exist() }),
then: joi.optional(),
otherwise: joi.required(),
}),
circuitBreaker: joi.object().optional(),
},
log: logJoi,
Expand Down
3 changes: 1 addition & 2 deletions lib/util/probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const RdkafkaStats = require('node-rdkafka-prometheus');
*/
function startProbeServer(config, callback) {
if (!config) {
const err = new Error('configuration for probe server is missing');
callback(err);
callback();
return;
}

Expand Down
4 changes: 0 additions & 4 deletions tests/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@
"host": "127.0.0.1",
"port": 8900
},
"healthcheckServer": {
"bindAddress": "0.0.0.0",
"port": 4042
},
"redis": {
"name": "backbeat-test",
"password": "",
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/lib/config/Config.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'; // eslint-disable-line

const assert = require('assert');

const { Config } = require('../../../../lib/Config');
const backbeatConfig = require('./config.json');

describe('Config', () => {
it('should make the probeserver config in the queuePoulator' +
'required when multiple extensions are configured', () => {
const config = new Config();
const testConfig = { ...backbeatConfig };
delete testConfig.queuePopulator.probeServer;
assert.throws(() => config._parseConfig(testConfig));
});

it('should make the probeserver config in the queuePoulator' +
'optional when only notification config is specified', () => {
const config = new Config();
const testConfig = { ...backbeatConfig };
delete testConfig.queuePopulator.probeServer;
testConfig.extensions = { notification: testConfig.extensions.notification };
assert.doesNotThrow(() => config._parseConfig(testConfig));
});
});
Loading
Loading