Skip to content

Commit

Permalink
NC | NSFS | Disable Prometheus reporting
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <[email protected]>
  • Loading branch information
shirady committed Nov 27, 2024
1 parent e5e6a35 commit d9a5361
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/cmd/nsfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class NsfsAccountSDK extends AccountSDK {
async function main(argv = minimist(process.argv.slice(2))) {
try {
config.DB_TYPE = 'none';
config.PROMETHEUS_ENABLED = false;
config.EVENT_LOGGING_ENABLED = true;
config.NSFS_VERSIONING_ENABLED = true;
// when using data buckets on noobaa standalone we should set it to true
Expand Down
3 changes: 2 additions & 1 deletion src/endpoint/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ async function main(options = {}) {
// the primary just forks and returns, workers will continue to serve
fork_count = options.forks ?? config.ENDPOINT_FORKS;
const metrics_port = options.metrics_port || config.EP_METRICS_SERVER_PORT;
if (fork_utils.start_workers(metrics_port, fork_count)) return;
const workers_were_started_from_primary = await fork_utils.start_workers(metrics_port, fork_count);
if (workers_were_started_from_primary) return;

const http_port = options.http_port || config.ENDPOINT_PORT;
const https_port = options.https_port || config.ENDPOINT_SSL_PORT;
Expand Down
8 changes: 7 additions & 1 deletion src/server/analytic_services/prometheus_reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ async function start_server(
const server = http.createServer(async (req, res) => {
// Serve all metrics on the root path for system that do have one or more fork running.
if (fork_enabled) {
const metrics = await aggregatorRegistry.clusterMetrics();
let metrics;
try {
metrics = await aggregatorRegistry.clusterMetrics();
} catch (err) {
dbg.error('start_server: Could not get the metrics, got an error', err);
return;
}
if (req.url === '' || req.url === '/') {
res.writeHead(200, { 'Content-Type': aggregatorRegistry.contentType });
res.end(metrics);
Expand Down
6 changes: 3 additions & 3 deletions src/util/fork_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const fs_workers_stats = {};
*
* @param {number?} count number of workers to start.
* @param {number?} metrics_port prometheus metris port.
* @returns {boolean} true if workers were started.
* @returns {Promise<boolean>} true if workers were started.
*/
function start_workers(metrics_port, count = 0) {
async function start_workers(metrics_port, count = 0) {
const exit_events = [];
if (cluster.isPrimary && count > 0) {
for (let i = 0; i < count; ++i) {
Expand Down Expand Up @@ -73,7 +73,7 @@ function start_workers(metrics_port, count = 0) {
}
if (metrics_port > 0) {
dbg.log0('Starting metrics server', metrics_port);
prom_reporting.start_server(metrics_port, true);
await prom_reporting.start_server(metrics_port, true);
dbg.log0('Started metrics server successfully');
}
return true;
Expand Down

0 comments on commit d9a5361

Please sign in to comment.