@@ -77,7 +77,7 @@ export class NodeCommand extends BaseCommand {
77
77
const podName = Templates . renderNetworkPodName ( nodeId )
78
78
79
79
try {
80
- await this . k8 . waitForPodReady ( [
80
+ await this . k8 . waitForPods ( [ constants . POD_PHASE_RUNNING ] , [
81
81
'fullstack.hedera.com/type=network-node' ,
82
82
`fullstack.hedera.com/node-name=${ nodeId } `
83
83
] , 1 , maxAttempts , delay )
@@ -556,11 +556,7 @@ export class NodeCommand extends BaseCommand {
556
556
const configTxtPath = `${ config . stagingDir } /config.txt`
557
557
const template = `${ constants . RESOURCES_DIR } /templates/config.template`
558
558
const appName = self . configManager . getFlag ( flags . app )
559
- if ( appName !== '' ) {
560
- await self . platformInstaller . prepareConfigTxt ( config . nodeIds , configTxtPath , config . releaseTag , config . chainId , template , appName )
561
- } else {
562
- await self . platformInstaller . prepareConfigTxt ( config . nodeIds , configTxtPath , config . releaseTag , config . chainId , template )
563
- }
559
+ await self . platformInstaller . prepareConfigTxt ( config . nodeIds , configTxtPath , config . releaseTag , config . chainId , template , appName || undefined )
564
560
}
565
561
}
566
562
]
@@ -706,11 +702,12 @@ export class NodeCommand extends BaseCommand {
706
702
title : 'Check node proxies are ACTIVE' ,
707
703
task : async ( ctx , parentTask ) => {
708
704
const subTasks = [ ]
709
- let localPort = constants . LOCAL_NODE_PROXY_START_PORT
710
705
for ( const nodeId of ctx . config . nodeIds ) {
711
706
subTasks . push ( {
712
707
title : `Check proxy for node: ${ chalk . yellow ( nodeId ) } ` ,
713
- task : async ( ) => await self . checkNetworkNodeProxyUp ( nodeId , localPort ++ )
708
+ task : async ( ) => await self . k8 . waitForPodReady (
709
+ [ `app=haproxy-${ nodeId } ` , 'fullstack.hedera.com/type=haproxy' ] ,
710
+ 1 , 300 , 2000 )
714
711
} )
715
712
}
716
713
@@ -740,93 +737,6 @@ export class NodeCommand extends BaseCommand {
740
737
return true
741
738
}
742
739
743
- /**
744
- * Check if the network node proxy is up, requires close() to be called after
745
- * @param nodeId the node id
746
- * @param localPort the local port to forward to
747
- * @param maxAttempts the maximum number of attempts
748
- * @param delay the delay between attempts
749
- * @returns {Promise<boolean> } true if the proxy is up
750
- */
751
- async checkNetworkNodeProxyUp ( nodeId , localPort , maxAttempts = 6 , delay = 20000 ) {
752
- const podLabels = [ `app=haproxy-${ nodeId } ` , 'fullstack.hedera.com/type=haproxy' ]
753
- let podArray = await this . k8 . getPodsByLabel ( podLabels )
754
-
755
- let attempts = 0
756
- let status = null
757
- if ( podArray . length > 0 ) {
758
- let podName = podArray [ 0 ] . metadata . name
759
- let portForwarder = null
760
-
761
- try {
762
- while ( attempts < maxAttempts ) {
763
- if ( attempts === 0 ) {
764
- try {
765
- portForwarder = await this . k8 . portForward ( podName , localPort , 5555 )
766
- } catch ( e ) {
767
- throw new FullstackTestingError ( `failed to portForward for podName ${ podName } with localPort ${ localPort } : ${ e . message } ` , e )
768
- }
769
- try {
770
- await this . k8 . testConnection ( 'localhost' , localPort )
771
- } catch ( e ) {
772
- throw new FullstackTestingError ( `failed to test connection for podName ${ podName } with localPort ${ localPort } : ${ e . message } ` , e )
773
- }
774
- } else if ( attempts % 5 === 0 ) {
775
- this . logger . debug ( `Recycling proxy ${ podName } [attempt: ${ attempts } /${ maxAttempts } ]` )
776
- try {
777
- await this . k8 . stopPortForward ( portForwarder )
778
- } catch ( e ) {
779
- throw new FullstackTestingError ( `failed to stop portForward for podName ${ podName } with localPort ${ localPort } : ${ e . message } ` , e )
780
- }
781
- try {
782
- await this . k8 . recyclePodByLabels ( podLabels )
783
- } catch ( e ) {
784
- throw new FullstackTestingError ( `failed to recycle pod for podName ${ podName } with localPort ${ localPort } : ${ e . message } ` , e )
785
- }
786
- podArray = await this . k8 . getPodsByLabel ( podLabels )
787
- podName = podArray [ 0 ] . metadata . name
788
- try {
789
- portForwarder = await this . k8 . portForward ( podName , localPort , 5555 )
790
- } catch ( e ) {
791
- throw new FullstackTestingError ( `failed to portForward for podName ${ podName } with localPort ${ localPort } : ${ e . message } ` , e )
792
- }
793
- try {
794
- await this . k8 . testConnection ( 'localhost' , localPort )
795
- } catch ( e ) {
796
- throw new FullstackTestingError ( `failed to test connection for podName ${ podName } with localPort ${ localPort } : ${ e . message } ` , e )
797
- }
798
- }
799
-
800
- try {
801
- status = await this . getNodeProxyStatus ( `http://localhost:${ localPort } /v2/services/haproxy/stats/native?type=backend` )
802
- } catch ( e ) {
803
- throw new FullstackTestingError ( `failed to get proxy status at http://localhost:${ localPort } /v2/services/haproxy/stats/native?type=backend: ${ e . message } ` , e )
804
- }
805
- if ( status === 'UP' ) {
806
- break
807
- }
808
-
809
- this . logger . debug ( `Proxy ${ podName } is not UP. Checking again in ${ delay } ms ... [attempt: ${ attempts } /${ maxAttempts } ]` )
810
- attempts ++
811
- await sleep ( delay )
812
- }
813
- } catch ( e ) {
814
- throw new FullstackTestingError ( `failed to check proxy for '${ nodeId } ' with localPort ${ localPort } : ${ e . message } ` , e )
815
- } finally {
816
- if ( portForwarder !== null ) {
817
- this . _portForwards . push ( portForwarder )
818
- }
819
- }
820
-
821
- if ( status === 'UP' ) {
822
- this . logger . debug ( `Proxy ${ podName } is UP. [attempt: ${ attempts } /${ maxAttempts } ]` )
823
- return true
824
- }
825
- }
826
-
827
- throw new FullstackTestingError ( `proxy for '${ nodeId } ' is not UP [ attempt = ${ attempts } /${ maxAttempts } ` )
828
- }
829
-
830
740
async stop ( argv ) {
831
741
const self = this
832
742
@@ -1052,10 +962,11 @@ export class NodeCommand extends BaseCommand {
1052
962
1053
963
const subTasks = [ ]
1054
964
const nodeList = [ ]
1055
- const serviceMap = await self . accountManager . getNodeServiceMap ( ctx . config . namespace )
1056
- for ( const serviceObject of serviceMap . values ( ) ) {
1057
- nodeList . push ( serviceObject . node )
965
+ const networkNodeServicesMap = await self . accountManager . getNodeServiceMap ( ctx . config . namespace )
966
+ for ( const networkNodeServices of networkNodeServicesMap . values ( ) ) {
967
+ nodeList . push ( networkNodeServices . nodeName )
1058
968
}
969
+
1059
970
for ( const nodeId of config . nodeIds ) {
1060
971
const podName = config . podNames [ nodeId ]
1061
972
subTasks . push ( {
@@ -1131,11 +1042,12 @@ export class NodeCommand extends BaseCommand {
1131
1042
// logs will have a lot of white noise from being behind
1132
1043
task : async ( ctx , task ) => {
1133
1044
const subTasks = [ ]
1134
- let localPort = constants . LOCAL_NODE_PROXY_START_PORT
1135
1045
for ( const nodeId of ctx . config . nodeIds ) {
1136
1046
subTasks . push ( {
1137
1047
title : `Check proxy for node: ${ chalk . yellow ( nodeId ) } ` ,
1138
- task : async ( ) => await self . checkNetworkNodeProxyUp ( nodeId , localPort ++ )
1048
+ task : async ( ) => await self . k8 . waitForPodReady (
1049
+ [ `app=haproxy-${ nodeId } ` , 'fullstack.hedera.com/type=haproxy' ] ,
1050
+ 1 , 300 , 2000 )
1139
1051
} )
1140
1052
}
1141
1053
@@ -1217,8 +1129,8 @@ export class NodeCommand extends BaseCommand {
1217
1129
task : async ( ctx , task ) => {
1218
1130
ctx . config . serviceMap = await self . accountManager . getNodeServiceMap (
1219
1131
ctx . config . namespace )
1220
- for ( const serviceObject of ctx . config . serviceMap . values ( ) ) {
1221
- ctx . config . existingNodeIds . push ( serviceObject . node )
1132
+ for ( /** @type { NetworkNodeServices } **/ const networkNodeServices of ctx . config . serviceMap . values ( ) ) {
1133
+ ctx . config . existingNodeIds . push ( networkNodeServices . nodeName )
1222
1134
}
1223
1135
1224
1136
return self . taskCheckNetworkNodePods ( ctx , task , ctx . config . existingNodeIds )
@@ -1229,12 +1141,14 @@ export class NodeCommand extends BaseCommand {
1229
1141
task : async ( ctx , task ) => {
1230
1142
const values = { hedera : { nodes : [ ] } }
1231
1143
let maxNum
1232
- for ( const serviceObject of ctx . config . serviceMap . values ( ) ) {
1144
+ for ( /** @type { NetworkNodeServices } **/ const networkNodeServices of ctx . config . serviceMap . values ( ) ) {
1233
1145
values . hedera . nodes . push ( {
1234
- accountId : serviceObject . accountId ,
1235
- name : serviceObject . node
1146
+ accountId : networkNodeServices . accountId ,
1147
+ name : networkNodeServices . nodeName
1236
1148
} )
1237
- maxNum = maxNum > AccountId . fromString ( serviceObject . accountId ) . num ? maxNum : AccountId . fromString ( serviceObject . accountId ) . num
1149
+ maxNum = maxNum > AccountId . fromString ( networkNodeServices . accountId ) . num
1150
+ ? maxNum
1151
+ : AccountId . fromString ( networkNodeServices . accountId ) . num
1238
1152
}
1239
1153
for ( const nodeId of ctx . config . nodeIds ) {
1240
1154
const accountId = AccountId . fromString ( values . hedera . nodes [ 0 ] . accountId )
@@ -1474,11 +1388,12 @@ export class NodeCommand extends BaseCommand {
1474
1388
// logs will have a lot of white noise from being behind
1475
1389
task : async ( ctx , task ) => {
1476
1390
const subTasks = [ ]
1477
- let localPort = constants . LOCAL_NODE_PROXY_START_PORT
1478
- for ( const nodeId of ctx . config . allNodeIds ) {
1391
+ for ( const nodeId of ctx . config . nodeIds ) {
1479
1392
subTasks . push ( {
1480
1393
title : `Check proxy for node: ${ chalk . yellow ( nodeId ) } ` ,
1481
- task : async ( ) => await self . checkNetworkNodeProxyUp ( nodeId , localPort ++ )
1394
+ task : async ( ) => await self . k8 . waitForPodReady (
1395
+ [ `app=haproxy-${ nodeId } ` , 'fullstack.hedera.com/type=haproxy' ] ,
1396
+ 1 , 300 , 2000 )
1482
1397
} )
1483
1398
}
1484
1399
@@ -1781,33 +1696,6 @@ export class NodeCommand extends BaseCommand {
1781
1696
}
1782
1697
}
1783
1698
1784
- async getNodeProxyStatus ( url ) {
1785
- try {
1786
- this . logger . debug ( `Fetching proxy status from: ${ url } ` )
1787
- const res = await fetch ( url , {
1788
- method : 'GET' ,
1789
- signal : AbortSignal . timeout ( 5000 ) ,
1790
- headers : {
1791
- Authorization : `Basic ${ Buffer . from (
1792
- `${ constants . NODE_PROXY_USER_ID } :${ constants . NODE_PROXY_PASSWORD } ` ) . toString ( 'base64' ) } `
1793
- }
1794
- } )
1795
- const response = await res . json ( )
1796
-
1797
- if ( res . status === 200 ) {
1798
- const status = response [ 0 ] ?. stats ?. filter (
1799
- ( stat ) => stat . name === 'http_backend' ) [ 0 ] ?. stats ?. status
1800
- this . logger . debug ( `Proxy status: ${ status } ` )
1801
- return status
1802
- } else {
1803
- this . logger . debug ( `Proxy request status code: ${ res . status } ` )
1804
- return null
1805
- }
1806
- } catch ( e ) {
1807
- this . logger . error ( `Error in fetching proxy status: ${ e . message } ` , e )
1808
- }
1809
- }
1810
-
1811
1699
async bumpHederaConfigVersion ( configTxtPath ) {
1812
1700
const lines = ( await readFile ( configTxtPath , 'utf-8' ) ) . split ( '\n' )
1813
1701
0 commit comments