Skip to content

Commit d8e5032

Browse files
fix: added missing async/await where needed (#551)
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent f639a3b commit d8e5032

12 files changed

+95
-70
lines changed

src/commands/mirror_node.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,43 +179,43 @@ export class MirrorNodeCommand extends BaseCommand {
179179
const subTasks = [
180180
{
181181
title: 'Check Postgres DB',
182-
task: async (ctx, _) => self.k8.waitForPodReady([
182+
task: async (ctx, _) => await self.k8.waitForPodReady([
183183
'app.kubernetes.io/component=postgresql',
184184
'app.kubernetes.io/name=postgres'
185185
], 1, 300, 2000)
186186
},
187187
{
188188
title: 'Check REST API',
189-
task: async (ctx, _) => self.k8.waitForPodReady([
189+
task: async (ctx, _) => await self.k8.waitForPodReady([
190190
'app.kubernetes.io/component=rest',
191191
'app.kubernetes.io/name=rest'
192192
], 1, 300, 2000)
193193
},
194194
{
195195
title: 'Check GRPC',
196-
task: async (ctx, _) => self.k8.waitForPodReady([
196+
task: async (ctx, _) => await self.k8.waitForPodReady([
197197
'app.kubernetes.io/component=grpc',
198198
'app.kubernetes.io/name=grpc'
199199
], 1, 300, 2000)
200200
},
201201
{
202202
title: 'Check Monitor',
203-
task: async (ctx, _) => self.k8.waitForPodReady([
203+
task: async (ctx, _) => await self.k8.waitForPodReady([
204204
'app.kubernetes.io/component=monitor',
205205
'app.kubernetes.io/name=monitor'
206206
], 1, 300, 2000)
207207
},
208208
{
209209
title: 'Check Importer',
210-
task: async (ctx, _) => self.k8.waitForPodReady([
210+
task: async (ctx, _) => await self.k8.waitForPodReady([
211211
'app.kubernetes.io/component=importer',
212212
'app.kubernetes.io/name=importer'
213213
], 1, 300, 2000)
214214
},
215215
{
216216
title: 'Check Hedera Explorer',
217217
skip: (ctx, _) => !ctx.config.deployHederaExplorer,
218-
task: async (ctx, _) => self.k8.waitForPodReady([
218+
task: async (ctx, _) => await self.k8.waitForPodReady([
219219
'app.kubernetes.io/component=hedera-explorer',
220220
'app.kubernetes.io/name=hedera-explorer'
221221
], 1, 300, 2000)

src/commands/network.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ export class NetworkCommand extends BaseCommand {
366366
for (const nodeId of config.nodeIds) {
367367
subTasks.push({
368368
title: `Check Node: ${chalk.yellow(nodeId)}`,
369-
task: () =>
370-
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
369+
task: async () =>
370+
await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
371371
'fullstack.hedera.com/type=network-node',
372372
`fullstack.hedera.com/node-name=${nodeId}`
373373
], 1, 60 * 15, 1000) // timeout 15 minutes
@@ -394,8 +394,8 @@ export class NetworkCommand extends BaseCommand {
394394
for (const nodeId of config.nodeIds) {
395395
subTasks.push({
396396
title: `Check HAProxy for: ${chalk.yellow(nodeId)}`,
397-
task: () =>
398-
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
397+
task: async () =>
398+
await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
399399
'fullstack.hedera.com/type=haproxy'
400400
], 1, 60 * 15, 1000) // timeout 15 minutes
401401
})
@@ -405,8 +405,8 @@ export class NetworkCommand extends BaseCommand {
405405
for (const nodeId of config.nodeIds) {
406406
subTasks.push({
407407
title: `Check Envoy Proxy for: ${chalk.yellow(nodeId)}`,
408-
task: () =>
409-
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
408+
task: async () =>
409+
await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
410410
'fullstack.hedera.com/type=envoy-proxy'
411411
], 1, 60 * 15, 1000) // timeout 15 minutes
412412
})
@@ -430,8 +430,8 @@ export class NetworkCommand extends BaseCommand {
430430
// minio
431431
subTasks.push({
432432
title: 'Check MinIO',
433-
task: () =>
434-
self.k8.waitForPodReady([
433+
task: async () =>
434+
await self.k8.waitForPodReady([
435435
'v1.min.io/tenant=minio'
436436
], 1, 60 * 5, 1000) // timeout 5 minutes
437437
})

src/commands/node.mjs

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ export class NodeCommand extends BaseCommand {
530530
const podName = podNames[nodeId]
531531
subTasks.push({
532532
title: `Update node: ${chalk.yellow(nodeId)} [ platformVersion = ${releaseTag} ]`,
533-
task: () =>
534-
platformInstaller.fetchPlatform(podName, releaseTag)
533+
task: async () =>
534+
await platformInstaller.fetchPlatform(podName, releaseTag)
535535
})
536536
}
537537

@@ -834,12 +834,12 @@ export class NodeCommand extends BaseCommand {
834834
if (self.configManager.getFlag(flags.app) !== '' && self.configManager.getFlag(flags.app) !== constants.HEDERA_APP_NAME) {
835835
subTasks.push({
836836
title: `Check node: ${chalk.yellow(nodeId)}`,
837-
task: () => self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log')
837+
task: async () => await self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log')
838838
})
839839
} else {
840840
subTasks.push({
841841
title: `Check node: ${chalk.yellow(nodeId)}`,
842-
task: () => self.checkNetworkNodeState(nodeId)
842+
task: async () => await self.checkNetworkNodeState(nodeId)
843843
})
844844
}
845845
}
@@ -886,7 +886,7 @@ export class NodeCommand extends BaseCommand {
886886
const accountId = accountMap.get(nodeId)
887887
subTasks.push({
888888
title: `Adding stake for node: ${chalk.yellow(nodeId)}`,
889-
task: () => self.addStake(ctx.config.namespace, accountId, nodeId)
889+
task: async () => await self.addStake(ctx.config.namespace, accountId, nodeId)
890890
})
891891
}
892892

@@ -955,7 +955,7 @@ export class NodeCommand extends BaseCommand {
955955
const podName = ctx.config.podNames[nodeId]
956956
subTasks.push({
957957
title: `Stop node: ${chalk.yellow(nodeId)}`,
958-
task: () => self.k8.execContainer(podName, constants.ROOT_CONTAINER, 'systemctl stop network-node')
958+
task: async () => await self.k8.execContainer(podName, constants.ROOT_CONTAINER, 'systemctl stop network-node')
959959
})
960960
}
961961

@@ -1235,12 +1235,12 @@ export class NodeCommand extends BaseCommand {
12351235
if (config.app !== '' && config.app !== constants.HEDERA_APP_NAME) {
12361236
subTasks.push({
12371237
title: `Check node: ${chalk.yellow(nodeId)}`,
1238-
task: () => self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log')
1238+
task: async () => await self.checkNetworkNodeState(nodeId, 100, 'ACTIVE', 'output/swirlds.log')
12391239
})
12401240
} else {
12411241
subTasks.push({
12421242
title: `Check node: ${chalk.yellow(nodeId)}`,
1243-
task: () => self.checkNetworkNodeState(nodeId)
1243+
task: async () => await self.checkNetworkNodeState(nodeId)
12441244
})
12451245
}
12461246
}
@@ -1615,6 +1615,7 @@ export class NodeCommand extends BaseCommand {
16151615
title: 'Check existing nodes staked amount',
16161616
task: async (ctx, task) => {
16171617
const config = /** @type {NodeAddConfigClass} **/ ctx.config
1618+
self.logger.info('sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate')
16181619
await sleep(60000)
16191620
const accountMap = getNodeAccountMap(config.existingNodeIds)
16201621
for (const nodeId of config.existingNodeIds) {
@@ -1729,7 +1730,7 @@ export class NodeCommand extends BaseCommand {
17291730
for (const nodeId of config.existingNodeIds) {
17301731
subTasks.push({
17311732
title: `Check node: ${chalk.yellow(nodeId)}`,
1732-
task: () => self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE')
1733+
task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE')
17331734
})
17341735
}
17351736

@@ -1796,8 +1797,8 @@ export class NodeCommand extends BaseCommand {
17961797
for (const nodeId of config.allNodeIds) {
17971798
subTasks.push({
17981799
title: `Check Node: ${chalk.yellow(nodeId)}`,
1799-
task: () =>
1800-
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
1800+
task: async () =>
1801+
await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
18011802
'fullstack.hedera.com/type=network-node',
18021803
`fullstack.hedera.com/node-name=${nodeId}`
18031804
], 1, 60 * 15, 1000) // timeout 15 minutes
@@ -1896,12 +1897,12 @@ export class NodeCommand extends BaseCommand {
18961897
title: 'Check all nodes are ACTIVE',
18971898
task: async (ctx, task) => {
18981899
const subTasks = []
1899-
// sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string
1900+
self.logger.info('sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string')
19001901
await sleep(30000)
19011902
for (const nodeId of ctx.config.allNodeIds) {
19021903
subTasks.push({
19031904
title: `Check node: ${chalk.yellow(nodeId)}`,
1904-
task: () => self.checkNetworkNodeState(nodeId, 200)
1905+
task: async () => await self.checkNetworkNodeState(nodeId, 200)
19051906
})
19061907
}
19071908

@@ -1941,9 +1942,9 @@ export class NodeCommand extends BaseCommand {
19411942
},
19421943
{
19431944
title: 'Stake new node',
1944-
task: (ctx, _) => {
1945+
task: async (ctx, _) => {
19451946
const config = /** @type {NodeAddConfigClass} **/ ctx.config
1946-
self.addStake(config.namespace, ctx.newNode.accountId, config.nodeId)
1947+
await self.addStake(config.namespace, ctx.newNode.accountId, config.nodeId)
19471948
}
19481949
},
19491950
{
@@ -2606,7 +2607,7 @@ export class NodeCommand extends BaseCommand {
26062607
for (const nodeId of config.existingNodeIds) {
26072608
subTasks.push({
26082609
title: `Check node: ${chalk.yellow(nodeId)}`,
2609-
task: () => self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE')
2610+
task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE')
26102611
})
26112612
}
26122613

@@ -2669,6 +2670,9 @@ export class NodeCommand extends BaseCommand {
26692670
for (const /** @type {NetworkNodeServices} **/ service of config.serviceMap.values()) {
26702671
await self.k8.kubeClient.deleteNamespacedPod(service.nodePodName, config.namespace, undefined, undefined, 1)
26712672
}
2673+
self.logger.info('sleep for 15 seconds to give time for pods to finish terminating')
2674+
await sleep(15000)
2675+
26722676
// again, the pod names will change after the pods are killed
26732677
config.serviceMap = await self.accountManager.getNodeServiceMap(
26742678
config.namespace)
@@ -2679,7 +2683,7 @@ export class NodeCommand extends BaseCommand {
26792683
}
26802684
},
26812685
{
2682-
title: 'Check node pods are running',
2686+
title: 'Check node pods are ready',
26832687
task:
26842688
async (ctx, task) => {
26852689
const subTasks = []
@@ -2689,11 +2693,11 @@ export class NodeCommand extends BaseCommand {
26892693
for (const nodeId of config.allNodeIds) {
26902694
subTasks.push({
26912695
title: `Check Node: ${chalk.yellow(nodeId)}`,
2692-
task: () =>
2693-
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
2694-
'fullstack.hedera.com/type=network-node',
2695-
`fullstack.hedera.com/node-name=${nodeId}`
2696-
], 1, 60 * 15, 1000) // timeout 15 minutes
2696+
task: async () =>
2697+
await self.k8.waitForPodReady(
2698+
['fullstack.hedera.com/type=network-node',
2699+
`fullstack.hedera.com/node-name=${nodeId}`],
2700+
1, 300, 2000)
26972701
})
26982702
}
26992703

@@ -2710,9 +2714,6 @@ export class NodeCommand extends BaseCommand {
27102714
title: 'Fetch platform software into network nodes',
27112715
task:
27122716
async (ctx, task) => {
2713-
// without this sleep, copy software from local build to container sometimes fail
2714-
await sleep(15000)
2715-
27162717
const config = /** @type {NodeUpdateConfigClass} **/ ctx.config
27172718
return self.fetchLocalOrReleasedPlatformSoftware(config.allNodeIds, config.podNames, config.releaseTag, task, config.localBuildPath)
27182719
}
@@ -2761,12 +2762,12 @@ export class NodeCommand extends BaseCommand {
27612762
title: 'Check all nodes are ACTIVE',
27622763
task: async (ctx, task) => {
27632764
const subTasks = []
2764-
// sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string
2765+
self.logger.info('sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string')
27652766
await sleep(30000)
27662767
for (const nodeId of ctx.config.allNodeIds) {
27672768
subTasks.push({
27682769
title: `Check node: ${chalk.yellow(nodeId)}`,
2769-
task: () => self.checkNetworkNodeState(nodeId, 200)
2770+
task: async () => await self.checkNetworkNodeState(nodeId, 200)
27702771
})
27712772
}
27722773

@@ -3098,7 +3099,7 @@ export class NodeCommand extends BaseCommand {
30983099
for (const nodeId of config.existingNodeIds) {
30993100
subTasks.push({
31003101
title: `Check node: ${chalk.yellow(nodeId)}`,
3101-
task: () => self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE')
3102+
task: async () => await self.checkNetworkNodeState(nodeId, 100, 'FREEZE_COMPLETE')
31023103
})
31033104
}
31043105

@@ -3157,6 +3158,7 @@ export class NodeCommand extends BaseCommand {
31573158
title: 'Check node pods are running',
31583159
task:
31593160
async (ctx, task) => {
3161+
self.logger.info('sleep 20 seconds to give time for pods to come up after being killed')
31603162
await sleep(20000)
31613163
const subTasks = []
31623164
const config = /** @type {NodeDeleteConfigClass} **/ ctx.config
@@ -3165,8 +3167,8 @@ export class NodeCommand extends BaseCommand {
31653167
for (const nodeId of config.allNodeIds) {
31663168
subTasks.push({
31673169
title: `Check Node: ${chalk.yellow(nodeId)}`,
3168-
task: () =>
3169-
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
3170+
task: async () =>
3171+
await self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
31703172
'fullstack.hedera.com/type=network-node',
31713173
`fullstack.hedera.com/node-name=${nodeId}`
31723174
], 1, 60 * 15, 1000) // timeout 15 minutes
@@ -3238,12 +3240,12 @@ export class NodeCommand extends BaseCommand {
32383240
title: 'Check all nodes are ACTIVE',
32393241
task: async (ctx, task) => {
32403242
const subTasks = []
3241-
// sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string
3243+
self.logger.info('sleep for 30 seconds to give time for the logs to roll over to prevent capturing an invalid "ACTIVE" string')
32423244
await sleep(30000)
32433245
for (const nodeId of ctx.config.allNodeIds) {
32443246
subTasks.push({
32453247
title: `Check node: ${chalk.yellow(nodeId)}`,
3246-
task: () => self.checkNetworkNodeState(nodeId, 200)
3248+
task: async () => await self.checkNetworkNodeState(nodeId, 200)
32473249
})
32483250
}
32493251

@@ -3285,7 +3287,7 @@ export class NodeCommand extends BaseCommand {
32853287
title: 'Trigger stake weight calculate',
32863288
task: async (ctx, task) => {
32873289
const config = /** @type {NodeDeleteConfigClass} **/ ctx.config
3288-
// sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate
3290+
self.logger.info('sleep 60 seconds for the handler to be able to trigger the network node stake weight recalculate')
32893291
await sleep(60000)
32903292
const accountMap = getNodeAccountMap(config.allNodeIds)
32913293
// send some write transactions to invoke the handler that will trigger the stake weight recalculate

src/core/account_manager.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export class AccountManager {
179179
* @returns {Promise<void>}
180180
*/
181181
async refreshNodeClient (namespace) {
182+
await this.close()
182183
const treasuryAccountInfo = await this.getTreasuryAccountKeys(namespace)
183184
const networkNodeServicesMap = await this.getNodeServiceMap(namespace)
184185

src/core/k8.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export class K8 {
441441
return await this.execContainer(
442442
podName,
443443
containerName,
444-
['sh', '-c', '[[ -d "' + destPath + '" ]] && echo -n "true" || echo -n "false"']
444+
['bash', '-c', '[[ -d "' + destPath + '" ]] && echo -n "true" || echo -n "false"']
445445
) === 'true'
446446
}
447447

@@ -455,7 +455,7 @@ export class K8 {
455455
return this.execContainer(
456456
podName,
457457
containerName,
458-
['sh', '-c', 'mkdir -p "' + destPath + '"']
458+
['bash', '-c', 'mkdir -p "' + destPath + '"']
459459
)
460460
}
461461

src/core/key_manager.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ export class KeyManager {
758758

759759
subTasks.push({
760760
title: `Check keytool exists (Version: ${keytoolDepManager.getKeytoolVersion()})`,
761-
task: async () => keytoolDepManager.checkVersion(true)
761+
task: async () => await keytoolDepManager.checkVersion(true)
762762

763763
})
764764

src/core/platform_installer.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ export class PlatformInstaller {
290290
return new Listr([
291291
{
292292
title: 'Set file permissions',
293-
task: (_, task) =>
294-
self.setPlatformDirPermissions(podName)
293+
task: async (_, task) =>
294+
await self.setPlatformDirPermissions(podName)
295295
}
296296
],
297297
{
@@ -323,17 +323,17 @@ export class PlatformInstaller {
323323
const subTasks = []
324324
subTasks.push({
325325
title: 'Copy TLS keys',
326-
task: (_, task) =>
327-
self.copyTLSKeys(nodeIds, stagingDir, keyFormat)
326+
task: async (_, task) =>
327+
await self.copyTLSKeys(nodeIds, stagingDir, keyFormat)
328328
})
329329

330330
for (const nodeId of nodeIds) {
331331
subTasks.push({
332332
title: `Node: ${chalk.yellow(nodeId)}`,
333333
task: () => new Listr([{
334334
title: 'Copy Gossip keys',
335-
task: (_, task) =>
336-
self.copyGossipKeys(nodeId, stagingDir, nodeIds, keyFormat)
335+
task: async (_, task) =>
336+
await self.copyGossipKeys(nodeId, stagingDir, nodeIds, keyFormat)
337337
}
338338
],
339339
{

0 commit comments

Comments
 (0)