@@ -149,10 +149,9 @@ export class NodeCommandTasks {
149
149
* @returns {Listr<*, *, *> }
150
150
*/
151
151
_uploadPlatformSoftware ( nodeAliases , podNames , task , localBuildPath ) {
152
- const self = this
153
152
const subTasks = [ ]
154
153
155
- self . logger . debug ( 'no need to fetch, use local build jar files' )
154
+ this . logger . debug ( 'no need to fetch, use local build jar files' )
156
155
157
156
/** @type {Map<NodeAlias, string> } */
158
157
const buildPathMap = new Map ( )
@@ -184,11 +183,11 @@ export class NodeCommandTasks {
184
183
title : `Copy local build to Node: ${ chalk . yellow ( nodeAlias ) } from ${ localDataLibBuildPath } ` ,
185
184
task : async ( ) => {
186
185
this . logger . debug ( `Copying build files to pod: ${ podName } from ${ localDataLibBuildPath } ` )
187
- await self . k8 . copyTo ( podName , constants . ROOT_CONTAINER , localDataLibBuildPath , `${ constants . HEDERA_HAPI_PATH } ` )
188
- const testJsonFiles = self . configManager . getFlag ( flags . appConfig ) . split ( ',' )
186
+ await this . k8 . copyTo ( podName , constants . ROOT_CONTAINER , localDataLibBuildPath , `${ constants . HEDERA_HAPI_PATH } ` )
187
+ const testJsonFiles = this . configManager . getFlag ( flags . appConfig ) . split ( ',' )
189
188
for ( const jsonFile of testJsonFiles ) {
190
189
if ( fs . existsSync ( jsonFile ) ) {
191
- await self . k8 . copyTo ( podName , constants . ROOT_CONTAINER , jsonFile , `${ constants . HEDERA_HAPI_PATH } ` )
190
+ await this . k8 . copyTo ( podName , constants . ROOT_CONTAINER , jsonFile , `${ constants . HEDERA_HAPI_PATH } ` )
192
191
}
193
192
}
194
193
}
@@ -385,7 +384,7 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
385
384
return new Task ( 'Generate gossip keys' , async ( ctx , task ) => {
386
385
const config = ctx . config
387
386
const nodeAliases = generateMultiple ? config . nodeAliases : [ config . nodeAlias ]
388
- const subTasks = self . keyManager . taskGenerateGossipKeys ( self . keytoolDepManager , nodeAliases , config . keysDir , config . curDate )
387
+ const subTasks = this . keyManager . taskGenerateGossipKeys ( this . keytoolDepManager , nodeAliases , config . keysDir , config . curDate )
389
388
// set up the sub-tasks
390
389
return task . newListr ( subTasks , {
391
390
concurrent : false ,
@@ -409,7 +408,7 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
409
408
return new Task ( 'Generate gRPC TLS Keys' , async ( ctx , task ) => {
410
409
const config = ctx . config
411
410
const nodeAliases = generateMultiple ? config . nodeAliases : [ config . nodeAlias ]
412
- const subTasks = self . keyManager . taskGenerateTLSKeys ( nodeAliases , config . keysDir , config . curDate )
411
+ const subTasks = this . keyManager . taskGenerateTLSKeys ( nodeAliases , config . keysDir , config . curDate )
413
412
// set up the sub-tasks
414
413
return task . newListr ( subTasks , {
415
414
concurrent : true ,
@@ -810,15 +809,15 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
810
809
return new Task ( 'Check node proxies are ACTIVE' , async ( ctx , task ) => {
811
810
// this is more reliable than checking the nodes logs for ACTIVE, as the
812
811
// logs will have a lot of white noise from being behind
813
- return self . _checkNodesProxiesTask ( ctx , task , ctx . config . nodeAliases )
812
+ return this . _checkNodesProxiesTask ( ctx , task , ctx . config . nodeAliases )
814
813
} , skip )
815
814
}
816
815
817
816
checkAllNodeProxiesAreActive ( ) {
818
817
return new Task ( 'Check all node proxies are ACTIVE' , async ( ctx , task ) => {
819
818
// this is more reliable than checking the nodes logs for ACTIVE, as the
820
819
// logs will have a lot of white noise from being behind
821
- return self . _checkNodesProxiesTask ( ctx , task , ctx . config . allNodeAliases )
820
+ return this . _checkNodesProxiesTask ( ctx , task , ctx . config . allNodeAliases )
822
821
} )
823
822
}
824
823
@@ -885,7 +884,7 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
885
884
const podName = ctx . config . podNames [ nodeAlias ]
886
885
subTasks . push ( {
887
886
title : `Stop node: ${ chalk . yellow ( nodeAlias ) } ` ,
888
- task : async ( ) => await self . k8 . execContainer ( podName , constants . ROOT_CONTAINER , 'systemctl stop network-node' )
887
+ task : async ( ) => await this . k8 . execContainer ( podName , constants . ROOT_CONTAINER , 'systemctl stop network-node' )
889
888
} )
890
889
}
891
890
@@ -903,9 +902,9 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
903
902
finalize ( ) {
904
903
return new Task ( 'Finalize' , async ( ctx , task ) => {
905
904
// reset flags so that keys are not regenerated later
906
- self . configManager . setFlag ( flags . generateGossipKeys , false )
907
- self . configManager . setFlag ( flags . generateTlsKeys , false )
908
- self . configManager . persist ( )
905
+ this . configManager . setFlag ( flags . generateGossipKeys , false )
906
+ this . configManager . setFlag ( flags . generateTlsKeys , false )
907
+ this . configManager . persist ( )
909
908
} )
910
909
}
911
910
@@ -918,7 +917,7 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
918
917
subTasks . push ( {
919
918
title : `Node: ${ chalk . yellow ( nodeAlias ) } ` ,
920
919
task : async ( ) =>
921
- await self . k8 . execContainer ( podName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `rm -rf ${ constants . HEDERA_HAPI_PATH } /data/saved/*` ] )
920
+ await this . k8 . execContainer ( podName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `rm -rf ${ constants . HEDERA_HAPI_PATH } /data/saved/*` ] )
922
921
} )
923
922
}
924
923
@@ -940,7 +939,7 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
940
939
941
940
checkPVCsEnabled ( ) {
942
941
return new Task ( 'Check that PVCs are enabled' , async ( ctx , task ) => {
943
- if ( ! self . configManager . getFlag ( flags . persistentVolumeClaims ) ) {
942
+ if ( ! this . configManager . getFlag ( flags . persistentVolumeClaims ) ) {
944
943
throw new SoloError ( 'PVCs are not enabled. Please enable PVCs before adding a node' )
945
944
}
946
945
} )
@@ -1065,34 +1064,34 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
1065
1064
const config = /** @type {NodeUpdateConfigClass } **/ ctx . config
1066
1065
1067
1066
const nodeId = Templates . nodeIdFromNodeAlias ( config . nodeAlias ) - 1
1068
- self . logger . info ( `nodeId: ${ nodeId } ` )
1069
- self . logger . info ( `config.newAccountNumber: ${ config . newAccountNumber } ` )
1067
+ this . logger . info ( `nodeId: ${ nodeId } ` )
1068
+ this . logger . info ( `config.newAccountNumber: ${ config . newAccountNumber } ` )
1070
1069
1071
1070
try {
1072
1071
const nodeUpdateTx = await new NodeUpdateTransaction ( )
1073
1072
. setNodeId ( nodeId )
1074
1073
1075
1074
if ( config . tlsPublicKey && config . tlsPrivateKey ) {
1076
- self . logger . info ( `config.tlsPublicKey: ${ config . tlsPublicKey } ` )
1075
+ this . logger . info ( `config.tlsPublicKey: ${ config . tlsPublicKey } ` )
1077
1076
const tlsCertDer = await this . _loadPermCertificate ( config . tlsPublicKey )
1078
1077
const tlsCertHash = crypto . createHash ( 'sha384' ) . update ( tlsCertDer ) . digest ( )
1079
1078
nodeUpdateTx . setCertificateHash ( tlsCertHash )
1080
1079
1081
1080
const publicKeyFile = Templates . renderTLSPemPublicKeyFile ( config . nodeAlias )
1082
1081
const privateKeyFile = Templates . renderTLSPemPrivateKeyFile ( config . nodeAlias )
1083
- renameAndCopyFile ( config . tlsPublicKey , publicKeyFile , config . keysDir )
1084
- renameAndCopyFile ( config . tlsPrivateKey , privateKeyFile , config . keysDir )
1082
+ renameAndCopyFile ( config . tlsPublicKey , publicKeyFile , config . keysDir , this . logger )
1083
+ renameAndCopyFile ( config . tlsPrivateKey , privateKeyFile , config . keysDir , this . logger )
1085
1084
}
1086
1085
1087
1086
if ( config . gossipPublicKey && config . gossipPrivateKey ) {
1088
- self . logger . info ( `config.gossipPublicKey: ${ config . gossipPublicKey } ` )
1087
+ this . logger . info ( `config.gossipPublicKey: ${ config . gossipPublicKey } ` )
1089
1088
const signingCertDer = await this . _loadPermCertificate ( config . gossipPublicKey )
1090
1089
nodeUpdateTx . setGossipCaCertificate ( signingCertDer )
1091
1090
1092
1091
const publicKeyFile = Templates . renderGossipPemPublicKeyFile ( constants . SIGNING_KEY_PREFIX , config . nodeAlias )
1093
1092
const privateKeyFile = Templates . renderGossipPemPrivateKeyFile ( constants . SIGNING_KEY_PREFIX , config . nodeAlias )
1094
- renameAndCopyFile ( config . gossipPublicKey , publicKeyFile , config . keysDir )
1095
- renameAndCopyFile ( config . gossipPrivateKey , privateKeyFile , config . keysDir )
1093
+ renameAndCopyFile ( config . gossipPublicKey , publicKeyFile , config . keysDir , this . logger )
1094
+ renameAndCopyFile ( config . gossipPrivateKey , privateKeyFile , config . keysDir , this . logger )
1096
1095
}
1097
1096
1098
1097
if ( config . newAccountNumber ) {
@@ -1215,7 +1214,7 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
1215
1214
return new Task ( 'Kill nodes' , async ( ctx , task ) => {
1216
1215
const config = ctx . config
1217
1216
for ( const /** @type {NetworkNodeServices } **/ service of config . serviceMap . values ( ) ) {
1218
- await self . k8 . kubeClient . deleteNamespacedPod ( service . nodePodName , config . namespace , undefined , undefined , 1 )
1217
+ await this . k8 . kubeClient . deleteNamespacedPod ( service . nodePodName , config . namespace , undefined , undefined , 1 )
1219
1218
}
1220
1219
} )
1221
1220
}
@@ -1224,16 +1223,16 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
1224
1223
return new Task ( 'Kill nodes to pick up updated configMaps' , async ( ctx , task ) => {
1225
1224
const config = ctx . config
1226
1225
// the updated node will have a new pod ID if its account ID changed which is a label
1227
- config . serviceMap = await self . accountManager . getNodeServiceMap (
1226
+ config . serviceMap = await this . accountManager . getNodeServiceMap (
1228
1227
config . namespace )
1229
1228
for ( const /** @type {NetworkNodeServices } **/ service of config . serviceMap . values ( ) ) {
1230
- await self . k8 . kubeClient . deleteNamespacedPod ( service . nodePodName , config . namespace , undefined , undefined , 1 )
1229
+ await this . k8 . kubeClient . deleteNamespacedPod ( service . nodePodName , config . namespace , undefined , undefined , 1 )
1231
1230
}
1232
- self . logger . info ( 'sleep for 15 seconds to give time for pods to finish terminating' )
1231
+ this . logger . info ( 'sleep for 15 seconds to give time for pods to finish terminating' )
1233
1232
await sleep ( 15000 )
1234
1233
1235
1234
// again, the pod names will change after the pods are killed
1236
- config . serviceMap = await self . accountManager . getNodeServiceMap (
1235
+ config . serviceMap = await this . accountManager . getNodeServiceMap (
1237
1236
config . namespace )
1238
1237
config . podNames = { }
1239
1238
for ( const service of config . serviceMap . values ( ) ) {
@@ -1281,8 +1280,8 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
1281
1280
const node1FullyQualifiedPodName = Templates . renderNetworkPodName ( config . existingNodeAliases [ 0 ] )
1282
1281
const upgradeDirectory = `${ constants . HEDERA_HAPI_PATH } /data/saved/com.hedera.services.ServicesMain/0/123`
1283
1282
// zip the contents of the newest folder on node1 within /opt/hgcapp/services-hedera/HapiApp2.0/data/saved/com.hedera.services.ServicesMain/0/123/
1284
- const zipFileName = await self . k8 . execContainer ( node1FullyQualifiedPodName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `cd ${ upgradeDirectory } && mapfile -t states < <(ls -1t .) && jar cf "\${states[0]}.zip" -C "\${states[0]}" . && echo -n \${states[0]}.zip` ] )
1285
- await self . k8 . copyFrom ( node1FullyQualifiedPodName , constants . ROOT_CONTAINER , `${ upgradeDirectory } /${ zipFileName } ` , config . stagingDir )
1283
+ const zipFileName = await this . k8 . execContainer ( node1FullyQualifiedPodName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `cd ${ upgradeDirectory } && mapfile -t states < <(ls -1t .) && jar cf "\${states[0]}.zip" -C "\${states[0]}" . && echo -n \${states[0]}.zip` ] )
1284
+ await this . k8 . copyFrom ( node1FullyQualifiedPodName , constants . ROOT_CONTAINER , `${ upgradeDirectory } /${ zipFileName } ` , config . stagingDir )
1286
1285
config . lastStateZipPath = path . join ( config . stagingDir , zipFileName )
1287
1286
} )
1288
1287
}
@@ -1294,10 +1293,10 @@ _fetchPlatformSoftware (nodeAliases, podNames, releaseTag, task, platformInstall
1294
1293
const nodeId = Templates . nodeIdFromNodeAlias ( config . nodeAlias )
1295
1294
const savedStateDir = ( config . lastStateZipPath . match ( / \/ ( \d + ) \. z i p $ / ) ) [ 1 ]
1296
1295
const savedStatePath = `${ constants . HEDERA_HAPI_PATH } /data/saved/com.hedera.services.ServicesMain/${ nodeId } /123/${ savedStateDir } `
1297
- await self . k8 . execContainer ( newNodeFullyQualifiedPodName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `mkdir -p ${ savedStatePath } ` ] )
1298
- await self . k8 . copyTo ( newNodeFullyQualifiedPodName , constants . ROOT_CONTAINER , config . lastStateZipPath , savedStatePath )
1299
- await self . platformInstaller . setPathPermission ( newNodeFullyQualifiedPodName , constants . HEDERA_HAPI_PATH )
1300
- await self . k8 . execContainer ( newNodeFullyQualifiedPodName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `cd ${ savedStatePath } && jar xf ${ path . basename ( config . lastStateZipPath ) } && rm -f ${ path . basename ( config . lastStateZipPath ) } ` ] )
1296
+ await this . k8 . execContainer ( newNodeFullyQualifiedPodName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `mkdir -p ${ savedStatePath } ` ] )
1297
+ await this . k8 . copyTo ( newNodeFullyQualifiedPodName , constants . ROOT_CONTAINER , config . lastStateZipPath , savedStatePath )
1298
+ await this . platformInstaller . setPathPermission ( newNodeFullyQualifiedPodName , constants . HEDERA_HAPI_PATH )
1299
+ await this . k8 . execContainer ( newNodeFullyQualifiedPodName , constants . ROOT_CONTAINER , [ 'bash' , '-c' , `cd ${ savedStatePath } && jar xf ${ path . basename ( config . lastStateZipPath ) } && rm -f ${ path . basename ( config . lastStateZipPath ) } ` ] )
1301
1300
} )
1302
1301
}
1303
1302
0 commit comments