From 59709d4458e004e9a8b05b9218f63322ad5c42e4 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 4 Sep 2024 14:40:45 -0500 Subject: [PATCH 01/37] save Signed-off-by: Jeffrey Tang --- src/commands/flags.mjs | 12 ++++ src/commands/network.mjs | 10 ++++ src/core/constants.mjs | 2 + test/e2e/commands/node-local-hedera.test.mjs | 3 +- test/e2e/commands/node-local-ptt.test.mjs | 60 -------------------- 5 files changed, 26 insertions(+), 61 deletions(-) delete mode 100644 test/e2e/commands/node-local-ptt.test.mjs diff --git a/src/commands/flags.mjs b/src/commands/flags.mjs index a63e88d2a..3e6ead398 100644 --- a/src/commands/flags.mjs +++ b/src/commands/flags.mjs @@ -756,6 +756,17 @@ export const persistentVolumeClaims = { } } +/** @type {CommandFlag} **/ +export const debugNodeId = { + constName: 'debugNodeId', + name: 'debug-nodeid', + definition: { + describe: 'Enable default jvm debug port (5005) for the given node id', + defaultValue: '', + type: 'string' + } +} + /** @type {CommandFlag[]} **/ export const allFlags = [ accountId, @@ -796,6 +807,7 @@ export const allFlags = [ grpcEndpoints, hederaExplorerTlsHostName, hederaExplorerTlsLoadBalancerIp, + debugNodeId, keyFormat, localBuildPath, log4j2Xml, diff --git a/src/commands/network.mjs b/src/commands/network.mjs index ebdcb9f56..410bed6ab 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -74,6 +74,7 @@ export class NetworkCommand extends BaseCommand { flags.fstChartVersion, flags.hederaExplorerTlsHostName, flags.hederaExplorerTlsLoadBalancerIp, + flags.debugNodeId, flags.keyFormat, flags.log4j2Xml, flags.namespace, @@ -139,6 +140,13 @@ export class NetworkCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(config.valuesFile) } + if (config.debugNodeId) { + // get node id from nodeid + const nodeId = Templates.nodeNumberFromNodeId(config.debugNodeId) - 1 + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].name=JAVA_OPTS"` + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=*:5005"` + } + const profileName = this.configManager.getFlag(flags.profileName) this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName) if (this.profileValuesFile) { @@ -187,6 +195,7 @@ export class NetworkCommand extends BaseCommand { flags.deployMirrorNode, flags.hederaExplorerTlsLoadBalancerIp, flags.keyFormat, + flags.debugNodeId, flags.log4j2Xml, flags.persistentVolumeClaims, flags.profileName, @@ -209,6 +218,7 @@ export class NetworkCommand extends BaseCommand { * @property {string} fstChartVersion * @property {string} hederaExplorerTlsHostName * @property {string} hederaExplorerTlsLoadBalancerIp + * @property {string} debugNodeId * @property {string} keyFormat * @property {string} namespace * @property {string} nodeIDs diff --git a/src/core/constants.mjs b/src/core/constants.mjs index 66bf0c816..94a9d762e 100644 --- a/src/core/constants.mjs +++ b/src/core/constants.mjs @@ -155,3 +155,5 @@ export const ENDPOINT_TYPE_FQDN = 'FQDN' // file must be uploaded using FileUpdateTransaction in maximum of 5Kb chunks export const UPGRADE_FILE_ID = FileId.fromString('0.0.150') export const UPGRADE_FILE_CHUNK_SIZE = 1024 * 5 // 5Kb + +export const JVM_DEBUG_PORT = 5005 diff --git a/test/e2e/commands/node-local-hedera.test.mjs b/test/e2e/commands/node-local-hedera.test.mjs index 3e805a9d4..c7d29f608 100644 --- a/test/e2e/commands/node-local-hedera.test.mjs +++ b/test/e2e/commands/node-local-hedera.test.mjs @@ -37,13 +37,14 @@ describe('Node local build', () => { argv[flags.generateGossipKeys.name] = true argv[flags.generateTlsKeys.name] = true argv[flags.clusterName.name] = TEST_CLUSTER + argv[flags.debugNodeId.name] = 'node1' // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined let hederaK8 afterAll(async () => { await getNodeLogs(hederaK8, LOCAL_HEDERA) - await hederaK8.deleteNamespace(LOCAL_HEDERA) + // await hederaK8.deleteNamespace(LOCAL_HEDERA) }, 600000) describe('Node for hedera app should start successfully', () => { diff --git a/test/e2e/commands/node-local-ptt.test.mjs b/test/e2e/commands/node-local-ptt.test.mjs deleted file mode 100644 index ec47b9795..000000000 --- a/test/e2e/commands/node-local-ptt.test.mjs +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (C) 2024 Hedera Hashgraph, LLC - * - * Licensed under the Apache License, Version 2.0 (the ""License""); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an ""AS IS"" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @jest-environment steps - */ -import { - afterAll, - describe -} from '@jest/globals' -import { flags } from '../../../src/commands/index.mjs' -import { - constants -} from '../../../src/core/index.mjs' -import { - bootstrapNetwork, - getDefaultArgv, - TEST_CLUSTER -} from '../../test_util.js' -import { getNodeLogs } from '../../../src/core/helpers.mjs' - -describe('Node local build', () => { - const LOCAL_PTT = 'local-ptt-app' - const argv = getDefaultArgv() - argv[flags.keyFormat.name] = constants.KEY_FORMAT_PFX - argv[flags.nodeIDs.name] = 'node0,node1,node2' - argv[flags.generateGossipKeys.name] = true - argv[flags.generateTlsKeys.name] = true - argv[flags.clusterName.name] = TEST_CLUSTER - // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts - argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined - argv[flags.valuesFile.name] = `test/data/${LOCAL_PTT}-values.yaml` - - let pttK8 - afterAll(async () => { - await getNodeLogs(pttK8, LOCAL_PTT) - await pttK8.deleteNamespace(LOCAL_PTT) - }, 120000) - - describe('Node for platform app should start successfully', () => { - console.log('Starting local build for Platform app') - argv[flags.localBuildPath.name] = '../hedera-services/platform-sdk/sdk/data,node1=../hedera-services/platform-sdk/sdk/data,node2=../hedera-services/platform-sdk/sdk/data' - argv[flags.app.name] = 'PlatformTestingTool.jar' - argv[flags.appConfig.name] = '../hedera-services/platform-sdk/platform-apps/tests/PlatformTestingTool/src/main/resources/FCMFCQ-Basic-2.5k-5m.json' - argv[flags.namespace.name] = LOCAL_PTT - const bootstrapResp = bootstrapNetwork(LOCAL_PTT, argv) - pttK8 = bootstrapResp.opts.k8 - }) -}) From af176399f2ea97dd651bb1998926c7200b6dc32f Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 4 Sep 2024 17:36:39 -0500 Subject: [PATCH 02/37] add flags Signed-off-by: Jeffrey Tang --- src/commands/network.mjs | 9 ++------- src/commands/node.mjs | 11 +++++++++++ src/core/helpers.mjs | 15 +++++++++++++++ test/e2e/commands/node-local-hedera.test.mjs | 2 +- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/commands/network.mjs b/src/commands/network.mjs index 410bed6ab..a99f92494 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -25,7 +25,7 @@ import { constants, Templates } from '../core/index.mjs' import * as prompts from './prompts.mjs' import * as helpers from '../core/helpers.mjs' import path from 'path' -import { validatePath } from '../core/helpers.mjs' +import { addDebugOptions, validatePath } from '../core/helpers.mjs' import fs from 'fs' export class NetworkCommand extends BaseCommand { @@ -140,12 +140,7 @@ export class NetworkCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(config.valuesFile) } - if (config.debugNodeId) { - // get node id from nodeid - const nodeId = Templates.nodeNumberFromNodeId(config.debugNodeId) - 1 - valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].name=JAVA_OPTS"` - valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=*:5005"` - } + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) const profileName = this.configManager.getFlag(flags.profileName) this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index ebef82c4a..cc5c5c2f2 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -23,6 +23,7 @@ import path from 'path' import { FullstackTestingError, IllegalArgumentError } from '../core/errors.mjs' import * as helpers from '../core/helpers.mjs' import { + addDebugOptions, getNodeAccountMap, getNodeLogs, renameAndCopyFile, @@ -167,6 +168,7 @@ export class NodeCommand extends BaseCommand { flags.chainId, flags.chartDirectory, flags.devMode, + flags.debugNodeId, flags.endpointType, flags.fstChartVersion, flags.generateGossipKeys, @@ -191,6 +193,7 @@ export class NodeCommand extends BaseCommand { flags.cacheDir, flags.chartDirectory, flags.devMode, + flags.debugNodeId, flags.endpointType, flags.keyFormat, flags.localBuildPath, @@ -212,6 +215,7 @@ export class NodeCommand extends BaseCommand { flags.cacheDir, flags.chartDirectory, flags.devMode, + flags.debugNodeId, flags.endpointType, flags.fstChartVersion, flags.gossipEndpoints, @@ -1372,6 +1376,7 @@ export class NodeCommand extends BaseCommand { * @property {string} chainId * @property {string} chartDirectory * @property {boolean} devMode + * @property {string} debugNodeId * @property {string} endpointType * @property {string} fstChartVersion * @property {boolean} generateGossipKeys @@ -1766,6 +1771,7 @@ export class NodeCommand extends BaseCommand { if (this.profileValuesFile) { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, @@ -2298,6 +2304,7 @@ export class NodeCommand extends BaseCommand { * @property {string} cacheDir * @property {string} chartDirectory * @property {boolean} devMode + * @property {string} debugNodeId * @property {string} endpointType * @property {string} fstChartVersion * @property {string} gossipEndpoints @@ -2647,6 +2654,7 @@ export class NodeCommand extends BaseCommand { if (this.profileValuesFile) { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, @@ -2883,6 +2891,7 @@ export class NodeCommand extends BaseCommand { * @property {string} cacheDir * @property {string} chartDirectory * @property {boolean} devMode + * @property {string} debugNodeId * @property {string} endpointType * @property {string} fstChartVersion * @property {string} keyFormat @@ -3135,6 +3144,8 @@ export class NodeCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + await self.chartManager.upgrade( config.namespace, constants.FULLSTACK_DEPLOYMENT_CHART, diff --git a/src/core/helpers.mjs b/src/core/helpers.mjs index 5bfa0b211..c2da1e821 100644 --- a/src/core/helpers.mjs +++ b/src/core/helpers.mjs @@ -361,3 +361,18 @@ export function renameAndCopyFile (srcFilePath, expectedBaseName, destDir) { } }) } + +/** + * Add debug options to valuesArg used by helm chart + * @param valuesArg the valuesArg to update + * @param debugNodeId the node ID to attach the debugger to + * @returns updated valuesArg + */ +export function addDebugOptions (valuesArg, debugNodeId) { + if (debugNodeId) { + const nodeId = Templates.nodeNumberFromNodeId(debugNodeId) - 1 + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].name=JAVA_OPTS"` + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=n\\,address=*:5005"` + } + return valuesArg +} diff --git a/test/e2e/commands/node-local-hedera.test.mjs b/test/e2e/commands/node-local-hedera.test.mjs index c7d29f608..b000c6d86 100644 --- a/test/e2e/commands/node-local-hedera.test.mjs +++ b/test/e2e/commands/node-local-hedera.test.mjs @@ -33,7 +33,7 @@ describe('Node local build', () => { const LOCAL_HEDERA = 'local-hedera-app' const argv = getDefaultArgv() argv[flags.keyFormat.name] = constants.KEY_FORMAT_PFX - argv[flags.nodeIDs.name] = 'node0,node1,node2' + argv[flags.nodeIDs.name] = 'node1,node2,node3' argv[flags.generateGossipKeys.name] = true argv[flags.generateTlsKeys.name] = true argv[flags.clusterName.name] = TEST_CLUSTER From cee93a500866f51b0b49b80583b5a6cbc90c8e72 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 5 Sep 2024 09:40:03 -0500 Subject: [PATCH 03/37] save Signed-off-by: Jeffrey Tang --- src/commands/network.mjs | 7 +------ src/core/helpers.mjs | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/commands/network.mjs b/src/commands/network.mjs index a99f92494..ebdcb9f56 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -25,7 +25,7 @@ import { constants, Templates } from '../core/index.mjs' import * as prompts from './prompts.mjs' import * as helpers from '../core/helpers.mjs' import path from 'path' -import { addDebugOptions, validatePath } from '../core/helpers.mjs' +import { validatePath } from '../core/helpers.mjs' import fs from 'fs' export class NetworkCommand extends BaseCommand { @@ -74,7 +74,6 @@ export class NetworkCommand extends BaseCommand { flags.fstChartVersion, flags.hederaExplorerTlsHostName, flags.hederaExplorerTlsLoadBalancerIp, - flags.debugNodeId, flags.keyFormat, flags.log4j2Xml, flags.namespace, @@ -140,8 +139,6 @@ export class NetworkCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(config.valuesFile) } - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) - const profileName = this.configManager.getFlag(flags.profileName) this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName) if (this.profileValuesFile) { @@ -190,7 +187,6 @@ export class NetworkCommand extends BaseCommand { flags.deployMirrorNode, flags.hederaExplorerTlsLoadBalancerIp, flags.keyFormat, - flags.debugNodeId, flags.log4j2Xml, flags.persistentVolumeClaims, flags.profileName, @@ -213,7 +209,6 @@ export class NetworkCommand extends BaseCommand { * @property {string} fstChartVersion * @property {string} hederaExplorerTlsHostName * @property {string} hederaExplorerTlsLoadBalancerIp - * @property {string} debugNodeId * @property {string} keyFormat * @property {string} namespace * @property {string} nodeIDs diff --git a/src/core/helpers.mjs b/src/core/helpers.mjs index c2da1e821..0cfbe3988 100644 --- a/src/core/helpers.mjs +++ b/src/core/helpers.mjs @@ -372,7 +372,7 @@ export function addDebugOptions (valuesArg, debugNodeId) { if (debugNodeId) { const nodeId = Templates.nodeNumberFromNodeId(debugNodeId) - 1 valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].name=JAVA_OPTS"` - valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=n\\,address=*:5005"` + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=n\\,address=*:${constants.JVM_DEBUG_PORT}"` } return valuesArg } From 8e13fe7b305d110fc610dd775bbe53fe2e7fdcb3 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 5 Sep 2024 13:39:30 -0500 Subject: [PATCH 04/37] save Signed-off-by: Jeffrey Tang --- src/commands/flags.mjs | 2 +- src/commands/network.mjs | 6 +- src/commands/node.mjs | 193 ++++++++++++++++--------- src/core/helpers.mjs | 2 +- test/e2e/commands/node-update.test.mjs | 6 +- test_debugger.sh | 31 ++++ 6 files changed, 171 insertions(+), 69 deletions(-) create mode 100755 test_debugger.sh diff --git a/src/commands/flags.mjs b/src/commands/flags.mjs index 3e6ead398..53c1782fb 100644 --- a/src/commands/flags.mjs +++ b/src/commands/flags.mjs @@ -751,7 +751,7 @@ export const persistentVolumeClaims = { name: 'pvcs', definition: { describe: 'Enable persistent volume claims to store data outside the pod, required for node add', - defaultValue: false, + defaultValue: true, type: 'boolean' } } diff --git a/src/commands/network.mjs b/src/commands/network.mjs index ebdcb9f56..9f1bdc3a2 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -25,7 +25,7 @@ import { constants, Templates } from '../core/index.mjs' import * as prompts from './prompts.mjs' import * as helpers from '../core/helpers.mjs' import path from 'path' -import { validatePath } from '../core/helpers.mjs' +import { addDebugOptions, validatePath } from '../core/helpers.mjs' import fs from 'fs' export class NetworkCommand extends BaseCommand { @@ -74,6 +74,7 @@ export class NetworkCommand extends BaseCommand { flags.fstChartVersion, flags.hederaExplorerTlsHostName, flags.hederaExplorerTlsLoadBalancerIp, + flags.debugNodeId, flags.keyFormat, flags.log4j2Xml, flags.namespace, @@ -139,6 +140,8 @@ export class NetworkCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(config.valuesFile) } + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + const profileName = this.configManager.getFlag(flags.profileName) this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName) if (this.profileValuesFile) { @@ -183,6 +186,7 @@ export class NetworkCommand extends BaseCommand { flags.bootstrapProperties, flags.cacheDir, flags.chainId, + flags.debugNodeId, flags.deployHederaExplorer, flags.deployMirrorNode, flags.hederaExplorerTlsLoadBalancerIp, diff --git a/src/commands/node.mjs b/src/commands/node.mjs index cc5c5c2f2..47256a7e3 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -326,65 +326,70 @@ export class NodeCommand extends BaseCommand { * @returns {Promise} */ async checkNetworkNodeState (nodeId, maxAttempt = 100, status = 'ACTIVE', logfile = 'output/hgcaa.log') { - nodeId = nodeId.trim() - const podName = Templates.renderNetworkPodName(nodeId) - const logfilePath = `${constants.HEDERA_HAPI_PATH}/${logfile}` - let attempt = 0 - let isActive = false - - this.logger.debug(`Checking if node ${nodeId} is ${status}...`) - // check log file is accessible - let logFileAccessible = false - while (attempt++ < maxAttempt) { - try { - if (await this.k8.hasFile(podName, constants.ROOT_CONTAINER, logfilePath)) { - logFileAccessible = true - break - } - } catch (e) { - } // ignore errors - - await sleep(1000) - } + try { + nodeId = nodeId.trim() + const podName = Templates.renderNetworkPodName(nodeId) + const logfilePath = `${constants.HEDERA_HAPI_PATH}/${logfile}` + let attempt = 0 + let isActive = false + + this.logger.debug(`Checking if node ${nodeId} is ${status}...`) + // check log file is accessible + let logFileAccessible = false + while (attempt++ < maxAttempt) { + try { + if (await this.k8.hasFile(podName, constants.ROOT_CONTAINER, logfilePath)) { + logFileAccessible = true + break + } + } catch (e) { + this.logger.warn(`error in checking if log file is accessible: ${e.message}`) // ignore errors + } // ignore errors + + await sleep(1000) + } - if (!logFileAccessible) { - throw new FullstackTestingError(`Logs are not accessible: ${logfilePath}`) - } + if (!logFileAccessible) { + throw new FullstackTestingError(`Logs are not accessible: ${logfilePath}`) + } - attempt = 0 - while (attempt < maxAttempt) { - try { - const output = await this.k8.execContainer(podName, constants.ROOT_CONTAINER, ['tail', '-100', logfilePath]) - if (output && output.indexOf('Terminating Netty') < 0 && // make sure we are not at the beginning of a restart - (output.indexOf(`Now current platform status = ${status}`) > 0 || - output.indexOf(`Platform Status Change ${status}`) > 0 || - output.indexOf(`is ${status}`) > 0 || - output.indexOf(`"newStatus":"${status}"`) > 0)) { - this.logger.debug(`Node ${nodeId} is ${status} [ attempt: ${attempt}/${maxAttempt}]`) - isActive = true - break - } - this.logger.debug(`Node ${nodeId} is not ${status} yet. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) - } catch (e) { - this.logger.warn(`error in checking if node ${nodeId} is ${status}: ${e.message}. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) - - // ls the HAPI path for debugging - await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}`) - - // ls the output directory for debugging - await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}/output`) + attempt = 0 + while (attempt < maxAttempt) { + try { + const output = await this.k8.execContainer(podName, constants.ROOT_CONTAINER, ['tail', '-100', logfilePath]) + if (output && output.indexOf('Terminating Netty') < 0 && // make sure we are not at the beginning of a restart + (output.indexOf(`Now current platform status = ${status}`) > 0 || + output.indexOf(`Platform Status Change ${status}`) > 0 || + output.indexOf(`is ${status}`) > 0 || + output.indexOf(`"newStatus":"${status}"`) > 0)) { + this.logger.debug(`Node ${nodeId} is ${status} [ attempt: ${attempt}/${maxAttempt}]`) + isActive = true + break + } + this.logger.debug(`Node ${nodeId} is not ${status} yet. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) + } catch (e) { + this.logger.warn(`error in checking if node ${nodeId} is ${status}: ${e.message}. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) + + // ls the HAPI path for debugging + await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}`) + + // ls the output directory for debugging + await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}/output`) + } + attempt += 1 + await sleep(1000) } - attempt += 1 - await sleep(1000) - } - this.logger.info(`!> -- Node ${nodeId} is ${status} -- -- Node ${nodeId} is ${status} -- self.taskCheckNetworkNodePods(ctx, task, ctx.config.nodeIds) + title: 'Identify existing network nodes', + task: async (ctx, task) => { + const config = /** @type {NodeUpdateConfigClass} **/ ctx.config + config.existingNodeIds = [] + config.serviceMap = await self.accountManager.getNodeServiceMap( + config.namespace) + for (/** @type {NetworkNodeServices} **/ const networkNodeServices of config.serviceMap.values()) { + config.existingNodeIds.push(networkNodeServices.nodeName) + } + + config.allNodeIds = [...config.existingNodeIds] + + return self.taskCheckNetworkNodePods(ctx, task, config.existingNodeIds) + } }, + // { + // title: 'Add jvm debug options to start nodes', + // task: async (ctx, _) => { + // ctx.config.chartPath = await self.prepareChartPath(ctx.config.chartDirectory, + // constants.FULLSTACK_TESTING_CHART, constants.FULLSTACK_DEPLOYMENT_CHART) + // + // const config = ctx.config + // const podName = `network-${ctx.config.debugNodeId}-0` + // this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) + // // const forwarder = await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + // + // const index = config.existingNodeIds.length + // let valuesArg = '' + // for (let i = 0; i < index; i++) { + // valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` + // } + // + // this.profileValuesFile = await self.profileManager.prepareValuesForNodeAdd( + // path.join(config.stagingDir, 'config.txt'), + // path.join(config.stagingDir, 'templates', 'application.properties')) + // if (this.profileValuesFile) { + // valuesArg += this.prepareValuesFiles(this.profileValuesFile) + // } + // valuesArg += addDebugOptions(valuesArg, config.debugNodeId) + // + // await self.chartManager.upgrade( + // config.namespace, + // constants.FULLSTACK_DEPLOYMENT_CHART, + // config.chartPath, + // valuesArg, + // config.fstChartVersion + // ) + // }, + // skip: (ctx, _) => !ctx.config.debugNodeId + // }, { title: 'Starting nodes', task: (ctx, task) => { @@ -850,12 +903,13 @@ export class NodeCommand extends BaseCommand { // set up the sub-tasks return task.newListr(subTasks, { - concurrent: false, + concurrent: true, rendererOptions: { collapseSubtasks: false } }) - } + }, + skip: (ctx, _) => ctx.config.debugNodeId }, { title: 'Check node proxies are ACTIVE', @@ -878,7 +932,9 @@ export class NodeCommand extends BaseCommand { } }) }, - skip: (ctx, _) => self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME + skip: (ctx, _) => + (self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME) || + ctx.config.debugNodeId }, { title: 'Add node stakes', @@ -902,10 +958,12 @@ export class NodeCommand extends BaseCommand { } }) } - } - }], { - concurrent: false, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION + }, + skip: (ctx, _) => ctx.config.debugNodeId + } + ], { + concurrent: false, + rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION }) try { @@ -1359,6 +1417,7 @@ export class NodeCommand extends BaseCommand { flags.chainId, flags.chartDirectory, flags.devMode, + flags.debugNodeId, flags.endpointType, flags.fstChartVersion, flags.localBuildPath, @@ -1771,7 +1830,7 @@ export class NodeCommand extends BaseCommand { if (this.profileValuesFile) { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + valuesArg += addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, @@ -2118,6 +2177,7 @@ export class NodeCommand extends BaseCommand { desc: 'Start a node', builder: y => flags.setCommandFlags(y, flags.app, + flags.debugNodeId, flags.namespace, flags.nodeIDs ), @@ -2279,6 +2339,7 @@ export class NodeCommand extends BaseCommand { flags.app, flags.chartDirectory, flags.devMode, + flags.debugNodeId, flags.endpointType, flags.force, flags.fstChartVersion, @@ -2654,7 +2715,8 @@ export class NodeCommand extends BaseCommand { if (this.profileValuesFile) { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + + valuesArg += addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, @@ -2876,6 +2938,7 @@ export class NodeCommand extends BaseCommand { flags.chainId, flags.chartDirectory, flags.devMode, + flags.debugNodeId, flags.endpointType, flags.force, flags.fstChartVersion, @@ -3144,7 +3207,7 @@ export class NodeCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + valuesArg += addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, diff --git a/src/core/helpers.mjs b/src/core/helpers.mjs index 0cfbe3988..f9da6799f 100644 --- a/src/core/helpers.mjs +++ b/src/core/helpers.mjs @@ -372,7 +372,7 @@ export function addDebugOptions (valuesArg, debugNodeId) { if (debugNodeId) { const nodeId = Templates.nodeNumberFromNodeId(debugNodeId) - 1 valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].name=JAVA_OPTS"` - valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=n\\,address=*:${constants.JVM_DEBUG_PORT}"` + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=*:${constants.JVM_DEBUG_PORT}"` } return valuesArg } diff --git a/test/e2e/commands/node-update.test.mjs b/test/e2e/commands/node-update.test.mjs index 6eed3cc33..5787b8b05 100644 --- a/test/e2e/commands/node-update.test.mjs +++ b/test/e2e/commands/node-update.test.mjs @@ -39,6 +39,7 @@ describe('Node update', () => { argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM argv[flags.nodeIDs.name] = 'node1,node2,node3' argv[flags.nodeID.name] = updateNodeId + argv[flags.debugNodeId.name] = 'node1' argv[flags.newAccountNumber.name] = newAccountId argv[flags.newAdminKey.name] = '302e020100300506032b6570042204200cde8d512569610f184b8b399e91e46899805c6171f7c2b8666d2a417bcc66c2' @@ -61,7 +62,7 @@ describe('Node update', () => { afterAll(async () => { await getNodeLogs(k8, namespace) await nodeCmd.stop(argv) - await k8.deleteNamespace(namespace) + // await k8.deleteNamespace(namespace) }, 600000) it('cache current version of private keys', async () => { @@ -75,6 +76,9 @@ describe('Node update', () => { }, 450000) it('should update a new node property successfully', async () => { + argv[flags.localBuildPath.name] = 'node0=../hedera-services/hedera-node/data/,../hedera-services/hedera-node/data,node2=../hedera-services/hedera-node/data' + + // generate gossip and tls keys for the updated node const tmpDir = getTmpDir() diff --git a/test_debugger.sh b/test_debugger.sh new file mode 100755 index 000000000..a1743b629 --- /dev/null +++ b/test_debugger.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +./test/e2e/setup-e2e.sh + +solo network deploy -i node1,node2,node3 --debug-nodeid node2 + +solo node keys --gossip-keys --tls-keys --key-format pem + +solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data + +#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & +# + + +solo node start -i node1,node2,node3 + +kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & + +# now goto intellij and attach the debug + + +#--debug-nodeid node2 + +#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & + +#solo node add --gossip-keys --tls-keys --key-format pem --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data + +# solo node update --node-id node2 --new-account-number 0.0.7 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data + + +# start, add, update delete \ No newline at end of file From 66e36ecfbb088044dbe2f7db421667e933c76d81 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 5 Sep 2024 19:56:37 -0500 Subject: [PATCH 05/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 51 +++++++++++++++++++++++++++++++---------- test_add_debugger.sh | 17 ++++++++++++++ test_debugger.sh | 14 +++++++---- test_update_debugger.sh | 16 +++++++++++++ 4 files changed, 82 insertions(+), 16 deletions(-) create mode 100755 test_add_debugger.sh create mode 100755 test_update_debugger.sh diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 47256a7e3..2b112e0d3 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -888,14 +888,18 @@ export class NodeCommand extends BaseCommand { task: (ctx, task) => { const subTasks = [] for (const nodeId of ctx.config.nodeIds) { + let reminder = '' + if (ctx.config.debugNodeId === nodeId) { + reminder = ' Please attach JVM debugger now.' + } if (self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME) { subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, + title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, task: () => self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log') }) } else { subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, + title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, task: () => self.checkNetworkNodeState(nodeId) }) } @@ -908,8 +912,7 @@ export class NodeCommand extends BaseCommand { collapseSubtasks: false } }) - }, - skip: (ctx, _) => ctx.config.debugNodeId + } }, { title: 'Check node proxies are ACTIVE', @@ -932,9 +935,7 @@ export class NodeCommand extends BaseCommand { } }) }, - skip: (ctx, _) => - (self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME) || - ctx.config.debugNodeId + skip: (ctx, _) => self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME }, { title: 'Add node stakes', @@ -959,7 +960,6 @@ export class NodeCommand extends BaseCommand { }) } }, - skip: (ctx, _) => ctx.config.debugNodeId } ], { concurrent: false, @@ -1679,7 +1679,7 @@ export class NodeCommand extends BaseCommand { title: 'Check existing nodes staked amount', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - await sleep(60000) + await sleep(15000) const accountMap = getNodeAccountMap(config.existingNodeIds) for (const nodeId of config.existingNodeIds) { const accountId = accountMap.get(nodeId) @@ -1957,6 +1957,15 @@ export class NodeCommand extends BaseCommand { }) } }, + { + title: 'Enable port forwarding JVM', + task: async (ctx, _) => { + const podName = `network-${ctx.config.debugNodeId}-0` + this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) + await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + }, + skip: (ctx, _) => !ctx.config.debugNodeId + }, { title: 'Check all nodes are ACTIVE', task: async (ctx, task) => { @@ -1964,8 +1973,12 @@ export class NodeCommand extends BaseCommand { // sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string await sleep(30000) for (const nodeId of ctx.config.allNodeIds) { + let reminder = '' + if (ctx.config.debugNodeId === nodeId) { + reminder = ' Please attach JVM debugger now.' + } subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, + title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, task: () => self.checkNetworkNodeState(nodeId, 200) }) } @@ -2716,6 +2729,7 @@ export class NodeCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } + this.logger.info(`config.debugNodeId = ${config.debugNodeId}`) valuesArg += addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( @@ -2727,7 +2741,7 @@ export class NodeCommand extends BaseCommand { ) }, // no need to run this step if the account number is not changed, since config.txt will be the same - skip: (ctx, _) => !ctx.config.newAccountNumber + skip: (ctx, _) => !ctx.config.newAccountNumber && !ctx.config.debugNodeId }, { title: 'Kill nodes to pick up updated configMaps', @@ -2827,6 +2841,15 @@ export class NodeCommand extends BaseCommand { }) } }, + { + title: 'Enable port forwarding JVM', + task: async (ctx, _) => { + const podName = `network-${ctx.config.debugNodeId}-0` + this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) + await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + }, + skip: (ctx, _) => !ctx.config.debugNodeId + }, { title: 'Check all nodes are ACTIVE', task: async (ctx, task) => { @@ -2834,8 +2857,12 @@ export class NodeCommand extends BaseCommand { // sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string await sleep(30000) for (const nodeId of ctx.config.allNodeIds) { + let reminder = '' + if (ctx.config.debugNodeId === nodeId) { + reminder = ' Please attach JVM debugger now.' + } subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, + title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, task: () => self.checkNetworkNodeState(nodeId, 200) }) } diff --git a/test_add_debugger.sh b/test_add_debugger.sh new file mode 100755 index 000000000..7f23aa38f --- /dev/null +++ b/test_add_debugger.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +./test/e2e/setup-e2e.sh + +solo network deploy -i node1,node2,node3 + +solo node keys --gossip-keys --tls-keys --key-format pem + +solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data + + +#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & + +solo node start -i node1,node2,node3 + +solo node add --gossip-keys --tls-keys --key-format pem --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data + diff --git a/test_debugger.sh b/test_debugger.sh index a1743b629..d730b17f1 100755 --- a/test_debugger.sh +++ b/test_debugger.sh @@ -8,17 +8,23 @@ solo node keys --gossip-keys --tls-keys --key-format pem solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data -#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & -# +kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & -solo node start -i node1,node2,node3 +solo node start -i node1,node2,node3 --debug-nodeid node2 -kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & # now goto intellij and attach the debug +# solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem + + + + + + + #--debug-nodeid node2 #kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & diff --git a/test_update_debugger.sh b/test_update_debugger.sh new file mode 100755 index 000000000..22b8e3a48 --- /dev/null +++ b/test_update_debugger.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +./test/e2e/setup-e2e.sh + +solo network deploy -i node1,node2,node3 + +solo node keys --gossip-keys --tls-keys --key-format pem + +solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data + + +solo node start -i node1,node2,node3 + + +solo node update --node-id node2 --local-build-path ../hedera-services/hedera-node/data --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem + From f35489dda097946c7e74f5c16daf44c651abf3ea Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 5 Sep 2024 21:28:52 -0500 Subject: [PATCH 06/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 16 ++++++++++++++-- test/e2e/commands/node-update.test.mjs | 1 - test_delete_debugger.sh | 17 +++++++++++++++++ test_update_debugger.sh | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100755 test_delete_debugger.sh diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 2b112e0d3..12e378ec1 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -2729,7 +2729,6 @@ export class NodeCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } - this.logger.info(`config.debugNodeId = ${config.debugNodeId}`) valuesArg += addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( @@ -3335,6 +3334,15 @@ export class NodeCommand extends BaseCommand { }) } }, + { + title: 'Enable port forwarding JVM', + task: async (ctx, _) => { + const podName = `network-${ctx.config.debugNodeId}-0` + this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) + await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + }, + skip: (ctx, _) => !ctx.config.debugNodeId + }, { title: 'Check all nodes are ACTIVE', task: async (ctx, task) => { @@ -3342,8 +3350,12 @@ export class NodeCommand extends BaseCommand { // sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string await sleep(30000) for (const nodeId of ctx.config.allNodeIds) { + let reminder = '' + if (ctx.config.debugNodeId === nodeId) { + reminder = ' Please attach JVM debugger now.' + } subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, + title: `Check node: ${chalk.yellow(nodeId)}, ${chalk.red(reminder)}`, task: () => self.checkNetworkNodeState(nodeId, 200) }) } diff --git a/test/e2e/commands/node-update.test.mjs b/test/e2e/commands/node-update.test.mjs index 5787b8b05..dd42ce99f 100644 --- a/test/e2e/commands/node-update.test.mjs +++ b/test/e2e/commands/node-update.test.mjs @@ -39,7 +39,6 @@ describe('Node update', () => { argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM argv[flags.nodeIDs.name] = 'node1,node2,node3' argv[flags.nodeID.name] = updateNodeId - argv[flags.debugNodeId.name] = 'node1' argv[flags.newAccountNumber.name] = newAccountId argv[flags.newAdminKey.name] = '302e020100300506032b6570042204200cde8d512569610f184b8b399e91e46899805c6171f7c2b8666d2a417bcc66c2' diff --git a/test_delete_debugger.sh b/test_delete_debugger.sh new file mode 100755 index 000000000..ec1c962b1 --- /dev/null +++ b/test_delete_debugger.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +./test/e2e/setup-e2e.sh + +solo network deploy -i node1,node2,node3,node4 + +solo node keys --gossip-keys --tls-keys --key-format pem + +solo node setup -i node1,node2,node3,node4 --local-build-path ../hedera-services/hedera-node/data + + +#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & + +solo node start -i node1,node2,node3,node4 + +solo node delete --node-id node2 --debug-nodeid node3 + diff --git a/test_update_debugger.sh b/test_update_debugger.sh index 22b8e3a48..154c74517 100755 --- a/test_update_debugger.sh +++ b/test_update_debugger.sh @@ -12,5 +12,5 @@ solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/heder solo node start -i node1,node2,node3 -solo node update --node-id node2 --local-build-path ../hedera-services/hedera-node/data --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem +solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --new-account-number 0.0.7 --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem From e541342533e38d7e7af73c498f3726be26b4c13c Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 5 Sep 2024 21:35:02 -0500 Subject: [PATCH 07/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 147 +++++++++---------------- test/e2e/commands/node-update.test.mjs | 4 +- 2 files changed, 55 insertions(+), 96 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 12e378ec1..26a47bf4a 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -326,70 +326,66 @@ export class NodeCommand extends BaseCommand { * @returns {Promise} */ async checkNetworkNodeState (nodeId, maxAttempt = 100, status = 'ACTIVE', logfile = 'output/hgcaa.log') { - try { - nodeId = nodeId.trim() - const podName = Templates.renderNetworkPodName(nodeId) - const logfilePath = `${constants.HEDERA_HAPI_PATH}/${logfile}` - let attempt = 0 - let isActive = false - - this.logger.debug(`Checking if node ${nodeId} is ${status}...`) - // check log file is accessible - let logFileAccessible = false - while (attempt++ < maxAttempt) { - try { - if (await this.k8.hasFile(podName, constants.ROOT_CONTAINER, logfilePath)) { - logFileAccessible = true - break - } - } catch (e) { - this.logger.warn(`error in checking if log file is accessible: ${e.message}`) // ignore errors - } // ignore errors - - await sleep(1000) - } + nodeId = nodeId.trim() + const podName = Templates.renderNetworkPodName(nodeId) + const logfilePath = `${constants.HEDERA_HAPI_PATH}/${logfile}` + let attempt = 0 + let isActive = false + + this.logger.debug(`Checking if node ${nodeId} is ${status}...`) + // check log file is accessible + let logFileAccessible = false + while (attempt++ < maxAttempt) { + try { + if (await this.k8.hasFile(podName, constants.ROOT_CONTAINER, logfilePath)) { + logFileAccessible = true + break + } + } catch (e) { + this.logger.warn(`error in checking if log file is accessible: ${e.message}`) // ignore errors + } // ignore errors + + await sleep(1000) + } - if (!logFileAccessible) { - throw new FullstackTestingError(`Logs are not accessible: ${logfilePath}`) - } + if (!logFileAccessible) { + throw new FullstackTestingError(`Logs are not accessible: ${logfilePath}`) + } - attempt = 0 - while (attempt < maxAttempt) { - try { - const output = await this.k8.execContainer(podName, constants.ROOT_CONTAINER, ['tail', '-100', logfilePath]) - if (output && output.indexOf('Terminating Netty') < 0 && // make sure we are not at the beginning of a restart - (output.indexOf(`Now current platform status = ${status}`) > 0 || - output.indexOf(`Platform Status Change ${status}`) > 0 || - output.indexOf(`is ${status}`) > 0 || - output.indexOf(`"newStatus":"${status}"`) > 0)) { - this.logger.debug(`Node ${nodeId} is ${status} [ attempt: ${attempt}/${maxAttempt}]`) - isActive = true - break - } - this.logger.debug(`Node ${nodeId} is not ${status} yet. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) - } catch (e) { - this.logger.warn(`error in checking if node ${nodeId} is ${status}: ${e.message}. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) - - // ls the HAPI path for debugging - await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}`) - - // ls the output directory for debugging - await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}/output`) - } - attempt += 1 - await sleep(1000) + attempt = 0 + while (attempt < maxAttempt) { + try { + const output = await this.k8.execContainer(podName, constants.ROOT_CONTAINER, ['tail', '-100', logfilePath]) + if (output && output.indexOf('Terminating Netty') < 0 && // make sure we are not at the beginning of a restart + (output.indexOf(`Now current platform status = ${status}`) > 0 || + output.indexOf(`Platform Status Change ${status}`) > 0 || + output.indexOf(`is ${status}`) > 0 || + output.indexOf(`"newStatus":"${status}"`) > 0)) { + this.logger.debug(`Node ${nodeId} is ${status} [ attempt: ${attempt}/${maxAttempt}]`) + isActive = true + break + } + this.logger.debug(`Node ${nodeId} is not ${status} yet. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) + } catch (e) { + this.logger.warn(`error in checking if node ${nodeId} is ${status}: ${e.message}. Trying again... [ attempt: ${attempt}/${maxAttempt} ]`) + + // ls the HAPI path for debugging + await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}`) + + // ls the output directory for debugging + await this.k8.execContainer(podName, constants.ROOT_CONTAINER, `ls -la ${constants.HEDERA_HAPI_PATH}/output`) } + attempt += 1 + await sleep(1000) + } - this.logger.info(`!> -- Node ${nodeId} is ${status} -- -- Node ${nodeId} is ${status} -- { - // ctx.config.chartPath = await self.prepareChartPath(ctx.config.chartDirectory, - // constants.FULLSTACK_TESTING_CHART, constants.FULLSTACK_DEPLOYMENT_CHART) - // - // const config = ctx.config - // const podName = `network-${ctx.config.debugNodeId}-0` - // this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) - // // const forwarder = await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) - // - // const index = config.existingNodeIds.length - // let valuesArg = '' - // for (let i = 0; i < index; i++) { - // valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` - // } - // - // this.profileValuesFile = await self.profileManager.prepareValuesForNodeAdd( - // path.join(config.stagingDir, 'config.txt'), - // path.join(config.stagingDir, 'templates', 'application.properties')) - // if (this.profileValuesFile) { - // valuesArg += this.prepareValuesFiles(this.profileValuesFile) - // } - // valuesArg += addDebugOptions(valuesArg, config.debugNodeId) - // - // await self.chartManager.upgrade( - // config.namespace, - // constants.FULLSTACK_DEPLOYMENT_CHART, - // config.chartPath, - // valuesArg, - // config.fstChartVersion - // ) - // }, - // skip: (ctx, _) => !ctx.config.debugNodeId - // }, { title: 'Starting nodes', task: (ctx, task) => { diff --git a/test/e2e/commands/node-update.test.mjs b/test/e2e/commands/node-update.test.mjs index 9d5c171c0..6eed3cc33 100644 --- a/test/e2e/commands/node-update.test.mjs +++ b/test/e2e/commands/node-update.test.mjs @@ -61,7 +61,7 @@ describe('Node update', () => { afterAll(async () => { await getNodeLogs(k8, namespace) await nodeCmd.stop(argv) - // await k8.deleteNamespace(namespace) + await k8.deleteNamespace(namespace) }, 600000) it('cache current version of private keys', async () => { @@ -75,8 +75,6 @@ describe('Node update', () => { }, 450000) it('should update a new node property successfully', async () => { - - // generate gossip and tls keys for the updated node const tmpDir = getTmpDir() From d01c0b680e0318b4aea65a5d23f387704ab9ffa8 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Thu, 5 Sep 2024 21:37:03 -0500 Subject: [PATCH 08/37] format check Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 26a47bf4a..1ea3e2e3c 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -797,7 +797,7 @@ export class NodeCommand extends BaseCommand { ctx.config = { app: self.configManager.getFlag(flags.app), cacheDir: self.configManager.getFlag(flags.cacheDir), - debugNodeId : self.configManager.getFlag(flags.debugNodeId), + debugNodeId: self.configManager.getFlag(flags.debugNodeId), namespace: self.configManager.getFlag(flags.namespace), nodeIds: helpers.parseNodeIds(self.configManager.getFlag(flags.nodeIDs)) } @@ -920,11 +920,10 @@ export class NodeCommand extends BaseCommand { } }) } - }, - } - ], { - concurrent: false, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION + } + }], { + concurrent: false, + rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION }) try { From b779c6bfa2238a55b9f0b9a1ebb8105ce84f41ad Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Fri, 6 Sep 2024 09:04:40 -0500 Subject: [PATCH 09/37] revert Signed-off-by: Jeffrey Tang --- test/e2e/commands/node-local-hedera.test.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/commands/node-local-hedera.test.mjs b/test/e2e/commands/node-local-hedera.test.mjs index 87070df56..290a7390a 100644 --- a/test/e2e/commands/node-local-hedera.test.mjs +++ b/test/e2e/commands/node-local-hedera.test.mjs @@ -37,14 +37,13 @@ describe('Node local build', () => { argv[flags.generateGossipKeys.name] = true argv[flags.generateTlsKeys.name] = true argv[flags.clusterName.name] = TEST_CLUSTER - argv[flags.debugNodeId.name] = 'node1' // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined let hederaK8 afterAll(async () => { await getNodeLogs(hederaK8, LOCAL_HEDERA) - // await hederaK8.deleteNamespace(LOCAL_HEDERA) + await hederaK8.deleteNamespace(LOCAL_HEDERA) }, 600000) describe('Node for hedera app should start successfully', () => { From 94e733030d0196428e343557e4fea1757ca58185 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Fri, 6 Sep 2024 09:55:00 -0500 Subject: [PATCH 10/37] refactor Signed-off-by: Jeffrey Tang --- src/commands/flags.mjs | 2 +- src/commands/node.mjs | 31 +++++++++++++++++++------------ test_add_debugger.sh | 2 +- test_debugger.sh | 27 ++------------------------- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/commands/flags.mjs b/src/commands/flags.mjs index 53c1782fb..3e6ead398 100644 --- a/src/commands/flags.mjs +++ b/src/commands/flags.mjs @@ -751,7 +751,7 @@ export const persistentVolumeClaims = { name: 'pvcs', definition: { describe: 'Enable persistent volume claims to store data outside the pod, required for node add', - defaultValue: true, + defaultValue: false, type: 'boolean' } } diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 1ea3e2e3c..d1642ffa4 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -844,6 +844,13 @@ export class NodeCommand extends BaseCommand { }) } }, + { + title: 'Enable port forwarding for JVM debugger', + task: async (ctx, _) => { + await this.enableJVMPortForwarding(ctx.config.debugNodeId) + }, + skip: (ctx, _) => !ctx.config.debugNodeId + }, { title: 'Check nodes are ACTIVE', task: (ctx, task) => { @@ -1918,11 +1925,9 @@ export class NodeCommand extends BaseCommand { } }, { - title: 'Enable port forwarding JVM', + title: 'Enable port forwarding for JVM debugger', task: async (ctx, _) => { - const podName = `network-${ctx.config.debugNodeId}-0` - this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) - await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + await this.enableJVMPortForwarding(ctx.config.debugNodeId) }, skip: (ctx, _) => !ctx.config.debugNodeId }, @@ -2096,6 +2101,12 @@ export class NodeCommand extends BaseCommand { } } + async enableJVMPortForwarding (nodeId) { + const podName = `network-${nodeId}-0` + this.logger.debug(`Enable port forwarding for JVM debugger on pod ${podName}`) + await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + } + /** * @param {Object} podNames * @param {string} nodeIds @@ -2801,11 +2812,9 @@ export class NodeCommand extends BaseCommand { } }, { - title: 'Enable port forwarding JVM', + title: 'Enable port forwarding for JVM debugger', task: async (ctx, _) => { - const podName = `network-${ctx.config.debugNodeId}-0` - this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) - await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + await this.enableJVMPortForwarding(ctx.config.debugNodeId) }, skip: (ctx, _) => !ctx.config.debugNodeId }, @@ -3295,11 +3304,9 @@ export class NodeCommand extends BaseCommand { } }, { - title: 'Enable port forwarding JVM', + title: 'Enable port forwarding for JVM debugger', task: async (ctx, _) => { - const podName = `network-${ctx.config.debugNodeId}-0` - this.logger.debug(`Enable port forwarding for JVM debugger on node ${podName}`) - await this.k8.portForward(podName, constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT) + await this.enableJVMPortForwarding(ctx.config.debugNodeId) }, skip: (ctx, _) => !ctx.config.debugNodeId }, diff --git a/test_add_debugger.sh b/test_add_debugger.sh index 7f23aa38f..1812273ae 100755 --- a/test_add_debugger.sh +++ b/test_add_debugger.sh @@ -2,7 +2,7 @@ ./test/e2e/setup-e2e.sh -solo network deploy -i node1,node2,node3 +solo network deploy -i node1,node2,node3 --pvcs solo node keys --gossip-keys --tls-keys --key-format pem diff --git a/test_debugger.sh b/test_debugger.sh index d730b17f1..eeed86d16 100755 --- a/test_debugger.sh +++ b/test_debugger.sh @@ -4,34 +4,11 @@ solo network deploy -i node1,node2,node3 --debug-nodeid node2 -solo node keys --gossip-keys --tls-keys --key-format pem +solo node keys --gossip-keys --tls-keys solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data - -kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & - -solo node start -i node1,node2,node3 --debug-nodeid node2 - - -# now goto intellij and attach the debug - - -# solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem - - - - - - - -#--debug-nodeid node2 - #kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & -#solo node add --gossip-keys --tls-keys --key-format pem --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data - -# solo node update --node-id node2 --new-account-number 0.0.7 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data - +solo node start -i node1,node2,node3 --debug-nodeid node2 -# start, add, update delete \ No newline at end of file From 4034ef64658403320a97274801aed96eb59ca517 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Fri, 6 Sep 2024 10:13:14 -0500 Subject: [PATCH 11/37] save Signed-off-by: Jeffrey Tang --- README.md.template | 49 +++++++++++++++++++++++++++++++++++++++++ src/commands/node.mjs | 1 - test_add_debugger.sh | 7 ++---- test_debugger.sh | 2 -- test_delete_debugger.sh | 5 +---- test_update_debugger.sh | 2 +- 6 files changed, 53 insertions(+), 13 deletions(-) diff --git a/README.md.template b/README.md.template index 2330c621e..697033b0f 100644 --- a/README.md.template +++ b/README.md.template @@ -378,6 +378,55 @@ You can find log for running solo command under the directory `~/.solo/logs/` The file `solo.log` contains the logs for the solo command. The file `hashgraph-sdk.log` contains the logs from solo client when sending transactions to network nodes. +## Using Intellj remote debug with solo + +Example 1: attach jvm debugger to a hedera node +```bash +./test/e2e/setup-e2e.sh +solo network deploy -i node1,node2,node3 --debug-nodeid node2 +solo node keys --gossip-keys --tls-keys +solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data +solo node start -i node1,node2,node3 --debug-nodeid node2 +``` + +Once you see the following message, you can launch jvm debugger from Intellij +``` +❯ Check all nodes are ACTIVE + Check node: node1, + Check node: node3, Please attach JVM debugger now. + Check node: node4, +``` + +Example 2: attach jvm debugger with node add operation + +```bash +./test/e2e/setup-e2e.sh +solo network deploy -i node1,node2,node3 --pvcs +solo node keys --gossip-keys --tls-keys +solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data +solo node start -i node1,node2,node3 +solo node add --gossip-keys --tls-keys --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data +``` + +Example 3: attach jvm debugger with node update operation +```bash +./test/e2e/setup-e2e.sh +solo network deploy -i node1,node2,node3 +solo node keys --gossip-keys --tls-keys +solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data +solo node start -i node1,node2,node3 +solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --new-account-number 0.0.7 --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem +``` + +Example 4: attach jvm debugger with node delete operation +```bash +./test/e2e/setup-e2e.sh +solo network deploy -i node1,node2,node3,node4 +solo node keys --gossip-keys --tls-keys +solo node setup -i node1,node2,node3,node4 --local-build-path ../hedera-services/hedera-node/data +solo node start -i node1,node2,node3,node4 +solo node delete --node-id node2 --debug-nodeid node3 +``` ## Support diff --git a/src/commands/node.mjs b/src/commands/node.mjs index d1642ffa4..cc57a39ae 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -342,7 +342,6 @@ export class NodeCommand extends BaseCommand { break } } catch (e) { - this.logger.warn(`error in checking if log file is accessible: ${e.message}`) // ignore errors } // ignore errors await sleep(1000) diff --git a/test_add_debugger.sh b/test_add_debugger.sh index 1812273ae..eb538ed39 100755 --- a/test_add_debugger.sh +++ b/test_add_debugger.sh @@ -4,14 +4,11 @@ solo network deploy -i node1,node2,node3 --pvcs -solo node keys --gossip-keys --tls-keys --key-format pem +solo node keys --gossip-keys --tls-keys solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data - -#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & - solo node start -i node1,node2,node3 -solo node add --gossip-keys --tls-keys --key-format pem --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data +solo node add --gossip-keys --tls-keys --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data diff --git a/test_debugger.sh b/test_debugger.sh index eeed86d16..5de8d4dbb 100755 --- a/test_debugger.sh +++ b/test_debugger.sh @@ -8,7 +8,5 @@ solo node keys --gossip-keys --tls-keys solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data -#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & - solo node start -i node1,node2,node3 --debug-nodeid node2 diff --git a/test_delete_debugger.sh b/test_delete_debugger.sh index ec1c962b1..dc801e0ca 100755 --- a/test_delete_debugger.sh +++ b/test_delete_debugger.sh @@ -4,13 +4,10 @@ solo network deploy -i node1,node2,node3,node4 -solo node keys --gossip-keys --tls-keys --key-format pem +solo node keys --gossip-keys --tls-keys solo node setup -i node1,node2,node3,node4 --local-build-path ../hedera-services/hedera-node/data - -#kubectl port-forward network-node2-0 -n solo-e2e 5005:5005 & - solo node start -i node1,node2,node3,node4 solo node delete --node-id node2 --debug-nodeid node3 diff --git a/test_update_debugger.sh b/test_update_debugger.sh index 154c74517..bd4ea1636 100755 --- a/test_update_debugger.sh +++ b/test_update_debugger.sh @@ -4,7 +4,7 @@ solo network deploy -i node1,node2,node3 -solo node keys --gossip-keys --tls-keys --key-format pem +solo node keys --gossip-keys --tls-keys solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data From 9fb0e5a188f9833f6e74a14f3fb0c8e93bffe376 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Fri, 6 Sep 2024 10:13:50 -0500 Subject: [PATCH 12/37] save Signed-off-by: Jeffrey Tang --- test_add_debugger.sh | 14 -------------- test_debugger.sh | 12 ------------ test_delete_debugger.sh | 14 -------------- test_update_debugger.sh | 16 ---------------- 4 files changed, 56 deletions(-) delete mode 100755 test_add_debugger.sh delete mode 100755 test_debugger.sh delete mode 100755 test_delete_debugger.sh delete mode 100755 test_update_debugger.sh diff --git a/test_add_debugger.sh b/test_add_debugger.sh deleted file mode 100755 index eb538ed39..000000000 --- a/test_add_debugger.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -./test/e2e/setup-e2e.sh - -solo network deploy -i node1,node2,node3 --pvcs - -solo node keys --gossip-keys --tls-keys - -solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data - -solo node start -i node1,node2,node3 - -solo node add --gossip-keys --tls-keys --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data - diff --git a/test_debugger.sh b/test_debugger.sh deleted file mode 100755 index 5de8d4dbb..000000000 --- a/test_debugger.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -./test/e2e/setup-e2e.sh - -solo network deploy -i node1,node2,node3 --debug-nodeid node2 - -solo node keys --gossip-keys --tls-keys - -solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data - -solo node start -i node1,node2,node3 --debug-nodeid node2 - diff --git a/test_delete_debugger.sh b/test_delete_debugger.sh deleted file mode 100755 index dc801e0ca..000000000 --- a/test_delete_debugger.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -./test/e2e/setup-e2e.sh - -solo network deploy -i node1,node2,node3,node4 - -solo node keys --gossip-keys --tls-keys - -solo node setup -i node1,node2,node3,node4 --local-build-path ../hedera-services/hedera-node/data - -solo node start -i node1,node2,node3,node4 - -solo node delete --node-id node2 --debug-nodeid node3 - diff --git a/test_update_debugger.sh b/test_update_debugger.sh deleted file mode 100755 index bd4ea1636..000000000 --- a/test_update_debugger.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -./test/e2e/setup-e2e.sh - -solo network deploy -i node1,node2,node3 - -solo node keys --gossip-keys --tls-keys - -solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data - - -solo node start -i node1,node2,node3 - - -solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --new-account-number 0.0.7 --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem - From 0684d6fb5515b670c1c8c85d596d8632d14bfcbe Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Sat, 7 Sep 2024 17:43:30 -0500 Subject: [PATCH 13/37] save Signed-off-by: Jeffrey Tang --- src/commands/network.mjs | 12 +++++++++++- src/commands/node.mjs | 10 ++++++---- src/core/helpers.mjs | 6 +++--- test/e2e/commands/network.test.mjs | 1 - test/e2e/commands/node-local-ptt.test.mjs | 1 - 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/commands/network.mjs b/src/commands/network.mjs index 9f1bdc3a2..9a1322cb3 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -140,7 +140,17 @@ export class NetworkCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(config.valuesFile) } - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + + if (config.app !== constants.HEDERA_APP_NAME) { + const index = config.nodeIds.length + for (let i = 0; i < index; i++) { + valuesArg += ` --set "hedera.nodes[${i}].root.extraEnv[0].name=JAVA_MAIN_CLASS"` + valuesArg += ` --set "hedera.nodes[${i}].root.extraEnv[0].value=com.swirlds.platform.Browser"` + } + valuesArg = addDebugOptions(valuesArg, config.debugNodeId, 1) + } else { + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + } const profileName = this.configManager.getFlag(flags.profileName) this.profileValuesFile = await this.profileManager.prepareValuesForFstChart(profileName) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index cc57a39ae..7d9c9717b 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -98,6 +98,7 @@ export class NodeCommand extends BaseCommand { */ static get SETUP_FLAGS_LIST () { return [ + flags.app, flags.appConfig, flags.cacheDir, flags.devMode, @@ -684,6 +685,7 @@ export class NodeCommand extends BaseCommand { // disable the prompts that we don't want to prompt the user for prompts.disablePrompts([ + flags.app, flags.appConfig, flags.devMode, flags.localBuildPath @@ -1260,7 +1262,7 @@ export class NodeCommand extends BaseCommand { const config = /** @type {NodeRefreshConfigClass} **/ ctx.config const subTasks = [] for (const nodeId of ctx.config.nodeIds) { - if (config.app !== '' && config.app !== constants.HEDERA_APP_NAME) { + if (config.app !== constants.HEDERA_APP_NAME) { subTasks.push({ title: `Check node: ${chalk.yellow(nodeId)}`, task: () => self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log') @@ -1796,7 +1798,7 @@ export class NodeCommand extends BaseCommand { if (this.profileValuesFile) { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } - valuesArg += addDebugOptions(valuesArg, config.debugNodeId) + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, @@ -2699,7 +2701,7 @@ export class NodeCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } - valuesArg += addDebugOptions(valuesArg, config.debugNodeId) + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, @@ -3201,7 +3203,7 @@ export class NodeCommand extends BaseCommand { valuesArg += this.prepareValuesFiles(this.profileValuesFile) } - valuesArg += addDebugOptions(valuesArg, config.debugNodeId) + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) await self.chartManager.upgrade( config.namespace, diff --git a/src/core/helpers.mjs b/src/core/helpers.mjs index f9da6799f..429cac212 100644 --- a/src/core/helpers.mjs +++ b/src/core/helpers.mjs @@ -368,11 +368,11 @@ export function renameAndCopyFile (srcFilePath, expectedBaseName, destDir) { * @param debugNodeId the node ID to attach the debugger to * @returns updated valuesArg */ -export function addDebugOptions (valuesArg, debugNodeId) { +export function addDebugOptions (valuesArg, debugNodeId, index = 0) { if (debugNodeId) { const nodeId = Templates.nodeNumberFromNodeId(debugNodeId) - 1 - valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].name=JAVA_OPTS"` - valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[0].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=*:${constants.JVM_DEBUG_PORT}"` + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[${index}].name=JAVA_OPTS"` + valuesArg += ` --set "hedera.nodes[${nodeId}].root.extraEnv[${index}].value=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=*:${constants.JVM_DEBUG_PORT}"` } return valuesArg } diff --git a/test/e2e/commands/network.test.mjs b/test/e2e/commands/network.test.mjs index 6c299f626..45b31fa6f 100644 --- a/test/e2e/commands/network.test.mjs +++ b/test/e2e/commands/network.test.mjs @@ -95,7 +95,6 @@ describe('NetworkCommand', () => { expect(networkCmd.getUnusedConfigs(NetworkCommand.DEPLOY_CONFIGS_NAME)).toEqual([ flags.apiPermissionProperties.constName, - flags.app.constName, flags.applicationEnv.constName, flags.applicationProperties.constName, flags.bootstrapProperties.constName, diff --git a/test/e2e/commands/node-local-ptt.test.mjs b/test/e2e/commands/node-local-ptt.test.mjs index 9199bbd4a..5534a1cc0 100644 --- a/test/e2e/commands/node-local-ptt.test.mjs +++ b/test/e2e/commands/node-local-ptt.test.mjs @@ -40,7 +40,6 @@ describe('Node local build', () => { argv[flags.clusterName.name] = TEST_CLUSTER // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined - argv[flags.valuesFile.name] = `test/data/${LOCAL_PTT}-values.yaml` let pttK8 afterAll(async () => { From 3522f13de16877e824f243251c6a65d7348ffe0a Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Sat, 7 Sep 2024 17:52:21 -0500 Subject: [PATCH 14/37] save Signed-off-by: Jeffrey Tang --- test/test_util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_util.js b/test/test_util.js index b0f4681c4..0126e3ecc 100644 --- a/test/test_util.js +++ b/test/test_util.js @@ -234,7 +234,6 @@ export function bootstrapNetwork (testName, argv, expect(networkCmd.getUnusedConfigs(NetworkCommand.DEPLOY_CONFIGS_NAME)).toEqual([ flags.apiPermissionProperties.constName, - flags.app.constName, flags.applicationEnv.constName, flags.applicationProperties.constName, flags.bootstrapProperties.constName, @@ -258,6 +257,7 @@ export function bootstrapNetwork (testName, argv, try { await expect(nodeCmd.setup(argv)).resolves.toBeTruthy() expect(nodeCmd.getUnusedConfigs(NodeCommand.SETUP_CONFIGS_NAME)).toEqual([ + flags.app.constName, flags.appConfig.constName, flags.devMode.constName ]) From 00bf06b6b461ee071efdaaa8ac23e6647c3256d5 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Sat, 7 Sep 2024 17:53:19 -0500 Subject: [PATCH 15/37] check Signed-off-by: Jeffrey Tang --- src/commands/network.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commands/network.mjs b/src/commands/network.mjs index 9a1322cb3..202bb82d7 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -139,8 +139,7 @@ export class NetworkCommand extends BaseCommand { if (config.valuesFile) { valuesArg += this.prepareValuesFiles(config.valuesFile) } - - + if (config.app !== constants.HEDERA_APP_NAME) { const index = config.nodeIds.length for (let i = 0; i < index; i++) { From 7715c47ad906414c82ca519245480fd95799eda0 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Sat, 7 Sep 2024 18:01:17 -0500 Subject: [PATCH 16/37] check Signed-off-by: Jeffrey Tang --- src/commands/network.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/network.mjs b/src/commands/network.mjs index 202bb82d7..dec451c18 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -139,7 +139,7 @@ export class NetworkCommand extends BaseCommand { if (config.valuesFile) { valuesArg += this.prepareValuesFiles(config.valuesFile) } - + if (config.app !== constants.HEDERA_APP_NAME) { const index = config.nodeIds.length for (let i = 0; i < index; i++) { From 4cee5e7b3f56214ed20019536a35d5bedc8a06b4 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Sat, 7 Sep 2024 19:31:32 -0500 Subject: [PATCH 17/37] check Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 10 +++++----- src/core/helpers.mjs | 1 + test/data/local-ptt-app-values.yaml | 5 ----- 3 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 test/data/local-ptt-app-values.yaml diff --git a/src/commands/node.mjs b/src/commands/node.mjs index d97745106..47c91c392 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -864,12 +864,12 @@ export class NodeCommand extends BaseCommand { if (self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME) { subTasks.push({ title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log') + task: async () => await self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log') }) } else { subTasks.push({ title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => self.checkNetworkNodeState(nodeId) + task: async () => await self.checkNetworkNodeState(nodeId) }) } } @@ -1946,7 +1946,7 @@ export class NodeCommand extends BaseCommand { } subTasks.push({ title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => self.checkNetworkNodeState(nodeId, 200) + task: async () => await self.checkNetworkNodeState(nodeId, 200) }) } @@ -2833,7 +2833,7 @@ export class NodeCommand extends BaseCommand { } subTasks.push({ title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => self.checkNetworkNodeState(nodeId, 200) + task: async () => await self.checkNetworkNodeState(nodeId, 200) }) } @@ -3326,7 +3326,7 @@ export class NodeCommand extends BaseCommand { } subTasks.push({ title: `Check node: ${chalk.yellow(nodeId)}, ${chalk.red(reminder)}`, - task: async () => self.checkNetworkNodeState(nodeId, 200) + task: async () => await self.checkNetworkNodeState(nodeId, 200) }) } diff --git a/src/core/helpers.mjs b/src/core/helpers.mjs index 429cac212..d0bbdab68 100644 --- a/src/core/helpers.mjs +++ b/src/core/helpers.mjs @@ -366,6 +366,7 @@ export function renameAndCopyFile (srcFilePath, expectedBaseName, destDir) { * Add debug options to valuesArg used by helm chart * @param valuesArg the valuesArg to update * @param debugNodeId the node ID to attach the debugger to + * @param index the index of extraEnv to add the debug options to * @returns updated valuesArg */ export function addDebugOptions (valuesArg, debugNodeId, index = 0) { diff --git a/test/data/local-ptt-app-values.yaml b/test/data/local-ptt-app-values.yaml deleted file mode 100644 index 808dfca8e..000000000 --- a/test/data/local-ptt-app-values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -defaults: - root: - extraEnv: - - name: JAVA_MAIN_CLASS - value: com.swirlds.platform.Browser From c4ec36492d96b0c0b316dbb5af3c5c82ab274793 Mon Sep 17 00:00:00 2001 From: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:07:12 -0500 Subject: [PATCH 18/37] Update README.md.template Co-authored-by: Jeromy Cannon Signed-off-by: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> --- README.md.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md.template b/README.md.template index e1c62825c..694cbfc16 100644 --- a/README.md.template +++ b/README.md.template @@ -420,8 +420,8 @@ solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hed Example 4: attach jvm debugger with node delete operation ```bash ./test/e2e/setup-e2e.sh -solo network deploy -i node1,node2,node3,node4 solo node keys --gossip-keys --tls-keys +solo network deploy -i node1,node2,node3,node4 solo node setup -i node1,node2,node3,node4 --local-build-path ../hedera-services/hedera-node/data solo node start -i node1,node2,node3,node4 solo node delete --node-id node2 --debug-nodeid node3 From 4e4980949753f9bc1389fd3bc54c26bbdddb388f Mon Sep 17 00:00:00 2001 From: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:07:25 -0500 Subject: [PATCH 19/37] Update README.md.template Co-authored-by: Jeromy Cannon Signed-off-by: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> --- README.md.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md.template b/README.md.template index 694cbfc16..7f27932de 100644 --- a/README.md.template +++ b/README.md.template @@ -410,8 +410,8 @@ solo node add --gossip-keys --tls-keys --node-id node4 --debug-nodeid node4 --lo Example 3: attach jvm debugger with node update operation ```bash ./test/e2e/setup-e2e.sh -solo network deploy -i node1,node2,node3 solo node keys --gossip-keys --tls-keys +solo network deploy -i node1,node2,node3 solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data solo node start -i node1,node2,node3 solo node update --node-id node2 --debug-nodeid node2 --local-build-path ../hedera-services/hedera-node/data --new-account-number 0.0.7 --gossip-public-key ./s-public-node2.pem --gossip-private-key ./s-private-node2.pem --agreement-public-key ./a-public-node2.pem --agreement-private-key ./a-private-node2.pem From 76b0630e1e3a78000f1c9e3888aa20d124c45198 Mon Sep 17 00:00:00 2001 From: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:07:33 -0500 Subject: [PATCH 20/37] Update README.md.template Co-authored-by: Jeromy Cannon Signed-off-by: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> --- README.md.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md.template b/README.md.template index 7f27932de..24463fdfd 100644 --- a/README.md.template +++ b/README.md.template @@ -400,8 +400,8 @@ Example 2: attach jvm debugger with node add operation ```bash ./test/e2e/setup-e2e.sh -solo network deploy -i node1,node2,node3 --pvcs solo node keys --gossip-keys --tls-keys +solo network deploy -i node1,node2,node3 --pvcs solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data solo node start -i node1,node2,node3 solo node add --gossip-keys --tls-keys --node-id node4 --debug-nodeid node4 --local-build-path ../hedera-services/hedera-node/data From 9f3a38c6fc3984dd7eca6c94703630672501c670 Mon Sep 17 00:00:00 2001 From: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:07:59 -0500 Subject: [PATCH 21/37] Update README.md.template Co-authored-by: Jeromy Cannon Signed-off-by: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> --- README.md.template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md.template b/README.md.template index 24463fdfd..5b812ae59 100644 --- a/README.md.template +++ b/README.md.template @@ -379,6 +379,8 @@ The file `hashgraph-sdk.log` contains the logs from solo client when sending tra ## Using Intellj remote debug with solo +NOTE: the hedera-services path referenced '../hedera-services/hedera-node/data' may need to be updated based on what directory you are currently in. This also assumes that you have done an assemble/build and the directory contents are up-to-date. + Example 1: attach jvm debugger to a hedera node ```bash ./test/e2e/setup-e2e.sh From 5fb784c37e57c8a436356fd3d8bab1028ed2874b Mon Sep 17 00:00:00 2001 From: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:08:12 -0500 Subject: [PATCH 22/37] Update README.md.template Co-authored-by: Jeromy Cannon Signed-off-by: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> --- README.md.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md.template b/README.md.template index 5b812ae59..380d66f0f 100644 --- a/README.md.template +++ b/README.md.template @@ -384,8 +384,8 @@ NOTE: the hedera-services path referenced '../hedera-services/hedera-node/data' Example 1: attach jvm debugger to a hedera node ```bash ./test/e2e/setup-e2e.sh -solo network deploy -i node1,node2,node3 --debug-nodeid node2 solo node keys --gossip-keys --tls-keys +solo network deploy -i node1,node2,node3 --debug-nodeid node2 solo node setup -i node1,node2,node3 --local-build-path ../hedera-services/hedera-node/data solo node start -i node1,node2,node3 --debug-nodeid node2 ``` From d72ab4c25a75e9b5b5dda6cec66eb2127a2341cd Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 09:53:52 -0500 Subject: [PATCH 23/37] fix: jsdoc errors Signed-off-by: Jeffrey Tang --- src/commands/index.mjs | 2 +- src/commands/init.mjs | 2 +- src/commands/node.mjs | 14 +++++++------- src/commands/relay.mjs | 2 +- src/core/constants.mjs | 2 +- .../dependency_managers/dependency_manager.mjs | 6 +++--- src/core/k8.mjs | 4 ++-- src/core/platform_installer.mjs | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/commands/index.mjs b/src/commands/index.mjs index 255df9f9e..a181b6404 100644 --- a/src/commands/index.mjs +++ b/src/commands/index.mjs @@ -27,7 +27,7 @@ import * as flags from './flags.mjs' /** * Return a list of Yargs command builder to be exposed through CLI * @param {Object} opts it is an Options object containing logger - * @returns {Array<{command: string, desc: string, builder: Function, handler?: Function}[]>} + * @returns {Array} an array of Yargs command builder */ function Initialize (opts) { const initCmd = new InitCommand(opts) diff --git a/src/commands/init.mjs b/src/commands/init.mjs index ceb9b8509..e52d12215 100644 --- a/src/commands/init.mjs +++ b/src/commands/init.mjs @@ -145,7 +145,7 @@ export class InitCommand extends BaseCommand { /** * Return Yargs command definition for 'init' command * @param {InitCommand} initCmd - an instance of InitCommand - * @returns {{command: string, desc: string, builder: Function, handler: (argv: Object) => void}} + * @returns A object representing the Yargs command definition */ static getCommandDefinition (initCmd) { if (!initCmd || !(initCmd instanceof InitCommand)) { diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 58cf62603..ea7ea4867 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -382,7 +382,7 @@ export class NodeCommand extends BaseCommand { /** * Return task for checking for all network node pods * @param {any} ctx - * @param {typeof import('listr2').TaskWrapper} task + * @param {TaskWrapper} task * @param {string[]} nodeIds * @returns {*} */ @@ -439,7 +439,7 @@ export class NodeCommand extends BaseCommand { /** * @param {string[]} nodeIds * @param {Object} podNames - * @param {typeof import('listr2').TaskWrapper} task + * @param {TaskWrapper} task * @param {string} localBuildPath * @returns {Listr<*, *, *>} */ @@ -499,7 +499,7 @@ export class NodeCommand extends BaseCommand { * @param {string[]} nodeIds * @param {Object} podNames * @param {string} releaseTag - * @param {typeof import('listr2').TaskWrapper} task + * @param {TaskWrapper} task * @param {string} localBuildPath * @returns {Listr<*, *, *>} */ @@ -516,7 +516,7 @@ export class NodeCommand extends BaseCommand { * @param {string[]} nodeIds * @param {Object} podNames * @param {string} releaseTag - * @param {typeof import('listr2').TaskWrapper} task + * @param {TaskWrapper} task * @param {PlatformInstaller} platformInstaller * @returns {Listr} */ @@ -1981,7 +1981,7 @@ export class NodeCommand extends BaseCommand { /** * @param {PrivateKey|string} freezeAdminPrivateKey * @param {Uint8Array|string} upgradeZipHash - * @param {Client} client + * @param {NodeClient} client * @returns {Promise} */ async prepareUpgradeNetworkNodes (freezeAdminPrivateKey, upgradeZipHash, client) { @@ -2020,7 +2020,7 @@ export class NodeCommand extends BaseCommand { /** * @param {PrivateKey|string} freezeAdminPrivateKey * @param {Uint8Array|string} upgradeZipHash - * @param {Client} client + * @param {NodeClient} client * @returns {Promise} */ async freezeUpgradeNetworkNodes (freezeAdminPrivateKey, upgradeZipHash, client) { @@ -2052,7 +2052,7 @@ export class NodeCommand extends BaseCommand { /** * @param {Object} podNames * @param {string} nodeIds - * @param {{title: string, task: () => Promise}[]} subTasks + * @param {Object[]} subTasks */ startNodes (podNames, nodeIds, subTasks) { for (const nodeId of nodeIds) { diff --git a/src/commands/relay.mjs b/src/commands/relay.mjs index b38e43a39..39464cc8f 100644 --- a/src/commands/relay.mjs +++ b/src/commands/relay.mjs @@ -26,7 +26,7 @@ import { getNodeAccountMap } from '../core/helpers.mjs' export class RelayCommand extends BaseCommand { /** - * @param {{profileManager: ProfileManager, accountManager?: AccountManager, logger: Logger, helm: Helm, k8: K8, + * @param {{profileManager: ProfileManager, accountManager: AccountManager, logger: Logger, helm: Helm, k8: K8, * chartManager: ChartManager, configManager: ConfigManager, depManager: DependencyManager, * downloader: PackageDownloader}} opts */ diff --git a/src/core/constants.mjs b/src/core/constants.mjs index eac6d3cbe..ad0c6aa55 100644 --- a/src/core/constants.mjs +++ b/src/core/constants.mjs @@ -95,7 +95,7 @@ export const POD_CONDITION_STATUS_TRUE = 'True' /** * Listr related - * @type {LoggerFieldFn<[number]> & {condition: (duration: number) => boolean, format: (duration: number) => Color}} + * @return a object that defines the default color options */ export const LISTR_DEFAULT_RENDERER_TIMER_OPTION = { ...PRESET_TIMER, diff --git a/src/core/dependency_managers/dependency_manager.mjs b/src/core/dependency_managers/dependency_manager.mjs index 3c7de638c..465158829 100644 --- a/src/core/dependency_managers/dependency_manager.mjs +++ b/src/core/dependency_managers/dependency_manager.mjs @@ -55,10 +55,10 @@ export class DependencyManager extends ShellRunner { } /** - * @param {*[]} [deps] - * @returns {{title: string, task: () => Promise}[]} + * @param {String[]} deps + * @param {Object[]} subTasks */ - taskCheckDependencies (deps = []) { + taskCheckDependencies (deps) { const subTasks = [] deps.forEach(dep => { subTasks.push({ diff --git a/src/core/k8.mjs b/src/core/k8.mjs index 52a05a9c9..3d4332ee3 100644 --- a/src/core/k8.mjs +++ b/src/core/k8.mjs @@ -212,7 +212,7 @@ export class K8 { /** * Get pods by labels * @param {string[]} labels - list of labels - * @returns {Promise>} + * @returns {Promise>} */ async getPodsByLabel (labels = []) { const ns = this._getNamespace() @@ -342,7 +342,7 @@ export class K8 { * @param {string} containerName * @param {string} destPath - path inside the container * @param {number} [timeout] - timeout in ms - * @returns {Promise<{owner: string, size: number, modifiedAt: string, name: string, directory: boolean, group: string}[]>} + * @returns {Promise<{owner: string, size: number, modifiedAt: string, name: string, directory: boolean, group: string}>} * array of directory entries, custom object */ async listDir (podName, containerName, destPath, timeout = 5000) { diff --git a/src/core/platform_installer.mjs b/src/core/platform_installer.mjs index fb782fd6e..4799f37c3 100644 --- a/src/core/platform_installer.mjs +++ b/src/core/platform_installer.mjs @@ -305,7 +305,7 @@ export class PlatformInstaller { * * @param stagingDir staging directory path * @param nodeIds list of node ids - * @returns {Listr[]} + * @returns {Listr} */ copyNodeKeys (stagingDir, nodeIds) { const self = this From ed06b260db0576836c450690f5dad8ddaddf5653 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 10:05:27 -0500 Subject: [PATCH 24/37] save Signed-off-by: Jeffrey Tang --- package-lock.json | 200 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 3 +- 2 files changed, 198 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 644ad44aa..f0d3d61b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "ip": "^2.0.1", "js-base64": "^3.7.7", "js-yaml": "^4.1.0", + "jsdoc": "^4.0.3", "listr2": "^8.2.4", "semver": "^7.6.3", "stream-buffers": "^3.0.3", @@ -416,7 +417,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.7.tgz", "integrity": "sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==", - "dev": true, "bin": { "parser": "bin/babel-parser.js" }, @@ -2054,6 +2054,17 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@jsdoc/salty": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.8.tgz", + "integrity": "sha512-5e+SFVavj1ORKlKaKr2BmTOekmXbelU7dC0cDkQLqag7xfuTPuGMUFx7KWJuv4bYZrTsoL2Z18VVCOKYxzoHcg==", + "dependencies": { + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=v12.0.0" + } + }, "node_modules/@kubernetes/client-node": { "version": "0.21.0", "resolved": "https://registry.npmjs.org/@kubernetes/client-node/-/client-node-0.21.0.tgz", @@ -2611,6 +2622,20 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==" + }, + "node_modules/@types/markdown-it": { + "version": "14.1.2", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz", + "integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==", + "dependencies": { + "@types/linkify-it": "^5", + "@types/mdurl": "^2" + } + }, "node_modules/@types/mdast": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", @@ -2620,6 +2645,11 @@ "@types/unist": "*" } }, + "node_modules/@types/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==" + }, "node_modules/@types/ms": { "version": "0.7.34", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", @@ -3286,6 +3316,11 @@ "node": ">=8" } }, + "node_modules/bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" + }, "node_modules/bn.js": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", @@ -3580,6 +3615,17 @@ "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" }, + "node_modules/catharsis": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", + "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", + "dependencies": { + "lodash": "^4.17.15" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/chalk": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", @@ -4461,6 +4507,17 @@ "node": ">=8.6" } }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/environment": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", @@ -5792,8 +5849,7 @@ "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, "node_modules/graphemer": { "version": "1.4.0", @@ -7615,11 +7671,55 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/js2xmlparser": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz", + "integrity": "sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==", + "dependencies": { + "xmlcreate": "^2.0.4" + } + }, "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" }, + "node_modules/jsdoc": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.3.tgz", + "integrity": "sha512-Nu7Sf35kXJ1MWDZIMAuATRQTg1iIPdzh7tqJ6jjvaU/GfDf+qi5UV8zJR3Mo+/pYFvm8mzay4+6O5EWigaQBQw==", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/jsdoc/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "engines": { + "node": ">=8" + } + }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -7710,6 +7810,14 @@ "json-buffer": "3.0.1" } }, + "node_modules/klaw": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", + "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", + "dependencies": { + "graceful-fs": "^4.1.9" + } + }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -7752,6 +7860,14 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", "dev": true }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, "node_modules/listr2": { "version": "8.2.4", "resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.4.tgz", @@ -7867,6 +7983,11 @@ "node": ">=8" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", @@ -8105,6 +8226,42 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it-anchor": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, + "node_modules/marked": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, "node_modules/mdast-comment-marker": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mdast-comment-marker/-/mdast-comment-marker-3.0.0.tgz", @@ -8256,6 +8413,11 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==" + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -8880,7 +9042,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true, "bin": { "mkdirp": "bin/cmd.js" }, @@ -9826,6 +9987,14 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "engines": { + "node": ">=6" + } + }, "node_modules/pure-rand": { "version": "6.0.4", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.4.tgz", @@ -10710,6 +10879,14 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "node_modules/requizzle": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.4.tgz", + "integrity": "sha512-JRrFk1D4OQ4SqovXOgdav+K8EAhSB/LJZqCz8tbX0KObcdeM15Ss59ozWMBWmmINMagCwmqn4ZNryUGpBsl6Jw==", + "dependencies": { + "lodash": "^4.17.21" + } + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", @@ -11821,6 +11998,11 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==" + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -11836,6 +12018,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/underscore": { + "version": "1.13.7", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.7.tgz", + "integrity": "sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==" + }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -12571,6 +12758,11 @@ "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", "dev": true }, + "node_modules/xmlcreate": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", + "integrity": "sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg==" + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index 1cbdef6ea..97cda9e9a 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "merge-unit": "nyc merge ./coverage/unit/ .nyc_output/coverage.json", "report-coverage": "npm run merge-clean && npm run merge-unit && npm run merge-e2e && nyc report --reporter=json --reporter=html --reporter=lcov", "solo": "NODE_OPTIONS=--experimental-vm-modules node --no-deprecation solo.mjs", - "check": "remark . --quiet --frail && eslint .", + "check": "remark . --quiet --frail && eslint .; cd docs; jsdoc -c jsdoc.conf.json; cd ..", "format": "remark . --quiet --frail --output && eslint --fix .", "test-setup": "./test/e2e/setup-e2e.sh", "test-coverage": "npm run test && npm run test-setup && npm run test-e2e-all && npm run report-coverage" @@ -54,6 +54,7 @@ "got": "^14.4.2", "inquirer": "^10.2.0", "ip": "^2.0.1", + "jsdoc": "^4.0.3", "js-base64": "^3.7.7", "js-yaml": "^4.1.0", "listr2": "^8.2.4", From 9bcd7eb57a2e9a8f852d65a2fd244725c63e9493 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 12:34:42 -0500 Subject: [PATCH 25/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 137 +++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 87 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 7e60fb6b7..34b0245e7 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -293,6 +293,7 @@ export class NodeCommand extends BaseCommand { } /** + * Check if the network node pod is running * @param {string} namespace * @param {string} nodeId * @param {number} [maxAttempts] @@ -417,6 +418,50 @@ export class NodeCommand extends BaseCommand { }) } + addCheckPodRunningTask (ctx, task, nodeIds) { + const subTasks = [] + for (const nodeId of nodeIds) { + subTasks.push({ + title: `Check Node: ${chalk.yellow(nodeId)}`, + task: async () => + await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [ + 'fullstack.hedera.com/type=network-node', + `fullstack.hedera.com/node-name=${nodeId}` + ], 1, 60 * 15, 1000) // timeout 15 minutes + }) + } + + // set up the sub-tasks + return task.newListr(subTasks, { + concurrent: false, // no need to run concurrently since if one node is up, the rest should be up by then + rendererOptions: { + collapseSubtasks: false + } + }) + } + + addCheckNodeFreezeTask (ctx, task, nodeIds) { + const subTasks = [] + for (const nodeId of nodeIds) { + subTasks.push({ + title: `Check node: ${chalk.yellow(nodeId)}`, + task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE') + }) + } + + // set up the sub-tasks + return task.newListr(subTasks, { + concurrent: false, + rendererOptions: { + collapseSubtasks: false + } + }) + } + + addSetupNodesTask (ctx, task, nodeIds) { + + } + async initializeSetup (config, k8) { // compute other config parameters config.keysDir = path.join(validatePath(config.cacheDir), 'keys') @@ -1748,21 +1793,7 @@ export class NodeCommand extends BaseCommand { title: 'Check network nodes are frozen', task: (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - const subTasks = [] - for (const nodeId of config.existingNodeIds) { - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE') - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckNodeFreezeTask(ctx, task, config.existingNodeIds) } }, { @@ -1813,28 +1844,8 @@ export class NodeCommand extends BaseCommand { title: 'Check node pods are running', task: async (ctx, task) => { - const subTasks = [] const config = /** @type {NodeAddConfigClass} **/ ctx.config - - // nodes - for (const nodeId of config.allNodeIds) { - subTasks.push({ - title: `Check Node: ${chalk.yellow(nodeId)}`, - task: async () => - await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [ - 'fullstack.hedera.com/type=network-node', - `fullstack.hedera.com/node-name=${nodeId}` - ], 1, 60 * 15, 1000) // timeout 15 minutes - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, // no need to run concurrently since if one node is up, the rest should be up by then - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) } }, { @@ -2645,21 +2656,7 @@ export class NodeCommand extends BaseCommand { title: 'Check network nodes are frozen', task: (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - const subTasks = [] - for (const nodeId of config.existingNodeIds) { - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE') - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckNodeFreezeTask(ctx, task, config.existingNodeIds) } }, { @@ -3151,21 +3148,7 @@ export class NodeCommand extends BaseCommand { title: 'Check network nodes are frozen', task: (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - const subTasks = [] - for (const nodeId of config.existingNodeIds) { - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE') - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckNodeFreezeTask(ctx, task, config.existingNodeIds) } }, { @@ -3218,28 +3201,8 @@ export class NodeCommand extends BaseCommand { async (ctx, task) => { self.logger.info('sleep 20 seconds to give time for pods to come up after being killed') await sleep(20000) - const subTasks = [] const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - - // nodes - for (const nodeId of config.allNodeIds) { - subTasks.push({ - title: `Check Node: ${chalk.yellow(nodeId)}`, - task: async () => - await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [ - 'fullstack.hedera.com/type=network-node', - `fullstack.hedera.com/node-name=${nodeId}` - ], 1, 60 * 15, 1000) // timeout 15 minutes - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, // no need to run concurrently since if one node is up, the rest should be up by then - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) } }, { From 220c0428b3706957fe288088e0ecc4980a611e00 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 13:33:34 -0500 Subject: [PATCH 26/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 116 ++++++++++-------------------------------- 1 file changed, 27 insertions(+), 89 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 34b0245e7..72b30b870 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -424,7 +424,7 @@ export class NodeCommand extends BaseCommand { subTasks.push({ title: `Check Node: ${chalk.yellow(nodeId)}`, task: async () => - await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [ + await this.k8.waitForPods([constants.POD_PHASE_RUNNING], [ 'fullstack.hedera.com/type=network-node', `fullstack.hedera.com/node-name=${nodeId}` ], 1, 60 * 15, 1000) // timeout 15 minutes @@ -445,7 +445,7 @@ export class NodeCommand extends BaseCommand { for (const nodeId of nodeIds) { subTasks.push({ title: `Check node: ${chalk.yellow(nodeId)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE') + task: async () => await this.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE') }) } @@ -462,6 +462,26 @@ export class NodeCommand extends BaseCommand { } + addCheckNodesProxiesTask (ctx, task, nodeIds) { + const subTasks = [] + for (const nodeId of nodeIds) { + subTasks.push({ + title: `Check proxy for node: ${chalk.yellow(nodeId)}`, + task: async () => await this.k8.waitForPodReady( + [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'], + 1, 300, 2000) + }) + } + + // set up the sub-tasks + return task.newListr(subTasks, { + concurrent: false, + rendererOptions: { + collapseSubtasks: false + } + }) + } + async initializeSetup (config, k8) { // compute other config parameters config.keysDir = path.join(validatePath(config.cacheDir), 'keys') @@ -927,23 +947,7 @@ export class NodeCommand extends BaseCommand { { title: 'Check node proxies are ACTIVE', task: async (ctx, parentTask) => { - const subTasks = [] - for (const nodeId of ctx.config.nodeIds) { - subTasks.push({ - title: `Check proxy for node: ${chalk.yellow(nodeId)}`, - task: async () => await self.k8.waitForPodReady( - [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'], - 1, 300, 2000) - }) - } - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: { - collapseSubtasks: false - } - }) + return self.addCheckNodesProxiesTask(ctx, parentTask, ctx.config.nodeIds) }, skip: (ctx, _) => self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME }, @@ -1329,23 +1333,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - const subTasks = [] - for (const nodeId of ctx.config.nodeIds) { - subTasks.push({ - title: `Check proxy for node: ${chalk.yellow(nodeId)}`, - task: async () => await self.k8.waitForPodReady( - [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'], - 1, 300, 2000) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckNodesProxiesTask(ctx, task, ctx.config.nodeIds) }, skip: (ctx, _) => ctx.config.app !== '' }], { @@ -1965,24 +1953,8 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { + return this.addCheckNodesProxiesTask(ctx, task, ctx.config.allNodeIds) const config = /** @type {NodeAddConfigClass} **/ ctx.config - const subTasks = [] - for (const nodeId of config.allNodeIds) { - subTasks.push({ - title: `Check proxy for node: ${chalk.yellow(nodeId)}`, - task: async () => await self.k8.waitForPodReady( - [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'], - 1, 300, 2000) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) } }, { @@ -2837,24 +2809,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - const subTasks = [] - for (const nodeId of config.allNodeIds) { - subTasks.push({ - title: `Check proxy for node: ${chalk.yellow(nodeId)}`, - task: async () => await self.k8.waitForPodReady( - [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'], - 1, 300, 2000) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckNodesProxiesTask(ctx, tas, config.allNodeIds) } }, { @@ -3295,24 +3250,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - const subTasks = [] - for (const nodeId of config.allNodeIds) { - subTasks.push({ - title: `Check proxy for node: ${chalk.yellow(nodeId)}`, - task: async () => await self.k8.waitForPodReady( - [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'], - 1, 300, 2000) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.addCheckNodesProxiesTask(ctx, task, ctx.config.allNodeIds) } }, { From 8985e61a0a71ed95675eff502d0feac31ed30418 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 13:58:42 -0500 Subject: [PATCH 27/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 171 +++++++++++++++++++----------------------- 1 file changed, 79 insertions(+), 92 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 72b30b870..33f60789d 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -482,6 +482,76 @@ export class NodeCommand extends BaseCommand { }) } + async addCheckStakingTask (existingNodeIds) { + const accountMap = getNodeAccountMap(existingNodeIds) + for (const nodeId of existingNodeIds) { + const accountId = accountMap.get(nodeId) + await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) + } + } + + addPrepareStagingTask (ctx, task, keysDir, stagingKeysDir, nodeIds) { + const subTasks = [ + { + title: 'Copy Gossip keys to staging', + task: async (ctx, _) => { + // const config = /** @type {NodeDeleteConfigClass} **/ ctx.config + + await this.keyManager.copyGossipKeysToStaging(keysDir, stagingKeysDir, nodeIds) + } + }, + { + title: 'Copy gRPC TLS keys to staging', + task: async (ctx, _) => { + // const config = /** @type {NodeDeleteConfigClass} **/ ctx.config + for (const nodeId of nodeIds) { + const tlsKeyFiles = this.keyManager.prepareTLSKeyFilePaths(nodeId, keysDir) + await this.keyManager.copyNodeKeysToStaging(tlsKeyFiles, stagingKeysDir) + } + } + } + ] + return task.newListr(subTasks, { + concurrent: false, + rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION + }) + } + + async chartUpdateTask (ctx, nodeIds) { + const config = ctx.config + const index = config.existingNodeIds.length + const nodeId = Templates.nodeNumberFromNodeId(config.nodeId) - 1 + + let valuesArg = '' + for (let i = 0; i < index; i++) { + if (config.newAccountNumber && i !== nodeId) { + valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` + } else { + // use new account number for this node id + valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.newAccountNumber}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` + } + } + if (config.newNode.accountId) { + valuesArg += ` --set "hedera.nodes[${index}].accountId=${ctx.newNode.accountId}" --set "hedera.nodes[${index}].name=${ctx.newNode.name}"` + } + this.profileValuesFile = await this.profileManager.prepareValuesForNodeAdd( + path.join(config.stagingDir, 'config.txt'), + path.join(config.stagingDir, 'templates', 'application.properties')) + if (this.profileValuesFile) { + valuesArg += this.prepareValuesFiles(this.profileValuesFile) + } + + valuesArg = addDebugOptions(valuesArg, config.debugNodeId) + + await this.chartManager.upgrade( + config.namespace, + constants.FULLSTACK_DEPLOYMENT_CHART, + config.chartPath, + valuesArg, + config.fstChartVersion + ) + } + async initializeSetup (config, k8) { // compute other config parameters config.keysDir = path.join(validatePath(config.cacheDir), 'keys') @@ -1670,13 +1740,7 @@ export class NodeCommand extends BaseCommand { title: 'Check existing nodes staked amount', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - self.logger.info('sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate') - await sleep(15000) - const accountMap = getNodeAccountMap(config.existingNodeIds) - for (const nodeId of config.existingNodeIds) { - const accountId = accountMap.get(nodeId) - await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) - } + await this.addCheckStakingTask(config.existingNodeIds) } }, { @@ -1736,31 +1800,8 @@ export class NodeCommand extends BaseCommand { { title: 'Prepare staging directory', task: async (ctx, parentTask) => { - const subTasks = [ - { - title: 'Copy Gossip keys to staging', - task: async (ctx, _) => { - const config = /** @type {NodeAddConfigClass} **/ ctx.config - - await this.keyManager.copyGossipKeysToStaging(config.keysDir, config.stagingKeysDir, config.allNodeIds) - } - }, - { - title: 'Copy gRPC TLS keys to staging', - task: async (ctx, _) => { - const config = /** @type {NodeAddConfigClass} **/ ctx.config - for (const nodeId of config.allNodeIds) { - const tlsKeyFiles = self.keyManager.prepareTLSKeyFilePaths(nodeId, config.keysDir) - await self.keyManager.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir) - } - } - } - ] - - return parentTask.newListr(subTasks, { - concurrent: false, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + const config = /** @type {NodeAddConfigClass} **/ ctx.config + return this.addPrepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.allNodeIds) } }, { @@ -2475,11 +2516,7 @@ export class NodeCommand extends BaseCommand { title: 'Check existing nodes staked amount', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - const accountMap = getNodeAccountMap(config.existingNodeIds) - for (const nodeId of config.existingNodeIds) { - const accountId = accountMap.get(nodeId) - await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) - } + await this.addCheckStakingTask(config.existingNodeIds) } }, { @@ -2583,31 +2620,8 @@ export class NodeCommand extends BaseCommand { { title: 'Prepare staging directory', task: async (ctx, parentTask) => { - const subTasks = [ - { - title: 'Copy Gossip keys to staging', - task: async (ctx, _) => { - const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - - await this.keyManager.copyGossipKeysToStaging(config.keysDir, config.stagingKeysDir, config.allNodeIds) - } - }, - { - title: 'Copy gRPC TLS keys to staging', - task: async (ctx, _) => { - const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - for (const nodeId of config.allNodeIds) { - const tlsKeyFiles = self.keyManager.prepareTLSKeyFilePaths(nodeId, config.keysDir) - await self.keyManager.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir) - } - } - } - ] - - return parentTask.newListr(subTasks, { - concurrent: false, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + const config = /** @type {NodeUpdateConfigClass} **/ ctx.config + return this.addPrepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.allNodeIds) } }, { @@ -2992,11 +3006,7 @@ export class NodeCommand extends BaseCommand { title: 'Check existing nodes staked amount', task: async (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - const accountMap = getNodeAccountMap(config.existingNodeIds) - for (const nodeId of config.existingNodeIds) { - const accountId = accountMap.get(nodeId) - await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) - } + await this.addCheckStakingTask(config.existingNodeIds) } }, { @@ -3056,31 +3066,8 @@ export class NodeCommand extends BaseCommand { { title: 'Prepare staging directory', task: async (ctx, parentTask) => { - const subTasks = [ - { - title: 'Copy Gossip keys to staging', - task: async (ctx, _) => { - const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - - await this.keyManager.copyGossipKeysToStaging(config.keysDir, config.stagingKeysDir, config.existingNodeIds) - } - }, - { - title: 'Copy gRPC TLS keys to staging', - task: async (ctx, _) => { - const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - for (const nodeId of config.existingNodeIds) { - const tlsKeyFiles = self.keyManager.prepareTLSKeyFilePaths(nodeId, config.keysDir) - await self.keyManager.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir) - } - } - } - ] - - return parentTask.newListr(subTasks, { - concurrent: false, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + const config = /** @type {NodeDeleteConfigClass} **/ ctx.config + return this.addPrepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.existingNodeIds) } }, { From 556984901c17c749e762cf0d68346c53acd4a6c6 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 14:24:19 -0500 Subject: [PATCH 28/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 168 ++++++------------------------------------ 1 file changed, 24 insertions(+), 144 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 33f60789d..3f1e3bd88 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -458,8 +458,22 @@ export class NodeCommand extends BaseCommand { }) } - addSetupNodesTask (ctx, task, nodeIds) { + setupNodesTask (ctx, task, nodeIds) { + const subTasks = [] + for (const nodeId of nodeIds) { + const podName = ctx.config.podNames[nodeId] + subTasks.push({ + title: `Node: ${chalk.yellow(nodeId)}`, + task: () => + this.platformInstaller.taskSetup(podName) + }) + } + // set up the sub-tasks + return task.newListr(subTasks, { + concurrent: true, + rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION + }) } addCheckNodesProxiesTask (ctx, task, nodeIds) { @@ -517,7 +531,7 @@ export class NodeCommand extends BaseCommand { }) } - async chartUpdateTask (ctx, nodeIds) { + async chartUpdateTask (ctx) { const config = ctx.config const index = config.existingNodeIds.length const nodeId = Templates.nodeNumberFromNodeId(config.nodeId) - 1 @@ -878,21 +892,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup network nodes', task: async (ctx, parentTask) => { - const subTasks = [] - for (const nodeId of ctx.config.nodeIds) { - const podName = ctx.config.podNames[nodeId] - subTasks.push({ - title: `Node: ${chalk.yellow(nodeId)}`, - task: () => - self.platformInstaller.taskSetup(podName) - }) - } - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + return this.setupNodesTask(ctx, parentTask, ctx.configs.nodeIds) } } ], { @@ -1333,24 +1333,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup network nodes', task: async (ctx, parentTask) => { - const config = /** @type {NodeRefreshConfigClass} **/ ctx.config - - const subTasks = [] - - for (const nodeId of config.nodeIds) { - const podName = config.podNames[nodeId] - subTasks.push({ - title: `Node: ${chalk.yellow(nodeId)}`, - task: () => - self.platformInstaller.taskSetup(podName) - }) - } - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + return this.setupNodesTask(ctx, parentTask, ctx.configs.nodeIds) } }, { @@ -1835,29 +1818,7 @@ export class NodeCommand extends BaseCommand { { title: 'Deploy new network node', task: async (ctx, task) => { - const config = /** @type {NodeAddConfigClass} **/ ctx.config - const index = config.existingNodeIds.length - let valuesArg = '' - for (let i = 0; i < index; i++) { - valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` - } - valuesArg += ` --set "hedera.nodes[${index}].accountId=${ctx.newNode.accountId}" --set "hedera.nodes[${index}].name=${ctx.newNode.name}"` - - this.profileValuesFile = await self.profileManager.prepareValuesForNodeAdd( - path.join(config.stagingDir, 'config.txt'), - path.join(config.stagingDir, 'templates', 'application.properties')) - if (this.profileValuesFile) { - valuesArg += this.prepareValuesFiles(this.profileValuesFile) - } - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) - - await self.chartManager.upgrade( - config.namespace, - constants.FULLSTACK_DEPLOYMENT_CHART, - config.chartPath, - valuesArg, - config.fstChartVersion - ) + await this.chartUpdateTask(ctx) } }, { @@ -1920,23 +1881,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup new network node', task: async (ctx, parentTask) => { - const config = /** @type {NodeAddConfigClass} **/ ctx.config - - const subTasks = [] - for (const nodeId of config.allNodeIds) { - const podName = config.podNames[nodeId] - subTasks.push({ - title: `Node: ${chalk.yellow(nodeId)}`, - task: () => - self.platformInstaller.taskSetup(podName) - }) - } - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + return this.setupNodesTask(ctx, parentTask, ctx.configs.allNodeIds) } }, { @@ -2655,34 +2600,7 @@ export class NodeCommand extends BaseCommand { { title: 'Update chart to use new configMap due to account number change', task: async (ctx, task) => { - const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - const index = config.existingNodeIds.length - const nodeId = Templates.nodeNumberFromNodeId(config.nodeId) - 1 - let valuesArg = '' - for (let i = 0; i < index; i++) { - if (i !== nodeId && config.newAccountNumber) { - valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` - } else { - // use new account number for this node id - valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.newAccountNumber}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` - } - } - this.profileValuesFile = await self.profileManager.prepareValuesForNodeAdd( - path.join(config.stagingDir, 'config.txt'), - path.join(config.stagingDir, 'templates', 'application.properties')) - if (this.profileValuesFile) { - valuesArg += this.prepareValuesFiles(this.profileValuesFile) - } - - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) - - await self.chartManager.upgrade( - config.namespace, - constants.FULLSTACK_DEPLOYMENT_CHART, - config.chartPath, - valuesArg, - config.fstChartVersion - ) + await this.chartUpdateTask(ctx) }, // no need to run this step if the account number is not changed, since config.txt will be the same skip: (ctx, _) => !ctx.config.newAccountNumber && !ctx.config.debugNodeId @@ -2748,23 +2666,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup network nodes', task: async (ctx, parentTask) => { - const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - - const subTasks = [] - for (const nodeId of config.allNodeIds) { - const podName = config.podNames[nodeId] - subTasks.push({ - title: `Node: ${chalk.yellow(nodeId)}`, - task: () => - self.platformInstaller.taskSetup(podName) - }) - } - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + return this.setupNodesTask(ctx, parentTask, ctx.configs.allNodeIds) } }, { @@ -2823,7 +2725,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - return this.addCheckNodesProxiesTask(ctx, tas, config.allNodeIds) + return this.addCheckNodesProxiesTask(ctx, task, config.allNodeIds) } }, { @@ -3103,29 +3005,7 @@ export class NodeCommand extends BaseCommand { { title: 'Update chart to use new configMap', task: async (ctx, task) => { - const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - const index = config.existingNodeIds.length - let valuesArg = '' - for (let i = 0; i < index; i++) { - valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` - } - - this.profileValuesFile = await self.profileManager.prepareValuesForNodeAdd( - path.join(config.stagingDir, 'config.txt'), - path.join(config.stagingDir, 'templates', 'application.properties')) - if (this.profileValuesFile) { - valuesArg += this.prepareValuesFiles(this.profileValuesFile) - } - - valuesArg = addDebugOptions(valuesArg, config.debugNodeId) - - await self.chartManager.upgrade( - config.namespace, - constants.FULLSTACK_DEPLOYMENT_CHART, - config.chartPath, - valuesArg, - config.fstChartVersion - ) + await this.chartUpdateTask(ctx) } }, { From 2ab23b856f0b9c43c34362d20578f2bc5ea60e08 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 14:33:11 -0500 Subject: [PATCH 29/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 3f1e3bd88..891e7b1c9 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -1940,7 +1940,6 @@ export class NodeCommand extends BaseCommand { // logs will have a lot of white noise from being behind task: async (ctx, task) => { return this.addCheckNodesProxiesTask(ctx, task, ctx.config.allNodeIds) - const config = /** @type {NodeAddConfigClass} **/ ctx.config } }, { @@ -2725,7 +2724,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - return this.addCheckNodesProxiesTask(ctx, task, config.allNodeIds) + return this.addCheckNodesProxiesTask(ctx, task, ctx.config.allNodeIds) } }, { From 99cfa8ebb95a30134a20826324c226f82210bb7a Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 16:12:21 -0500 Subject: [PATCH 30/37] fix typop Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 891e7b1c9..26e8a6895 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -892,7 +892,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup network nodes', task: async (ctx, parentTask) => { - return this.setupNodesTask(ctx, parentTask, ctx.configs.nodeIds) + return this.setupNodesTask(ctx, parentTask, ctx.config.nodeIds) } } ], { @@ -1333,7 +1333,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup network nodes', task: async (ctx, parentTask) => { - return this.setupNodesTask(ctx, parentTask, ctx.configs.nodeIds) + return this.setupNodesTask(ctx, parentTask, ctx.config.nodeIds) } }, { @@ -1881,7 +1881,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup new network node', task: async (ctx, parentTask) => { - return this.setupNodesTask(ctx, parentTask, ctx.configs.allNodeIds) + return this.setupNodesTask(ctx, parentTask, ctx.config.allNodeIds) } }, { @@ -2665,7 +2665,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup network nodes', task: async (ctx, parentTask) => { - return this.setupNodesTask(ctx, parentTask, ctx.configs.allNodeIds) + return this.setupNodesTask(ctx, parentTask, ctx.config.allNodeIds) } }, { @@ -3041,23 +3041,7 @@ export class NodeCommand extends BaseCommand { { title: 'Setup network nodes', task: async (ctx, parentTask) => { - const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - - const subTasks = [] - for (const nodeId of config.allNodeIds) { - const podName = config.podNames[nodeId] - subTasks.push({ - title: `Node: ${chalk.yellow(nodeId)}`, - task: () => - self.platformInstaller.taskSetup(podName) - }) - } - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + return this.setupNodesTask(ctx, parentTask, ctx.config.allNodeIds) } }, { From 31dca7e73e68df714244d2f02452a9c3c10ce5f2 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 16:49:23 -0500 Subject: [PATCH 31/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 176 +++++++++++++----------------------------- 1 file changed, 52 insertions(+), 124 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 26e8a6895..9bb28458a 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -476,6 +476,21 @@ export class NodeCommand extends BaseCommand { }) } + startNetworkNodesTask (task, podNames, nodeIds) { + const subTasks = [] + // ctx.config.allNodeIds = ctx.config.existingNodeIds + this.startNodes(podNames, nodeIds, subTasks) + + // set up the sub-tasks + return task.newListr(subTasks, { + concurrent: true, + rendererOptions: { + collapseSubtasks: false, + timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION + } + }) + } + addCheckNodesProxiesTask (ctx, task, nodeIds) { const subTasks = [] for (const nodeId of nodeIds) { @@ -545,7 +560,7 @@ export class NodeCommand extends BaseCommand { valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.newAccountNumber}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` } } - if (config.newNode.accountId) { + if (config.newNode && config.newNode.accountId) { valuesArg += ` --set "hedera.nodes[${index}].accountId=${ctx.newNode.accountId}" --set "hedera.nodes[${index}].name=${ctx.newNode.name}"` } this.profileValuesFile = await this.profileManager.prepareValuesForNodeAdd( @@ -566,6 +581,25 @@ export class NodeCommand extends BaseCommand { ) } + async triggerStakeCalculation (config) { + const accountMap = getNodeAccountMap(config.allNodeIds) + + if (config.newAccountNumber) { + // update map with current account ids + accountMap.set(config.nodeId, config.newAccountNumber) + + // update _nodeClient with the new service map since one of the account number has changed + await this.accountManager.refreshNodeClient(config.namespace) + } + + // send some write transactions to invoke the handler that will trigger the stake weight recalculate + for (const nodeId of config.allNodeIds) { + const accountId = accountMap.get(nodeId) + config.nodeClient.setOperator(TREASURY_ACCOUNT_ID, config.treasuryKey) + await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) + } + } + async initializeSetup (config, k8) { // compute other config parameters config.keysDir = path.join(validatePath(config.cacheDir), 'keys') @@ -963,17 +997,7 @@ export class NodeCommand extends BaseCommand { { title: 'Starting nodes', task: (ctx, task) => { - const subTasks = [] - self.startNodes(ctx.config.podNames, ctx.config.nodeIds, subTasks) - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: true, - rendererOptions: { - collapseSubtasks: false, - timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION - } - }) + return this.startNetworkNodesTask(task, ctx.config.podNames, ctx.config.nodeIds) } }, { @@ -1339,18 +1363,7 @@ export class NodeCommand extends BaseCommand { { title: 'Starting nodes', task: (ctx, task) => { - const config = /** @type {NodeRefreshConfigClass} **/ ctx.config - const subTasks = [] - self.startNodes(config.podNames, config.nodeIds, subTasks) - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: true, - rendererOptions: { - collapseSubtasks: false, - timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION - } - }) + return this.startNetworkNodesTask(task, ctx.config.podNames, ctx.config.nodeIds) } }, { @@ -1832,11 +1845,10 @@ export class NodeCommand extends BaseCommand { }, { title: 'Check node pods are running', - task: - async (ctx, task) => { - const config = /** @type {NodeAddConfigClass} **/ ctx.config - return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) - } + task: async (ctx, task) => { + const config = /** @type {NodeAddConfigClass} **/ ctx.config + return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) + } }, { title: 'Fetch platform software into all network nodes', @@ -1888,17 +1900,7 @@ export class NodeCommand extends BaseCommand { title: 'Start network nodes', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - const subTasks = [] - self.startNodes(config.podNames, config.allNodeIds, subTasks) - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: true, - rendererOptions: { - collapseSubtasks: false, - timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION - } - }) + return this.startNetworkNodesTask(task, config.podNames, config.allNodeIds) } }, { @@ -1953,15 +1955,7 @@ export class NodeCommand extends BaseCommand { title: 'Trigger stake weight calculate', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - self.logger.info('sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate') - await sleep(60000) - const accountMap = getNodeAccountMap(config.allNodeIds) - // send some write transactions to invoke the handler that will trigger the stake weight recalculate - for (const nodeId of config.allNodeIds) { - const accountId = accountMap.get(nodeId) - config.nodeClient.setOperator(TREASURY_ACCOUNT_ID, config.treasuryKey) - await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) - } + await this.triggerStakeCalculation(config) } }, { @@ -2627,32 +2621,11 @@ export class NodeCommand extends BaseCommand { } }, { - title: 'Check node pods are ready', - task: - async (ctx, task) => { - const subTasks = [] - const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - - // nodes - for (const nodeId of config.allNodeIds) { - subTasks.push({ - title: `Check Node: ${chalk.yellow(nodeId)}`, - task: async () => - await self.k8.waitForPodReady( - ['fullstack.hedera.com/type=network-node', - `fullstack.hedera.com/node-name=${nodeId}`], - 1, 300, 2000) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, // no need to run concurrently since if one node is up, the rest should be up by then - rendererOptions: { - collapseSubtasks: false - } - }) - } + title: 'Check node pods are running', + task: async (ctx, task) => { + const config = /** @type {NodeUpdateConfigClass} **/ ctx.config + return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) + } }, { title: 'Fetch platform software into network nodes', @@ -2672,18 +2645,7 @@ export class NodeCommand extends BaseCommand { title: 'Start network nodes', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - const subTasks = [] - // ctx.config.allNodeIds = ctx.config.existingNodeIds - self.startNodes(config.podNames, config.allNodeIds, subTasks) - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: true, - rendererOptions: { - collapseSubtasks: false, - timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION - } - }) + return this.startNetworkNodesTask(task, config.podNames, config.allNodeIds) } }, { @@ -2731,22 +2693,7 @@ export class NodeCommand extends BaseCommand { title: 'Trigger stake weight calculate', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - self.logger.info('sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate') - await sleep(60000) - const accountMap = getNodeAccountMap(config.allNodeIds) - // update map with current account ids - accountMap.set(config.nodeId, config.newAccountNumber) - - // update _nodeClient with the new service map since one of the account number has changed - await this.accountManager.refreshNodeClient(config.namespace) - - // send some write transactions to invoke the handler that will trigger the stake weight recalculate - for (const nodeId of config.allNodeIds) { - const accountId = accountMap.get(nodeId) - config.nodeClient.setOperator(TREASURY_ACCOUNT_ID, config.treasuryKey) - self.logger.info(`Sending 1 HBAR to account: ${accountId}`) - await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) - } + await this.triggerStakeCalculation(config) } }, { @@ -3048,18 +2995,7 @@ export class NodeCommand extends BaseCommand { title: 'Start network nodes', task: async (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - const subTasks = [] - - self.startNodes(config.podNames, config.allNodeIds, subTasks) - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: true, - rendererOptions: { - collapseSubtasks: false, - timer: constants.LISTR_DEFAULT_RENDERER_TIMER_OPTION - } - }) + return this.startNetworkNodesTask(task, config.podNames, config.allNodeIds) } }, { @@ -3107,15 +3043,7 @@ export class NodeCommand extends BaseCommand { title: 'Trigger stake weight calculate', task: async (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - self.logger.info('sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate') - await sleep(60000) - const accountMap = getNodeAccountMap(config.allNodeIds) - // send some write transactions to invoke the handler that will trigger the stake weight recalculate - for (const nodeId of config.allNodeIds) { - const accountId = accountMap.get(nodeId) - config.nodeClient.setOperator(TREASURY_ACCOUNT_ID, config.treasuryKey) - await this.accountManager.transferAmount(constants.TREASURY_ACCOUNT_ID, accountId, 1) - } + await this.triggerStakeCalculation(config) } }, { From 01f6daec1f0ff9132d29ec4d56eca0dbcb48329a Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 17:33:34 -0500 Subject: [PATCH 32/37] refactor Signed-off-by: Jeffrey Tang --- package.json | 2 +- src/commands/node.mjs | 206 ++++++++++++++++++++++++------------------ 2 files changed, 120 insertions(+), 88 deletions(-) diff --git a/package.json b/package.json index 97cda9e9a..fbab33bde 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "merge-unit": "nyc merge ./coverage/unit/ .nyc_output/coverage.json", "report-coverage": "npm run merge-clean && npm run merge-unit && npm run merge-e2e && nyc report --reporter=json --reporter=html --reporter=lcov", "solo": "NODE_OPTIONS=--experimental-vm-modules node --no-deprecation solo.mjs", - "check": "remark . --quiet --frail && eslint .; cd docs; jsdoc -c jsdoc.conf.json; cd ..", + "check": "rm -rf docs/public/*; remark . --quiet --frail && eslint .; cd docs; jsdoc -c jsdoc.conf.json; cd ..", "format": "remark . --quiet --frail --output && eslint --fix .", "test-setup": "./test/e2e/setup-e2e.sh", "test-coverage": "npm run test && npm run test-setup && npm run test-e2e-all && npm run report-coverage" diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 9bb28458a..133bbf412 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -418,7 +418,14 @@ export class NodeCommand extends BaseCommand { }) } - addCheckPodRunningTask (ctx, task, nodeIds) { + /** + * Return task for checking for all network node pods + * @param {any} ctx + * @param {TaskWrapper} task + * @param {string[]} nodeIds + * @returns {*} + */ + checkPodRunningTask (ctx, task, nodeIds) { const subTasks = [] for (const nodeId of nodeIds) { subTasks.push({ @@ -440,7 +447,14 @@ export class NodeCommand extends BaseCommand { }) } - addCheckNodeFreezeTask (ctx, task, nodeIds) { + /** + * Return task for checking for if node is in freeze state + * @param {any} ctx + * @param {TaskWrapper} task + * @param {string[]} nodeIds + * @returns {*} + */ + checkNodeFreezeTask (ctx, task, nodeIds) { const subTasks = [] for (const nodeId of nodeIds) { subTasks.push({ @@ -458,6 +472,13 @@ export class NodeCommand extends BaseCommand { }) } + /** + * Return task for setup network nodes + * @param {any} ctx + * @param {TaskWrapper} task + * @param {string[]} nodeIds + * @returns {*} + */ setupNodesTask (ctx, task, nodeIds) { const subTasks = [] for (const nodeId of nodeIds) { @@ -476,6 +497,13 @@ export class NodeCommand extends BaseCommand { }) } + /** + * Return task for start network node hedera service + * @param {TaskWrapper} task + * @param {string[]} podNames + * @param {string[]} nodeIds + * @returns {*} + */ startNetworkNodesTask (task, podNames, nodeIds) { const subTasks = [] // ctx.config.allNodeIds = ctx.config.existingNodeIds @@ -491,7 +519,14 @@ export class NodeCommand extends BaseCommand { }) } - addCheckNodesProxiesTask (ctx, task, nodeIds) { + /** + * Return task for check if node proxies are ready + * @param {any} ctx + * @param {TaskWrapper} task + * @param {string[]} nodeIds + * @returns {*} + */ + checkNodesProxiesTask (ctx, task, nodeIds) { const subTasks = [] for (const nodeId of nodeIds) { subTasks.push({ @@ -511,7 +546,7 @@ export class NodeCommand extends BaseCommand { }) } - async addCheckStakingTask (existingNodeIds) { + async checkStakingTask (existingNodeIds) { const accountMap = getNodeAccountMap(existingNodeIds) for (const nodeId of existingNodeIds) { const accountId = accountMap.get(nodeId) @@ -519,7 +554,16 @@ export class NodeCommand extends BaseCommand { } } - addPrepareStagingTask (ctx, task, keysDir, stagingKeysDir, nodeIds) { + /** + * Task for repairing staging directory + * @param ctx + * @param task + * @param keysDir + * @param stagingKeysDir + * @param nodeIds + * @return return task for reparing staging directory + */ + prepareStagingTask (ctx, task, keysDir, stagingKeysDir, nodeIds) { const subTasks = [ { title: 'Copy Gossip keys to staging', @@ -546,6 +590,10 @@ export class NodeCommand extends BaseCommand { }) } + /** + * Prepare parameter and update the network node chart + * @param ctx + */ async chartUpdateTask (ctx) { const config = ctx.config const index = config.existingNodeIds.length @@ -581,6 +629,10 @@ export class NodeCommand extends BaseCommand { ) } + /** + * Update account manager and transfer hbar for staking purpose + * @param config + */ async triggerStakeCalculation (config) { const accountMap = getNodeAccountMap(config.allNodeIds) @@ -600,6 +652,44 @@ export class NodeCommand extends BaseCommand { } } + /** + * Identify existing network nodes and check if they are running + * @param {any} ctx + * @param {TaskWrapper} task + * @param config + */ + async identifyExistingNetworkNodes (ctx, task, config) { + config.existingNodeIds = [] + config.serviceMap = await this.accountManager.getNodeServiceMap( + config.namespace) + for (/** @type {NetworkNodeServices} **/ const networkNodeServices of config.serviceMap.values()) { + config.existingNodeIds.push(networkNodeServices.nodeName) + } + if (config.nodeId) { // case of adding new node + config.allNodeIds = [...config.existingNodeIds, config.nodeId] + } else { + config.allNodeIds = [...config.existingNodeIds] + } + return this.taskCheckNetworkNodePods(ctx, task, config.existingNodeIds) + } + + /** + * Download generated config files and key files from the network node + * @param config + */ + async downloadNodeGeneratedFiles (config) { + const node1FullyQualifiedPodName = Templates.renderNetworkPodName(config.existingNodeIds[0]) + + // copy the config.txt file from the node1 upgrade directory + await this.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/config.txt`, config.stagingDir) + + const signedKeyFiles = (await this.k8.listDir(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current`)).filter(file => file.name.startsWith(constants.SIGNING_KEY_PREFIX)) + await this.k8.execContainer(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, ['bash', '-c', `mkdir -p ${constants.HEDERA_HAPI_PATH}/data/keys_backup && cp ${constants.HEDERA_HAPI_PATH}/data/keys/..data/* ${constants.HEDERA_HAPI_PATH}/data/keys_backup/`]) + for (const signedKeyFile of signedKeyFiles) { + await this.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/${signedKeyFile.name}`, `${config.keysDir}`) + } + } + async initializeSetup (config, k8) { // compute other config parameters config.keysDir = path.join(validatePath(config.cacheDir), 'keys') @@ -982,16 +1072,7 @@ export class NodeCommand extends BaseCommand { title: 'Identify existing network nodes', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - config.existingNodeIds = [] - config.serviceMap = await self.accountManager.getNodeServiceMap( - config.namespace) - for (/** @type {NetworkNodeServices} **/ const networkNodeServices of config.serviceMap.values()) { - config.existingNodeIds.push(networkNodeServices.nodeName) - } - - config.allNodeIds = [...config.existingNodeIds] - - return self.taskCheckNetworkNodePods(ctx, task, config.existingNodeIds) + return this.identifyExistingNetworkNodes(ctx, task, config) } }, { @@ -1041,7 +1122,7 @@ export class NodeCommand extends BaseCommand { { title: 'Check node proxies are ACTIVE', task: async (ctx, parentTask) => { - return self.addCheckNodesProxiesTask(ctx, parentTask, ctx.config.nodeIds) + return self.checkNodesProxiesTask(ctx, parentTask, ctx.config.nodeIds) }, skip: (ctx, _) => self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME }, @@ -1399,7 +1480,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - return this.addCheckNodesProxiesTask(ctx, task, ctx.config.nodeIds) + return this.checkNodesProxiesTask(ctx, task, ctx.config.nodeIds) }, skip: (ctx, _) => ctx.config.app !== '' }], { @@ -1589,15 +1670,7 @@ export class NodeCommand extends BaseCommand { title: 'Identify existing network nodes', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - config.serviceMap = await self.accountManager.getNodeServiceMap( - config.namespace) - for (/** @type {NetworkNodeServices} **/ const networkNodeServices of config.serviceMap.values()) { - config.existingNodeIds.push(networkNodeServices.nodeName) - } - - config.allNodeIds = [...config.existingNodeIds, config.nodeId] - - return self.taskCheckNetworkNodePods(ctx, task, config.existingNodeIds) + return this.identifyExistingNetworkNodes(ctx, task, config) } }, { @@ -1736,7 +1809,7 @@ export class NodeCommand extends BaseCommand { title: 'Check existing nodes staked amount', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - await this.addCheckStakingTask(config.existingNodeIds) + await this.checkStakingTask(config.existingNodeIds) } }, { @@ -1774,16 +1847,7 @@ export class NodeCommand extends BaseCommand { title: 'Download generated files from an existing node', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - const node1FullyQualifiedPodName = Templates.renderNetworkPodName(config.existingNodeIds[0]) - - // copy the config.txt file from the node1 upgrade directory - await self.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/config.txt`, config.stagingDir) - - const signedKeyFiles = (await self.k8.listDir(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current`)).filter(file => file.name.startsWith(constants.SIGNING_KEY_PREFIX)) - await self.k8.execContainer(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, ['bash', '-c', `mkdir -p ${constants.HEDERA_HAPI_PATH}/data/keys_backup && cp ${constants.HEDERA_HAPI_PATH}/data/keys/..data/* ${constants.HEDERA_HAPI_PATH}/data/keys_backup/`]) - for (const signedKeyFile of signedKeyFiles) { - await self.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/${signedKeyFile.name}`, `${config.keysDir}`) - } + await this.downloadNodeGeneratedFiles(config) } }, { @@ -1797,7 +1861,7 @@ export class NodeCommand extends BaseCommand { title: 'Prepare staging directory', task: async (ctx, parentTask) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - return this.addPrepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.allNodeIds) + return this.prepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.allNodeIds) } }, { @@ -1818,7 +1882,7 @@ export class NodeCommand extends BaseCommand { title: 'Check network nodes are frozen', task: (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - return this.addCheckNodeFreezeTask(ctx, task, config.existingNodeIds) + return this.checkNodeFreezeTask(ctx, task, config.existingNodeIds) } }, { @@ -1847,7 +1911,7 @@ export class NodeCommand extends BaseCommand { title: 'Check node pods are running', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) + return this.checkPodRunningTask(ctx, task, config.allNodeIds) } }, { @@ -1941,7 +2005,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - return this.addCheckNodesProxiesTask(ctx, task, ctx.config.allNodeIds) + return this.checkNodesProxiesTask(ctx, task, ctx.config.allNodeIds) } }, { @@ -2382,15 +2446,7 @@ export class NodeCommand extends BaseCommand { title: 'Identify existing network nodes', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - config.serviceMap = await self.accountManager.getNodeServiceMap( - config.namespace) - for (/** @type {NetworkNodeServices} **/ const networkNodeServices of config.serviceMap.values()) { - config.existingNodeIds.push(networkNodeServices.nodeName) - } - - config.allNodeIds = [...config.existingNodeIds] - - return self.taskCheckNetworkNodePods(ctx, task, config.existingNodeIds) + return this.identifyExistingNetworkNodes(ctx, task, config) } }, { @@ -2454,7 +2510,7 @@ export class NodeCommand extends BaseCommand { title: 'Check existing nodes staked amount', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - await this.addCheckStakingTask(config.existingNodeIds) + await this.checkStakingTask(config.existingNodeIds) } }, { @@ -2536,16 +2592,7 @@ export class NodeCommand extends BaseCommand { title: 'Download generated files from an existing node', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - const node1FullyQualifiedPodName = Templates.renderNetworkPodName(config.existingNodeIds[0]) - - // copy the config.txt file from the node1 upgrade directory - await self.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/config.txt`, config.stagingDir) - - const signedKeyFiles = (await self.k8.listDir(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current`)).filter(file => file.name.startsWith(constants.SIGNING_KEY_PREFIX)) - await self.k8.execContainer(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, ['bash', '-c', `mkdir -p ${constants.HEDERA_HAPI_PATH}/data/keys_backup && cp ${constants.HEDERA_HAPI_PATH}/data/keys/..data/* ${constants.HEDERA_HAPI_PATH}/data/keys_backup/`]) - for (const signedKeyFile of signedKeyFiles) { - await self.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/${signedKeyFile.name}`, `${config.keysDir}`) - } + await this.downloadNodeGeneratedFiles(config) } }, { @@ -2559,7 +2606,7 @@ export class NodeCommand extends BaseCommand { title: 'Prepare staging directory', task: async (ctx, parentTask) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - return this.addPrepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.allNodeIds) + return this.prepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.allNodeIds) } }, { @@ -2580,7 +2627,7 @@ export class NodeCommand extends BaseCommand { title: 'Check network nodes are frozen', task: (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - return this.addCheckNodeFreezeTask(ctx, task, config.existingNodeIds) + return this.checkNodeFreezeTask(ctx, task, config.existingNodeIds) } }, { @@ -2624,7 +2671,7 @@ export class NodeCommand extends BaseCommand { title: 'Check node pods are running', task: async (ctx, task) => { const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) + return this.checkPodRunningTask(ctx, task, config.allNodeIds) } }, { @@ -2686,7 +2733,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - return this.addCheckNodesProxiesTask(ctx, task, ctx.config.allNodeIds) + return this.checkNodesProxiesTask(ctx, task, ctx.config.allNodeIds) } }, { @@ -2826,13 +2873,7 @@ export class NodeCommand extends BaseCommand { title: 'Identify existing network nodes', task: async (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - config.serviceMap = await self.accountManager.getNodeServiceMap( - config.namespace) - for (/** @type {NetworkNodeServices} **/ const networkNodeServices of config.serviceMap.values()) { - config.existingNodeIds.push(networkNodeServices.nodeName) - } - - return self.taskCheckNetworkNodePods(ctx, task, config.existingNodeIds) + return this.identifyExistingNetworkNodes(ctx, task, config) } }, { @@ -2854,7 +2895,7 @@ export class NodeCommand extends BaseCommand { title: 'Check existing nodes staked amount', task: async (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - await this.addCheckStakingTask(config.existingNodeIds) + await this.checkStakingTask(config.existingNodeIds) } }, { @@ -2892,16 +2933,7 @@ export class NodeCommand extends BaseCommand { title: 'Download generated files from an existing node', task: async (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - const node1FullyQualifiedPodName = Templates.renderNetworkPodName(config.existingNodeIds[0]) - - // copy the config.txt file from the node1 upgrade directory - await self.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/config.txt`, config.stagingDir) - - const signedKeyFiles = (await self.k8.listDir(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current`)).filter(file => file.name.startsWith(constants.SIGNING_KEY_PREFIX)) - await self.k8.execContainer(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, ['bash', '-c', `mkdir -p ${constants.HEDERA_HAPI_PATH}/data/keys_backup && cp ${constants.HEDERA_HAPI_PATH}/data/keys/..data/* ${constants.HEDERA_HAPI_PATH}/data/keys_backup/`]) - for (const signedKeyFile of signedKeyFiles) { - await self.k8.copyFrom(node1FullyQualifiedPodName, constants.ROOT_CONTAINER, `${constants.HEDERA_HAPI_PATH}/data/upgrade/current/${signedKeyFile.name}`, `${config.keysDir}`) - } + await this.downloadNodeGeneratedFiles(config) } }, { @@ -2915,7 +2947,7 @@ export class NodeCommand extends BaseCommand { title: 'Prepare staging directory', task: async (ctx, parentTask) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - return this.addPrepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.existingNodeIds) + return this.prepareStagingTask(ctx, parentTask, config.keysDir, config.stagingKeysDir, config.existingNodeIds) } }, { @@ -2938,7 +2970,7 @@ export class NodeCommand extends BaseCommand { title: 'Check network nodes are frozen', task: (ctx, task) => { const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - return this.addCheckNodeFreezeTask(ctx, task, config.existingNodeIds) + return this.checkNodeFreezeTask(ctx, task, config.existingNodeIds) } }, { @@ -2970,7 +3002,7 @@ export class NodeCommand extends BaseCommand { self.logger.info('sleep 20 seconds to give time for pods to come up after being killed') await sleep(20000) const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - return this.addCheckPodRunningTask(ctx, task, config.allNodeIds) + return this.checkPodRunningTask(ctx, task, config.allNodeIds) } }, { @@ -3036,7 +3068,7 @@ export class NodeCommand extends BaseCommand { // this is more reliable than checking the nodes logs for ACTIVE, as the // logs will have a lot of white noise from being behind task: async (ctx, task) => { - return this.addCheckNodesProxiesTask(ctx, task, ctx.config.allNodeIds) + return this.checkNodesProxiesTask(ctx, task, ctx.config.allNodeIds) } }, { From a666227b590df5c194fbe8f60f55ea8957305562 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 21:57:06 -0500 Subject: [PATCH 33/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 133bbf412..f7ffc24ce 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -601,7 +601,7 @@ export class NodeCommand extends BaseCommand { let valuesArg = '' for (let i = 0; i < index; i++) { - if (config.newAccountNumber && i !== nodeId) { + if ((config.newAccountNumber && i !== nodeId) || !config.newAccountNumber) { valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` } else { // use new account number for this node id From 999097b97af322557966387dd63b4dd8d2048887 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Tue, 10 Sep 2024 23:01:04 -0500 Subject: [PATCH 34/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index f7ffc24ce..94a1cc57e 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -608,7 +608,7 @@ export class NodeCommand extends BaseCommand { valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.newAccountNumber}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` } } - if (config.newNode && config.newNode.accountId) { + if (ctx.newNode && ctx.newNode.accountId) { valuesArg += ` --set "hedera.nodes[${index}].accountId=${ctx.newNode.accountId}" --set "hedera.nodes[${index}].name=${ctx.newNode.name}"` } this.profileValuesFile = await this.profileManager.prepareValuesForNodeAdd( @@ -657,15 +657,16 @@ export class NodeCommand extends BaseCommand { * @param {any} ctx * @param {TaskWrapper} task * @param config + * @param isAddNode if this is an operation of adding a new node */ - async identifyExistingNetworkNodes (ctx, task, config) { + async identifyExistingNetworkNodes (ctx, task, config, isAddNode= false) { config.existingNodeIds = [] config.serviceMap = await this.accountManager.getNodeServiceMap( config.namespace) for (/** @type {NetworkNodeServices} **/ const networkNodeServices of config.serviceMap.values()) { config.existingNodeIds.push(networkNodeServices.nodeName) } - if (config.nodeId) { // case of adding new node + if (isAddNode) { // case of adding new node config.allNodeIds = [...config.existingNodeIds, config.nodeId] } else { config.allNodeIds = [...config.existingNodeIds] @@ -1670,7 +1671,7 @@ export class NodeCommand extends BaseCommand { title: 'Identify existing network nodes', task: async (ctx, task) => { const config = /** @type {NodeAddConfigClass} **/ ctx.config - return this.identifyExistingNetworkNodes(ctx, task, config) + return this.identifyExistingNetworkNodes(ctx, task, config, true) } }, { From 26bbe345bca33b7f046039dd8c95e20e02039e1f Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 11 Sep 2024 08:29:38 -0500 Subject: [PATCH 35/37] check Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 94a1cc57e..1f051d027 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -546,6 +546,11 @@ export class NodeCommand extends BaseCommand { }) } + /** + * Transfer some hbar to the node for staking purpose + * @param existingNodeIds + * @return {Promise} + */ async checkStakingTask (existingNodeIds) { const accountMap = getNodeAccountMap(existingNodeIds) for (const nodeId of existingNodeIds) { @@ -601,13 +606,15 @@ export class NodeCommand extends BaseCommand { let valuesArg = '' for (let i = 0; i < index; i++) { - if ((config.newAccountNumber && i !== nodeId) || !config.newAccountNumber) { + if ((config.newAccountNumber && i !== nodeId) || !config.newAccountNumber) { // for the case of updating node valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.serviceMap.get(config.existingNodeIds[i]).accountId}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` } else { // use new account number for this node id valuesArg += ` --set "hedera.nodes[${i}].accountId=${config.newAccountNumber}" --set "hedera.nodes[${i}].name=${config.existingNodeIds[i]}"` } } + + // for the case of adding new node if (ctx.newNode && ctx.newNode.accountId) { valuesArg += ` --set "hedera.nodes[${index}].accountId=${ctx.newNode.accountId}" --set "hedera.nodes[${index}].name=${ctx.newNode.name}"` } @@ -659,7 +666,7 @@ export class NodeCommand extends BaseCommand { * @param config * @param isAddNode if this is an operation of adding a new node */ - async identifyExistingNetworkNodes (ctx, task, config, isAddNode= false) { + async identifyExistingNetworkNodes (ctx, task, config, isAddNode = false) { config.existingNodeIds = [] config.serviceMap = await this.accountManager.getNodeServiceMap( config.namespace) From 0e84ccb84f207787a6173e3485e5fdb6420989a0 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 11 Sep 2024 09:14:09 -0500 Subject: [PATCH 36/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 153 +++++++++++------------------------------- 1 file changed, 41 insertions(+), 112 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 1f051d027..8195d91ce 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -447,6 +447,42 @@ export class NodeCommand extends BaseCommand { }) } + /** + * + * @param {string} debugNodeId + * @param {TaskWrapper} task + * @param {string[]} nodeIds + * @return {Listr} + */ + checkNodeActiveTask (debugNodeId, task, nodeIds) { + const subTasks = [] + for (const nodeId of nodeIds) { + let reminder = '' + if (debugNodeId === nodeId) { + reminder = ' Please attach JVM debugger now.' + } + if (this.configManager.getFlag(flags.app) !== '' && this.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME) { + subTasks.push({ + title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, + task: async () => await this.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log') + }) + } else { + subTasks.push({ + title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, + task: async () => await this.checkNetworkNodeState(nodeId) + }) + } + } + + // set up the sub-tasks + return task.newListr(subTasks, { + concurrent: true, + rendererOptions: { + collapseSubtasks: false + } + }) + } + /** * Return task for checking for if node is in freeze state * @param {any} ctx @@ -1099,32 +1135,7 @@ export class NodeCommand extends BaseCommand { { title: 'Check nodes are ACTIVE', task: (ctx, task) => { - const subTasks = [] - for (const nodeId of ctx.config.nodeIds) { - let reminder = '' - if (ctx.config.debugNodeId === nodeId) { - reminder = ' Please attach JVM debugger now.' - } - if (self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME) { - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log') - }) - } else { - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => await self.checkNetworkNodeState(nodeId) - }) - } - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: true, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.checkNodeActiveTask(ctx.config.debugNodeId, task, ctx.config.nodeIds) } }, { @@ -1458,29 +1469,7 @@ export class NodeCommand extends BaseCommand { { title: 'Check nodes are ACTIVE', task: (ctx, task) => { - const config = /** @type {NodeRefreshConfigClass} **/ ctx.config - const subTasks = [] - for (const nodeId of ctx.config.nodeIds) { - if (config.app !== constants.HEDERA_APP_NAME) { - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log') - }) - } else { - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}`, - task: async () => await self.checkNetworkNodeState(nodeId) - }) - } - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.checkNodeActiveTask(ctx.config.debugNodeId, task, ctx.config.nodeIds) } }, { @@ -1985,27 +1974,7 @@ export class NodeCommand extends BaseCommand { { title: 'Check all nodes are ACTIVE', task: async (ctx, task) => { - const subTasks = [] - self.logger.info('sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string') - await sleep(30000) - for (const nodeId of ctx.config.allNodeIds) { - let reminder = '' - if (ctx.config.debugNodeId === nodeId) { - reminder = ' Please attach JVM debugger now.' - } - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 200) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.checkNodeActiveTask(ctx.config.debugNodeId, task, ctx.config.allNodeIds) } }, { @@ -2713,27 +2682,7 @@ export class NodeCommand extends BaseCommand { { title: 'Check all nodes are ACTIVE', task: async (ctx, task) => { - const subTasks = [] - self.logger.info('sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string') - await sleep(30000) - for (const nodeId of ctx.config.allNodeIds) { - let reminder = '' - if (ctx.config.debugNodeId === nodeId) { - reminder = ' Please attach JVM debugger now.' - } - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)} ${chalk.red(reminder)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 200) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.checkNodeActiveTask(ctx.config.debugNodeId, task, ctx.config.allNodeIds) } }, { @@ -3048,27 +2997,7 @@ export class NodeCommand extends BaseCommand { { title: 'Check all nodes are ACTIVE', task: async (ctx, task) => { - const subTasks = [] - self.logger.info('sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string') - await sleep(30000) - for (const nodeId of ctx.config.allNodeIds) { - let reminder = '' - if (ctx.config.debugNodeId === nodeId) { - reminder = ' Please attach JVM debugger now.' - } - subTasks.push({ - title: `Check node: ${chalk.yellow(nodeId)}, ${chalk.red(reminder)}`, - task: async () => await self.checkNetworkNodeState(nodeId, 200) - }) - } - - // set up the sub-tasks - return task.newListr(subTasks, { - concurrent: false, - rendererOptions: { - collapseSubtasks: false - } - }) + return this.checkNodeActiveTask(ctx.config.debugNodeId, task, ctx.config.allNodeIds) } }, { From 2df8689dd9b4b76aa602d9a27cb8d53704899215 Mon Sep 17 00:00:00 2001 From: Jeffrey Tang Date: Wed, 11 Sep 2024 10:04:32 -0500 Subject: [PATCH 37/37] save Signed-off-by: Jeffrey Tang --- src/commands/node.mjs | 49 +++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 8195d91ce..e321ac5ee 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -631,6 +631,21 @@ export class NodeCommand extends BaseCommand { }) } + /** + * Return task for copy node key to staging directory + * @param ctx + * @param task + */ + copyNodeKeyTask (ctx, task) { + const subTasks = this.platformInstaller.copyNodeKeys(ctx.config.stagingDir, ctx.config.allNodeIds) + + // set up the sub-tasks + return task.newListr(subTasks, { + concurrent: true, + rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION + }) + } + /** * Prepare parameter and update the network node chart * @param ctx @@ -677,6 +692,8 @@ export class NodeCommand extends BaseCommand { * @param config */ async triggerStakeCalculation (config) { + this.logger.info('sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate') + await sleep(60000) const accountMap = getNodeAccountMap(config.allNodeIds) if (config.newAccountNumber) { @@ -1864,15 +1881,7 @@ export class NodeCommand extends BaseCommand { { title: 'Copy node keys to secrets', task: async (ctx, parentTask) => { - const config = /** @type {NodeAddConfigClass} **/ ctx.config - - const subTasks = self.platformInstaller.copyNodeKeys(config.stagingDir, config.allNodeIds) - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + return this.copyNodeKeyTask(ctx, parentTask) } }, { @@ -2589,15 +2598,7 @@ export class NodeCommand extends BaseCommand { { title: 'Copy node keys to secrets', task: async (ctx, parentTask) => { - const config = /** @type {NodeUpdateConfigClass} **/ ctx.config - - const subTasks = self.platformInstaller.copyNodeKeys(config.stagingDir, config.allNodeIds) - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + return this.copyNodeKeyTask(ctx, parentTask) } }, { @@ -2910,17 +2911,9 @@ export class NodeCommand extends BaseCommand { { title: 'Copy node keys to secrets', task: async (ctx, parentTask) => { - const config = /** @type {NodeDeleteConfigClass} **/ ctx.config - // remove nodeId from existingNodeIds - config.allNodeIds = config.existingNodeIds.filter(nodeId => nodeId !== ctx.config.nodeId) - const subTasks = self.platformInstaller.copyNodeKeys(config.stagingDir, config.allNodeIds) - - // set up the sub-tasks - return parentTask.newListr(subTasks, { - concurrent: true, - rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION - }) + ctx.config.allNodeIds = ctx.config.existingNodeIds.filter(nodeId => nodeId !== ctx.config.nodeId) + return this.copyNodeKeyTask(ctx, parentTask) } }, {