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

S3C supports having different queueProcessor probeserver configuratio… #2550

Merged
Merged
Show file tree
Hide file tree
Changes from 7 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
7 changes: 5 additions & 2 deletions extensions/replication/ReplicationConfigValidator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');
const joi = require('joi');
const { hostPortJoi, transportJoi, bootstrapListJoi, adminCredsJoi,
retryParamsJoi, probeServerJoi } =
retryParamsJoi, probeServerJoi, probeServerPerSite } =
require('../../lib/config/configItems.joi');

const qpRetryJoi = joi.object({
Expand Down Expand Up @@ -71,7 +71,10 @@ const joiSchema = joi.object({
concurrency: joi.number().greater(0).default(10),
mpuPartsConcurrency: joi.number().greater(0).default(10),
minMPUSizeMB: joi.number().greater(0).default(20),
probeServer: probeServerJoi.default(),
probeServer: joi.alternatives().try(
probeServerJoi,
probeServerPerSite
KillianG marked this conversation as resolved.
Show resolved Hide resolved
).default({ bindAddress: 'localhost', port: '' }),
KillianG marked this conversation as resolved.
Show resolved Hide resolved
circuitBreaker: joi.object().optional(),
}).required(),
replicationStatusProcessor: {
Expand Down
22 changes: 21 additions & 1 deletion extensions/replication/queueProcessor/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,28 @@
}
});

/**
* Get probe config will pull the configuration for the probe server based on
* the provided site key, and if the probe server config is not an array, it will
* return the global probe server config.
*
* Get the probe server config for the first site in the site names list,
* as if the probeConfig is an array there is only one element in site names
*
* @param {Object} queueProcessorConfig - Configuration of the queue processor that
* holds the probe server configs for all sites
* @param {Array<String>} siteNames - List of site names
* @returns {ProbeServerConfig} Config for site or global config
*/
function getProbeConfig(queueProcessorConfig, siteNames) {
KillianG marked this conversation as resolved.
Show resolved Hide resolved
if (Array.isArray(queueProcessorConfig.probeServer) && siteNames[0]) {
KillianG marked this conversation as resolved.
Show resolved Hide resolved
return queueProcessorConfig.probeServer.filter(probe => probe.site === siteNames[0])[0];

Check warning on line 257 in extensions/replication/queueProcessor/task.js

View check run for this annotation

Codecov / codecov/patch/Backbeat

extensions/replication/queueProcessor/task.js#L256-L257

Added lines #L256 - L257 were not covered by tests
KillianG marked this conversation as resolved.
Show resolved Hide resolved
}
return queueProcessorConfig.probeServer;

Check warning on line 259 in extensions/replication/queueProcessor/task.js

View check run for this annotation

Codecov / codecov/patch/Backbeat

extensions/replication/queueProcessor/task.js#L259

Added line #L259 was not covered by tests
}

startProbeServer(
repConfig.queueProcessor.probeServer,
getProbeConfig(repConfig.queueProcessor, siteNames),
(err, probeServer) => {
if (err) {
log.fatal('error creating probe server', {
Expand Down
9 changes: 9 additions & 0 deletions lib/config/configItems.joi.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ const probeServerJoi = joi.object({
port: joi.number().required(),
});

const probeServerPerSite = joi.array().items(
KillianG marked this conversation as resolved.
Show resolved Hide resolved
joi.object({
bindAddress: joi.string().default('localhost'),
port: joi.number().required(),
site: joi.string().required()
KillianG marked this conversation as resolved.
Show resolved Hide resolved
})
);

const mongoJoi = joi.object({
replicaSetHosts: joi.string().default('localhost:27017'),
logName: joi.string().default('s3-recordlog'),
Expand Down Expand Up @@ -161,6 +169,7 @@ module.exports = {
retryParamsJoi,
certFilePathsJoi,
probeServerJoi,
probeServerPerSite,
stsConfigJoi,
mongoJoi,
qpKafkaJoi,
Expand Down
Loading