Skip to content

Commit a65218d

Browse files
committed
Squashed commit of the following:
commit 2ec418d Author: Jeromy Cannon <[email protected]> Date: Tue Aug 27 22:09:10 2024 +0100 missed merge issue Signed-off-by: Jeromy Cannon <[email protected]> commit c374f62 Author: Jeromy Cannon <[email protected]> Date: Tue Aug 27 21:05:02 2024 +0100 merge lint issue Signed-off-by: Jeromy Cannon <[email protected]> commit 3af4ebb Author: Jeromy Cannon <[email protected]> Date: Thu Aug 22 16:09:02 2024 +0100 remove mirror node dependency on standard e2e tests Signed-off-by: Jeromy Cannon <[email protected]> commit ee86b0c Author: Jeromy Cannon <[email protected]> Date: Thu Aug 22 16:08:42 2024 +0100 remove mirror node dependency on standard e2e tests Signed-off-by: Jeromy Cannon <[email protected]> commit c5f17e4 Author: Jeromy Cannon <[email protected]> Date: Thu Aug 22 14:26:31 2024 +0100 add comment Signed-off-by: Jeromy Cannon <[email protected]> commit 3f0d621 Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 23:09:07 2024 +0100 fixed test cases Signed-off-by: Jeromy Cannon <[email protected]> commit 85e0e85 Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 20:20:25 2024 +0100 fixed lint errors Signed-off-by: Jeromy Cannon <[email protected]> commit 854c797 Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 20:13:32 2024 +0100 updated version of fst charts Signed-off-by: Jeromy Cannon <[email protected]> commit 717a16b Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 17:40:39 2024 +0100 fix test cases Signed-off-by: Jeromy Cannon <[email protected]> commit 40d9513 Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 17:22:05 2024 +0100 fix lint issue Signed-off-by: Jeromy Cannon <[email protected]> commit e854a4f Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 17:17:17 2024 +0100 remove todos, these are just local backups, so no changes needed Signed-off-by: Jeromy Cannon <[email protected]> commit 502aba0 Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 17:14:50 2024 +0100 enhance to use secret mounts Signed-off-by: Jeromy Cannon <[email protected]> commit 7c9ef3f Author: Jeromy Cannon <[email protected]> Date: Wed Aug 21 17:13:55 2024 +0100 k8.mjs: copyFrom to handle links that is used by secret volume mounts Signed-off-by: Jeromy Cannon <[email protected]> commit ddbbd45 Author: Jeromy Cannon <[email protected]> Date: Tue Aug 20 14:00:05 2024 +0100 node-add: updated to set the secret prior to adding the node Signed-off-by: Jeromy Cannon <[email protected]> commit 9fee4db Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 23:54:37 2024 +0100 add the logic to write the gossip key secrets Signed-off-by: Jeromy Cannon <[email protected]> commit e3ade3e Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 20:59:06 2024 +0100 upgrade to v0.53.0 Signed-off-by: Jeromy Cannon <[email protected]> commit 70a4716 Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 20:33:56 2024 +0100 moved taskGenerateTLSKeys from node.mjs to key_manager.mjs Signed-off-by: Jeromy Cannon <[email protected]> commit e4f8b4d Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 20:10:58 2024 +0100 moved taskGenerateGossipKeys from node.mjs to key_manager.mjs Signed-off-by: Jeromy Cannon <[email protected]> commit 426e8f3 Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 19:55:15 2024 +0100 moved copyGossipKeysToStaging from node.mjs to key_manager.mjs Signed-off-by: Jeromy Cannon <[email protected]> commit b76fbf9 Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 19:51:33 2024 +0100 moved copyNodeKeysToStaging from node.mjs to key_manager.mjs Signed-off-by: Jeromy Cannon <[email protected]> commit 49b0195 Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 19:46:13 2024 +0100 moved key validation logic from node to keyManager Signed-off-by: Jeromy Cannon <[email protected]> commit eeb192d Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 19:27:20 2024 +0100 use local keytool instance Signed-off-by: Jeromy Cannon <[email protected]> commit 390bbf0 Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 19:16:28 2024 +0100 renamed node._nodeTlsKeyTaskList to node.taskGenerateTLSKeys, node._copyNodeKeys to copyNodeKeysToStaging Signed-off-by: Jeromy Cannon <[email protected]> commit b526dd4 Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 19:13:06 2024 +0100 renamed node._nodeGossipKeysTaskList to node.taskGenerateGossipKeys Signed-off-by: Jeromy Cannon <[email protected]> commit 9513b0c Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 19:11:05 2024 +0100 renamed platformInstaller.taskInstall to platformInstaller.taskSetup Signed-off-by: Jeromy Cannon <[email protected]> commit 43b7e99 Author: Jeromy Cannon <[email protected]> Date: Mon Aug 19 18:47:01 2024 +0100 add TODOs Signed-off-by: Jeromy Cannon <[email protected]> Signed-off-by: Jeromy Cannon <[email protected]>
1 parent d676ba7 commit a65218d

