Skip to content

Commit

Permalink
Update analyze_network.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyalbo committed Dec 10, 2024
1 parent 1a38ad5 commit 12ac3b5
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/tools/diagnostics/analyze_network.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Copyright (C) 2023 NooBaa */
'use strict';

const _ = require('lodash');
const dbg = require('../../util/debug_module')(__filename);
dbg.set_process_name('analyze_network');
const { is_hostname } = require('../../util/net_utils');
Expand All @@ -9,9 +10,11 @@ const { ManageCLIError } = require('../../manage_nsfs/manage_nsfs_cli_errors');
const { ManageCLIResponse } = require('../../manage_nsfs/manage_nsfs_cli_responses');
const { throw_cli_error, write_stdout_response } = require('../../manage_nsfs/manage_nsfs_cli_utils');
const { call_forks } = require('../../manage_nsfs/health');
const os_utils = require('../../util/os_utils');

const ANALYZE_FUNCTION_BY_SERVICE_TYPE = {
S3: analyze_s3,
S3_HTTP: analyze_s3,
S3_HTTPS: analyze_s3_secure,
STS: analyze_sts,
IAM: analyze_iam,
DB: analyze_db,
Expand Down Expand Up @@ -65,10 +68,29 @@ async function test_nc_network(config_fs) {
*
*/
async function test_network(services_info) {
const services = await os_utils.discover_k8s_services();
const [external_services, internal_services] = _.partition(services, s => s.kind === 'EXTERNAL');
const conatinerized_enabled_services = ['S3', 'STS', 'MGMT', 'DB', 'METRICS']; // IAM
for (const service of conatinerized_enabled_services) {
await analyze_service(service, services_info[service]);
for (const service_info of internal_services) {
const service_type = get_service_type(service_info);
if (service_type !== '') await analyze_service(service_type, service_info);
}
for (const service_info of external_services) {
const service_type = get_service_type(service_info);
if (service_type !== '') await analyze_service(service_type, service_info);
}
}

function get_service_type(info) {
if (info.api === 'metrics') return 'METRICS';
if (info.api === 's3') {
if (info.secure) return 'S3';
else return 'S3-HTTP';
}
if (info.api === 'postgres') return 'DB';
if (info.api === 'mgmt') return 'MGMT';
if (info.api === 'sts') return 'STS';
return '';
}

/**
Expand Down Expand Up @@ -105,6 +127,10 @@ async function analyze_s3(service_info) {

}

async function analyze_s3_secure(service_info) {

}

async function analyze_sts(service_info) {

}
Expand Down

0 comments on commit 12ac3b5

Please sign in to comment.