Skip to content

Commit

Permalink
parametrize routes based on mongo config
Browse files Browse the repository at this point in the history
Issue: BB-538
  • Loading branch information
benzekrimaha committed Nov 6, 2024
1 parent 2418cfc commit c1860dc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 48 deletions.
3 changes: 2 additions & 1 deletion lib/api/BackbeatAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ class BackbeatAPI {
const rDetails = bbRequest.getRouteDetails();
const route = bbRequest.getRoute();
const addKeys = {};
const disableAdditionalRoutes = !this._queuePopulator.mongo;

this._updateConfigSites();
const routes = getRoutesFn({
crr: this._crrSites,
ingestion: this._ingestionSites,
lifecycle: this._lifecycleSites,
});
}, disableAdditionalRoutes);

// first validate healthcheck routes or prom routes since they do not
// have rDetails set
Expand Down
99 changes: 52 additions & 47 deletions lib/api/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
* @param {Array} locations.crr - The list of replication location names
* @param {Array} locations.ingestion - The list of ingestion location names
* @param {Array} locations.lifecycle - The list of lifecycle location names
* @param {Boolean} disableAdditionalRoutes - Whether to disable additional routes
* @return {Array} The array of route objects
*/
function routes(locations) {
function routes(locations, disableAdditionalRoutes) {
/* eslint-disable no-param-reassign */
locations.crr = locations.crr || [];
locations.ingestion = locations.ingestion || [];
locations.lifecycle = locations.lifecycle || [];
/* eslint-enable no-param-reassign */

return [
const routesArray = [
// Route: /_/healthcheck
{
httpMethod: 'GET',
Expand All @@ -26,19 +26,6 @@ function routes(locations) {
method: 'getHealthcheck',
extensions: {},
},
// Route: /_/metrics/crr/<location>/pending
// Route: /_/metrics/ingestion/<location>/pending
{
httpMethod: 'GET',
category: 'metrics',
type: 'pending',
extensions: {
crr: [...locations.crr, 'all'],
ingestion: [...locations.ingestion, 'all'],
},
method: 'getPending',
dataPoints: ['opsPending', 'bytesPending'],
},
// Route: /_/metrics/crr/<location>/backlog
{
httpMethod: 'GET',
Expand All @@ -61,15 +48,6 @@ function routes(locations) {
method: 'getCompletions',
dataPoints: ['opsDone', 'bytesDone'],
},
// Route: /_/metrics/crr/<location>/failures
{
httpMethod: 'GET',
category: 'metrics',
type: 'failures',
extensions: { crr: [...locations.crr, 'all'] },
method: 'getFailedMetrics',
dataPoints: ['opsFail', 'bytesFail'],
},
// Route: /_/metrics/crr/<location>/throughput
// Route: /_/metrics/ingestion/<location>/throughput
{
Expand All @@ -96,6 +74,52 @@ function routes(locations) {
method: 'getAllMetrics',
dataPoints: ['ops', 'opsDone', 'opsFail', 'bytes', 'bytesDone',
'bytesFail', 'opsPending', 'bytesPending'],
},
// Route: /_/crr/failed?site=<site>&marker=<marker>
{
httpMethod: 'GET',
type: 'all',
extensions: { crr: ['failed'] },
method: 'getSiteFailedCRR',
},
// Route: /_/crr/failed/<bucket>/<key>/<versionId>
{
httpMethod: 'GET',
type: 'specific',
extensions: { crr: ['failed'] },
method: 'getFailedCRR',
},
// Route: /_/crr/failed
{
httpMethod: 'POST',
type: 'all',
extensions: { crr: ['failed'] },
method: 'retryFailedCRR',
},
];
if (!disableAdditionalRoutes) {
routesArray.push(
// Route: /_/metrics/crr/<location>/pending
// Route: /_/metrics/ingestion/<location>/pending
{
httpMethod: 'GET',
category: 'metrics',
type: 'pending',
extensions: {
crr: [...locations.crr, 'all'],
ingestion: [...locations.ingestion, 'all'],
},
method: 'getPending',
dataPoints: ['opsPending', 'bytesPending'],
},
// Route: /_/metrics/crr/<location>/failures
{
httpMethod: 'GET',
category: 'metrics',
type: 'failures',
extensions: { crr: [...locations.crr, 'all'] },
method: 'getFailedMetrics',
dataPoints: ['opsFail', 'bytesFail'],
},
// Route: /_/metrics/crr/<site>/progress/<bucket>/<key>
{
Expand All @@ -117,27 +141,6 @@ function routes(locations) {
method: 'getObjectThroughput',
dataPoints: ['objectBytesDone'],
},
// Route: /_/crr/failed?site=<site>&marker=<marker>
{
httpMethod: 'GET',
type: 'all',
extensions: { crr: ['failed'] },
method: 'getSiteFailedCRR',
},
// Route: /_/crr/failed/<bucket>/<key>/<versionId>
{
httpMethod: 'GET',
type: 'specific',
extensions: { crr: ['failed'] },
method: 'getFailedCRR',
},
// Route: /_/crr/failed
{
httpMethod: 'POST',
type: 'all',
extensions: { crr: ['failed'] },
method: 'retryFailedCRR',
},
// Route: /_/monitoring/metrics
{
httpMethod: 'GET',
Expand Down Expand Up @@ -222,7 +225,9 @@ function routes(locations) {
method: 'applyWorkflowConfiguration',
extensions: {},
},
];
);
}
return routesArray;
}

module.exports = routes;

0 comments on commit c1860dc

Please sign in to comment.