14 files changed

+521
-508
lines changed

.github/workflows/flow-build-application.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ jobs:
8484
needs:
8585
- env-vars
8686
- code-style
87-
- e2e-tests
8887
with:
8988
custom-job-label: Mirror Node
9089
npm-test-script: test-${{ needs.env-vars.outputs.e2e-mirror-node-test-subdir }}

.github/workflows/flow-pull-request-checks.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ jobs:
7171
needs:
7272
- env-vars
7373
- code-style
74-
- e2e-tests
7574
with:
7675
custom-job-label: Mirror Node
7776
npm-test-script: test-${{ needs.env-vars.outputs.e2e-mirror-node-test-subdir }}

src/commands/network.mjs

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@ import { Listr } from 'listr2'
2020
import { FullstackTestingError, IllegalArgumentError, MissingArgumentError } from '../core/errors.mjs'
2121
import { BaseCommand } from './base.mjs'
2222
import * as flags from './flags.mjs'
23-
import { constants } from '../core/index.mjs'
23+
import { constants, Templates } from '../core/index.mjs'
2424
import * as prompts from './prompts.mjs'
2525
import * as helpers from '../core/helpers.mjs'
2626
import path from 'path'
27+
import { validatePath } from '../core/helpers.mjs'
28+
import fs from 'fs'
2729

