@@ -54,7 +54,12 @@ import {type Listr, type ListrTaskWrapper} from 'listr2';
54
54
import { type ConfigBuilder , type NodeAlias , type NodeAliases , type SkipCheck } from '../../types/aliases.js' ;
55
55
import { PodName } from '../../core/kube/resources/pod/pod_name.js' ;
56
56
import { NodeStatusCodes , NodeStatusEnums , NodeSubcommandType } from '../../core/enumerations.js' ;
57
- import { type NodeDeleteConfigClass , type NodeRefreshConfigClass , type NodeUpdateConfigClass } from './configs.js' ;
57
+ import {
58
+ type NodeDeleteConfigClass ,
59
+ type NodeRefreshConfigClass ,
60
+ type NodeSetupConfigClass ,
61
+ type NodeUpdateConfigClass ,
62
+ } from './configs.js' ;
58
63
import { type Lease } from '../../core/lease/lease.js' ;
59
64
import { ListrLease } from '../../core/lease/listr_lease.js' ;
60
65
import { Duration } from '../../core/time/duration.js' ;
@@ -68,6 +73,8 @@ import {ContainerRef} from '../../core/kube/resources/container/container_ref.js
68
73
import { NetworkNodes } from '../../core/network_nodes.js' ;
69
74
import { container } from 'tsyringe-neo' ;
70
75
import * as helpers from '../../core/helpers.js' ;
76
+ import { type Optional , type SoloListrTask , type SoloListrTaskWrapper } from '../../types/index.js' ;
77
+ import { type ConsensusNode } from '../../core/model/consensus_node.js' ;
71
78
72
79
export class NodeCommandTasks {
73
80
private readonly accountManager : AccountManager ;
@@ -196,6 +203,7 @@ export class NodeCommandTasks {
196
203
podRefs : Record < NodeAlias , PodRef > ,
197
204
task : ListrTaskWrapper < any , any , any > ,
198
205
localBuildPath : string ,
206
+ consensusNodes : Optional < ConsensusNode [ ] > ,
199
207
) {
200
208
const subTasks = [ ] ;
201
209
@@ -216,6 +224,7 @@ export class NodeCommandTasks {
216
224
let localDataLibBuildPath : string ;
217
225
for ( const nodeAlias of nodeAliases ) {
218
226
const podRef = podRefs [ nodeAlias ] ;
227
+ const context = helpers . extractContextFromConsensusNodes ( nodeAlias , consensusNodes ) ;
219
228
if ( buildPathMap . has ( nodeAlias ) ) {
220
229
localDataLibBuildPath = buildPathMap . get ( nodeAlias ) ;
221
230
} else {
@@ -227,24 +236,25 @@ export class NodeCommandTasks {
227
236
}
228
237
229
238
const self = this ;
239
+
240
+ const k8 = context ? self . k8Factory . getK8 ( context ) : self . k8Factory . default ( ) ;
241
+
230
242
subTasks . push ( {
231
243
title : `Copy local build to Node: ${ chalk . yellow ( nodeAlias ) } from ${ localDataLibBuildPath } ` ,
232
244
task : async ( ) => {
233
245
// filter the data/config and data/keys to avoid failures due to config and secret mounts
234
246
const filterFunction = ( path , stat ) => {
235
247
return ! ( path . includes ( 'data/keys' ) || path . includes ( 'data/config' ) ) ;
236
248
} ;
237
- await self . k8Factory
238
- . default ( )
249
+ await k8
239
250
. containers ( )
240
251
. readByRef ( ContainerRef . of ( podRef , constants . ROOT_CONTAINER ) )
241
252
. copyTo ( localDataLibBuildPath , `${ constants . HEDERA_HAPI_PATH } ` , filterFunction ) ;
242
253
if ( self . configManager . getFlag < string > ( flags . appConfig ) ) {
243
254
const testJsonFiles : string [ ] = this . configManager . getFlag < string > ( flags . appConfig ) ! . split ( ',' ) ;
244
255
for ( const jsonFile of testJsonFiles ) {
245
256
if ( fs . existsSync ( jsonFile ) ) {
246
- await self . k8Factory
247
- . default ( )
257
+ await k8
248
258
. containers ( )
249
259
. readByRef ( ContainerRef . of ( podRef , constants . ROOT_CONTAINER ) )
250
260
. copyTo ( jsonFile , `${ constants . HEDERA_HAPI_PATH } ` ) ;
@@ -267,13 +277,15 @@ export class NodeCommandTasks {
267
277
releaseTag : string ,
268
278
task : ListrTaskWrapper < any , any , any > ,
269
279
platformInstaller : PlatformInstaller ,
280
+ consensusNodes ?: Optional < ConsensusNode [ ] > ,
270
281
) {
271
282
const subTasks = [ ] ;
272
283
for ( const nodeAlias of nodeAliases ) {
284
+ const context = helpers . extractContextFromConsensusNodes ( nodeAlias , consensusNodes ) ;
273
285
const podRef = podRefs [ nodeAlias ] ;
274
286
subTasks . push ( {
275
287
title : `Update node: ${ chalk . yellow ( nodeAlias ) } [ platformVersion = ${ releaseTag } ]` ,
276
- task : async ( ) => await platformInstaller . fetchPlatform ( podRef , releaseTag ) ,
288
+ task : async ( ) => await platformInstaller . fetchPlatform ( podRef , releaseTag , context ) ,
277
289
} ) ;
278
290
}
279
291
@@ -797,10 +809,12 @@ export class NodeCommandTasks {
797
809
if ( ! ctx . config ) ctx . config = { } ;
798
810
799
811
ctx . config . podRefs = { } ;
812
+ const consensusNodes : Optional < ConsensusNode [ ] > = ctx . config . consensusNodes ;
800
813
801
814
const subTasks = [ ] ;
802
815
const self = this ;
803
816
for ( const nodeAlias of nodeAliases ) {
817
+ const context = helpers . extractContextFromConsensusNodes ( nodeAlias , consensusNodes ) ;
804
818
subTasks . push ( {
805
819
title : `Check network pod: ${ chalk . yellow ( nodeAlias ) } ` ,
806
820
task : async ( ctx : any ) => {
@@ -809,6 +823,8 @@ export class NodeCommandTasks {
809
823
ctx . config . namespace ,
810
824
nodeAlias ,
811
825
maxAttempts ,
826
+ undefined ,
827
+ context ,
812
828
) ;
813
829
} catch ( _ ) {
814
830
ctx . config . skipStop = true ;
@@ -832,14 +848,16 @@ export class NodeCommandTasks {
832
848
nodeAlias : NodeAlias ,
833
849
maxAttempts = constants . PODS_RUNNING_MAX_ATTEMPTS ,
834
850
delay = constants . PODS_RUNNING_DELAY ,
851
+ context ?: Optional < string > ,
835
852
) {
836
853
nodeAlias = nodeAlias . trim ( ) as NodeAlias ;
837
854
const podName = Templates . renderNetworkPodName ( nodeAlias ) ;
838
855
const podRef = PodRef . of ( namespace , podName ) ;
839
856
840
857
try {
841
- await this . k8Factory
842
- . default ( )
858
+ const k8 = context ? this . k8Factory . getK8 ( context ) : this . k8Factory . default ( ) ;
859
+
860
+ await k8
843
861
. pods ( )
844
862
. waitForRunningPhase (
845
863
namespace ,
@@ -912,7 +930,7 @@ export class NodeCommandTasks {
912
930
) ;
913
931
}
914
932
915
- identifyNetworkPods ( maxAttempts = undefined ) {
933
+ identifyNetworkPods ( maxAttempts ?: number ) {
916
934
const self = this ;
917
935
return new Task ( 'Identify network pods' , ( ctx : any , task : ListrTaskWrapper < any , any , any > ) => {
918
936
return self . taskCheckNetworkNodePods ( ctx , task , ctx . config . nodeAliases , maxAttempts ) ;
@@ -924,10 +942,22 @@ export class NodeCommandTasks {
924
942
return new Task ( 'Fetch platform software into network nodes' , ( ctx : any , task : ListrTaskWrapper < any , any , any > ) => {
925
943
const { podRefs, releaseTag, localBuildPath} = ctx . config ;
926
944
927
- if ( localBuildPath !== '' ) {
928
- return self . _uploadPlatformSoftware ( ctx . config [ aliasesField ] , podRefs , task , localBuildPath ) ;
929
- }
930
- return self . _fetchPlatformSoftware ( ctx . config [ aliasesField ] , podRefs , releaseTag , task , this . platformInstaller ) ;
945
+ return localBuildPath !== ''
946
+ ? self . _uploadPlatformSoftware (
947
+ ctx . config [ aliasesField ] ,
948
+ podRefs ,
949
+ task ,
950
+ localBuildPath ,
951
+ ctx . config . consensusNodes ,
952
+ )
953
+ : self . _fetchPlatformSoftware (
954
+ ctx . config [ aliasesField ] ,
955
+ podRefs ,
956
+ releaseTag ,
957
+ task ,
958
+ this . platformInstaller ,
959
+ ctx . config . consensusNodes ,
960
+ ) ;
931
961
} ) ;
932
962
}
933
963
@@ -955,12 +985,14 @@ export class NodeCommandTasks {
955
985
956
986
await this . generateNodeOverridesJson ( ctx . config . namespace , ctx . config . nodeAliases , ctx . config . stagingDir ) ;
957
987
988
+ const consensusNodes = ctx . config . consensusNodes ;
958
989
const subTasks = [ ] ;
959
990
for ( const nodeAlias of ctx . config [ nodeAliasesProperty ] ) {
960
991
const podRef = ctx . config . podRefs [ nodeAlias ] ;
992
+ const context = helpers . extractContextFromConsensusNodes ( nodeAlias , consensusNodes ) ;
961
993
subTasks . push ( {
962
994
title : `Node: ${ chalk . yellow ( nodeAlias ) } ` ,
963
- task : ( ) => this . platformInstaller . taskSetup ( podRef , ctx . config . stagingDir , isGenesis ) ,
995
+ task : ( ) => this . platformInstaller . taskSetup ( podRef , ctx . config . stagingDir , isGenesis , context ) ,
964
996
} ) ;
965
997
}
966
998
0 commit comments