Skip to content

Commit f4087bf

Browse files
committed
saving progress
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 537fc1a commit f4087bf

File tree

8 files changed

+43
-18
lines changed

8 files changed

+43
-18
lines changed

src/commands/base.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,20 @@ export abstract class BaseCommand extends ShellRunner {
255255
const consensusNodes: ConsensusNode[] = [];
256256

257257
// using the remoteConfigManager to get the consensus nodes
258-
Object.values(this.getRemoteConfigManager().components.consensusNodes).forEach(node => {
259-
consensusNodes.push(
260-
new ConsensusNode(
261-
node.name,
262-
node.nodeId,
263-
node.namespace,
264-
node.cluster,
265-
// use local config to get the context
266-
this.getLocalConfig().clusterRefs[node.cluster],
267-
),
268-
);
269-
});
258+
if (this.getRemoteConfigManager()?.components?.consensusNodes) {
259+
Object.values(this.getRemoteConfigManager().components.consensusNodes).forEach(node => {
260+
consensusNodes.push(
261+
new ConsensusNode(
262+
node.name,
263+
node.nodeId,
264+
node.namespace,
265+
node.cluster,
266+
// use local config to get the context
267+
this.getLocalConfig().clusterRefs[node.cluster],
268+
),
269+
);
270+
});
271+
}
270272

271273
// return the consensus nodes
272274
return consensusNodes;

src/commands/network.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ export class NetworkCommand extends BaseCommand {
362362
flags.debugNodeAlias,
363363
flags.loadBalancerEnabled,
364364
flags.log4j2Xml,
365+
flags.nodeAliasesUnparsed,
365366
flags.persistentVolumeClaims,
366367
flags.profileName,
367368
flags.profileFile,
@@ -433,6 +434,12 @@ export class NetworkCommand extends BaseCommand {
433434

434435
config.consensusNodes = this.getConsensusNodes();
435436
config.contexts = this.getContexts();
437+
if (config.nodeAliases.length === 0) {
438+
config.nodeAliases = config.consensusNodes.map(node => node.name) as NodeAliases;
439+
if (config.nodeAliases.length === 0) {
440+
throw new SoloError('no node aliases provided via flags or RemoteConfig');
441+
}
442+
}
436443

437444
if (!(await this.k8Factory.default().namespaces().has(namespace))) {
438445
await this.k8Factory.default().namespaces().create(namespace);

src/commands/node/configs.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,20 @@ export const refreshConfigBuilder = async function (argv, ctx, task) {
300300
};
301301

302302
export const keysConfigBuilder = function (argv, ctx, task) {
303-
const config = this.getConfig(KEYS_CONFIGS_NAME, argv.flags, [
303+
const config: NodeKeysConfigClass = this.getConfig(KEYS_CONFIGS_NAME, argv.flags, [
304304
'curDate',
305305
'keysDir',
306306
'nodeAliases',
307307
]) as NodeKeysConfigClass;
308308

309309
config.curDate = new Date();
310310
config.nodeAliases = helpers.parseNodeAliases(config.nodeAliasesUnparsed);
311+
if (config.nodeAliases.length === 0) {
312+
config.nodeAliases = this.consensusNodes.map((node: {nodeAlias: string}) => node.nodeAlias);
313+
if (config.nodeAliases.length === 0) {
314+
throw new SoloError('no node aliases provided via flags or RemoteConfig');
315+
}
316+
}
311317
config.keysDir = path.join(this.configManager.getFlag(flags.cacheDir), 'keys');
312318

313319
if (!fs.existsSync(config.keysDir)) {

src/commands/node/flags.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ export const REFRESH_FLAGS = {
221221
};
222222

223223
export const KEYS_FLAGS = {
224-
requiredFlags: [flags.cacheDir, flags.generateGossipKeys, flags.generateTlsKeys, flags.nodeAliasesUnparsed],
224+
requiredFlags: [flags.cacheDir, flags.generateGossipKeys, flags.generateTlsKeys, flags.deployment],
225225
requiredFlagsWithDisabledPrompt: [],
226-
optionalFlags: [flags.devMode, flags.quiet],
226+
optionalFlags: [flags.devMode, flags.quiet, flags.nodeAliasesUnparsed],
227227
};
228228

229229
export const STOP_FLAGS = {

src/commands/node/handlers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {type ComponentsDataWrapper} from '../../core/config/remote/components_da
4242
import {type Optional} from '../../types/index.js';
4343
import {type NamespaceName} from '../../core/kube/resources/namespace/namespace_name.js';
4444
import {Templates} from '../../core/templates.js';
45+
import {type ConsensusNode} from '../../core/model/consensus_node.js';
4546

4647
export class NodeCommandHandlers implements CommandHandlers {
4748
private readonly accountManager: AccountManager;
@@ -52,6 +53,8 @@ export class NodeCommandHandlers implements CommandHandlers {
5253
private readonly tasks: NodeCommandTasks;
5354
private readonly leaseManager: LeaseManager;
5455
public readonly remoteConfigManager: RemoteConfigManager;
56+
public readonly contexts: string[];
57+
public readonly consensusNodes: ConsensusNode[];
5558

5659
private getConfig: any;
5760
private prepareChartPath: any;
@@ -79,6 +82,10 @@ export class NodeCommandHandlers implements CommandHandlers {
7982

8083
this.getConfig = opts.parent.getConfig.bind(opts.parent);
8184
this.prepareChartPath = opts.parent.prepareChartPath.bind(opts.parent);
85+
86+
this.consensusNodes = opts.parent.getConsensusNodes();
87+
this.contexts = opts.parent.getContexts();
88+
8289
this.parent = opts.parent;
8390
}
8491

src/core/config/remote/remote_config_manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class RemoteConfigManager {
6363

6464
/** @returns the components data wrapper cloned */
6565
public get components(): ComponentsDataWrapper {
66-
return this.remoteConfig.components.clone();
66+
return this.remoteConfig?.components?.clone();
6767
}
6868

6969
/* ---------- Readers and Modifiers ---------- */

test/e2e/commands/network.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ describe('NetworkCommand', () => {
2727
const applicationEnvParentDirectory = path.join(getTmpDir(), 'network-command-test');
2828
const applicationEnvFilePath = path.join(applicationEnvParentDirectory, 'application.env');
2929
const argv = getDefaultArgv();
30-
argv[flags.namespace.name] = namespace.name;
30+
// argv[flags.namespace.name] = namespace.name;
3131
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG;
32-
argv[flags.nodeAliasesUnparsed.name] = 'node1';
32+
// argv[flags.nodeAliasesUnparsed.name] = 'node1';
3333
argv[flags.generateGossipKeys.name] = true;
3434
argv[flags.generateTlsKeys.name] = true;
3535
argv[flags.deployMinio.name] = true;

test/test_container.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {Container} from '../src/core/dependency_injection/container_init.js';
66
import fs from 'fs';
77
import {type NamespaceNameAsString} from '../src/core/config/remote/types.js';
88
import * as yaml from 'yaml';
9+
import {K8Client} from '../src/core/kube/k8_client/k8_client.js';
910

1011
const cacheDirectory = path.join('test', 'data', 'tmp');
1112

@@ -28,4 +29,6 @@ export function resetForTest(namespace?: NamespaceNameAsString, cacheDir: string
2829

2930
fs.writeFileSync(path.join(cacheDirectory, localConfigFile), yaml.stringify(parsedData));
3031
resetTestContainer(cacheDir);
32+
33+
parsedData.clusterRefs['cluster-1'] = new K8Client(undefined).contexts().readCurrent();
3134
}

0 commit comments

Comments
 (0)