2830
export class NetworkCommand extends BaseCommand {
2931
constructor (opts) {
3032
super(opts)
3133

34+
if (!opts || !opts.k8) throw new Error('An instance of core/K8 is required')
35+
if (!opts || !opts.keyManager) throw new IllegalArgumentError('An instance of core/KeyManager is required', opts.keyManager)
36+
if (!opts || !opts.platformInstaller) throw new IllegalArgumentError('An instance of core/PlatformInstaller is required', opts.platformInstaller)
3237
if (!opts || !opts.profileManager) throw new MissingArgumentError('An instance of core/ProfileManager is required', opts.downloader)
3338

39+
this.k8 = opts.k8
40+
this.keyManager = opts.keyManager
41+
this.platformInstaller = opts.platformInstaller
3442
this.profileManager = opts.profileManager
3543
}
3644

@@ -45,6 +53,7 @@ export class NetworkCommand extends BaseCommand {
4553
flags.applicationEnv,
4654
flags.applicationProperties,
4755
flags.bootstrapProperties,
56+
flags.cacheDir,
4857
flags.chainId,
4958
flags.chartDirectory,
5059
flags.deployHederaExplorer,
@@ -54,6 +63,7 @@ export class NetworkCommand extends BaseCommand {
5463
flags.fstChartVersion,
5564
flags.hederaExplorerTlsHostName,
5665
flags.hederaExplorerTlsLoadBalancerIp,
66+
flags.keyFormat,
5767
flags.log4j2Xml,
5868
flags.namespace,
5969
flags.nodeIDs,
@@ -143,10 +153,12 @@ export class NetworkCommand extends BaseCommand {
143153
flags.applicationEnv,
144154
flags.applicationProperties,
145155
flags.bootstrapProperties,
156+
flags.cacheDir,
146157
flags.chainId,
147158
flags.deployHederaExplorer,
148159
flags.deployMirrorNode,
149160
flags.hederaExplorerTlsLoadBalancerIp,
161+
flags.keyFormat,
150162
flags.log4j2Xml,
151163
flags.persistentVolumeClaims,
152164
flags.profileName,
@@ -160,6 +172,7 @@ export class NetworkCommand extends BaseCommand {
160172
* @typedef {Object} NetworkDeployConfigClass
161173
* -- flags --
162174
* @property {string} applicationEnv
175+
* @property {string} cacheDir
163176
* @property {string} chartDirectory
164177
* @property {boolean} deployHederaExplorer
165178
* @property {boolean} deployMirrorNode
@@ -168,6 +181,7 @@ export class NetworkCommand extends BaseCommand {
168181
* @property {string} fstChartVersion
169182
* @property {string} hederaExplorerTlsHostName
170183
* @property {string} hederaExplorerTlsLoadBalancerIp
184+
* @property {string} keyFormat
171185
* @property {string} namespace
172186
* @property {string} nodeIDs
173187
* @property {string} persistentVolumeClaims
@@ -176,8 +190,11 @@ export class NetworkCommand extends BaseCommand {
176190
* @property {string} releaseTag
177191
* @property {string} tlsClusterIssuerType
178192
* -- extra args --
179-
* @property {string[]} nodeIds
180193
* @property {string} chartPath
194+
* @property {string} keysDir
195+
* @property {string[]} nodeIds
196+
* @property {string} stagingDir
197+
* @property {string} stagingKeysDir
181198
* @property {string} valuesArg
182199
* -- methods --
183200
* @property {getUnusedConfigs} getUnusedConfigs
@@ -189,7 +206,14 @@ export class NetworkCommand extends BaseCommand {
189206

190207
// create a config object for subsequent steps
191208
const config = /** @type {NetworkDeployConfigClass} **/ this.getConfig(NetworkCommand.DEPLOY_CONFIGS_NAME, NetworkCommand.DEPLOY_FLAGS_LIST,
192-
['nodeIds', 'chartPath', 'valuesArg'])
209+
[
210+
'chartPath',
211+
'keysDir',
212+
'nodeIds',
213+
'stagingDir',
214+
'stagingKeysDir',
215+
'valuesArg'
216+
])
193217

194218
config.nodeIds = helpers.parseNodeIds(config.nodeIDs)
195219

@@ -199,6 +223,28 @@ export class NetworkCommand extends BaseCommand {
199223

200224
config.valuesArg = await this.prepareValuesArg(config)
201225

226+
// compute other config parameters
227+
config.keysDir = path.join(validatePath(config.cacheDir), 'keys')
228+
config.stagingDir = Templates.renderStagingDir(
229+
config.cacheDir,
230+
config.releaseTag
231+
)
232+
config.stagingKeysDir = path.join(validatePath(config.stagingDir), 'keys')
233+
234+
if (!await this.k8.hasNamespace(config.namespace)) {
235+
await this.k8.createNamespace(config.namespace)
236+
}
237+
238+
// prepare staging keys directory
239+
if (!fs.existsSync(config.stagingKeysDir)) {
240+
fs.mkdirSync(config.stagingKeysDir, { recursive: true })
241+
}
242+
243+
// create cached keys dir if it does not exist yet
244+
if (!fs.existsSync(config.keysDir)) {
245+
fs.mkdirSync(config.keysDir)
246+
}
247+
202248
this.logger.debug('Prepared config', {
203249
config,
204250
cachedConfig: this.configManager.config
@@ -221,6 +267,50 @@ export class NetworkCommand extends BaseCommand {
221267
ctx.config = /** @type {NetworkDeployConfigClass} **/ await self.prepareConfig(task, argv)
222268
}
223269
},
270+
{
271+
title: 'Prepare staging directory',
272+
task: async (ctx, parentTask) => {
273+
const subTasks = [
274+
{
275+
title: 'Copy Gossip keys to staging',
276+
task: async (ctx, _) => {
277+
const config = /** @type {NetworkDeployConfigClass} **/ ctx.config
278+
279+
await this.keyManager.copyGossipKeysToStaging(config.keyFormat, config.keysDir, config.stagingKeysDir, config.nodeIds)
280+
}
281+
},
282+
{
283+
title: 'Copy gRPC TLS keys to staging',
284+
task: async (ctx, _) => {
285+
const config = /** @type {NetworkDeployConfigClass} **/ ctx.config
286+
for (const nodeId of config.nodeIds) {
287+
const tlsKeyFiles = self.keyManager.prepareTLSKeyFilePaths(nodeId, config.keysDir)
288+
await self.keyManager.copyNodeKeysToStaging(tlsKeyFiles, config.stagingKeysDir)
289+
}
290+
}
291+
}
292+
]
293+
294+
return parentTask.newListr(subTasks, {
295+
concurrent: false,
296+
rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION
297+
})
298+
}
299+
},
300+
{
301+
title: 'Copy node keys to secrets',
302+
task: async (ctx, parentTask) => {
303+
const config = /** @type {NetworkDeployConfigClass} **/ ctx.config
304+
305+
const subTasks = self.platformInstaller.copyNodeKeys(config.stagingDir, config.nodeIds, config.keyFormat)
306+
307+
// set up the sub-tasks
308+
return parentTask.newListr(subTasks, {
309+
concurrent: true,
310+
rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION
311+
})
312+
}
313+
},
224314
{
225315
title: `Install chart '${constants.FULLSTACK_DEPLOYMENT_CHART}'`,
226316
task: async (ctx, _) => {

0 commit comments

Comments
 (0)