Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: solo network destroy should update remote-config #1155

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/commands/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import {ListrEnquirerPromptAdapter} from '@listr2/prompt-adapter-enquirer';
import chalk from 'chalk';
import {Listr, type ListrTask} from 'listr2';
import {Listr} from 'listr2';
import {IllegalArgumentError, MissingArgumentError, SoloError} from '../core/errors.js';
import {BaseCommand} from './base.js';
import {Flags as flags} from './flags.js';
Expand All @@ -40,6 +40,8 @@
import {HaProxyComponent} from '../core/config/remote/components/ha_proxy_component.js';
import {v4 as uuidv4} from 'uuid';
import * as Base64 from 'js-base64';
import type {SoloListrTask} from '../types/index.js';
import type {Namespace} from '../core/config/remote/types.js';

export interface NetworkDeployConfigClass {
applicationEnv: string;
Expand Down Expand Up @@ -772,10 +774,15 @@
self.logger.error(message);
self.logger.showUser(chalk.red(message));
networkDestroySuccess = false;

Check warning on line 777 in src/commands/network.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/network.ts#L777

Added line #L777 was not covered by tests
if (ctx.config.deletePvcs && ctx.config.deleteSecrets && ctx.config.force) {
self.k8.deleteNamespace(ctx.config.namespace);
} else {
// If the namespace is not being deleted,
// remove all components data from the remote configuration
self.remoteConfigManager.deleteComponents();

Check warning on line 783 in src/commands/network.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/network.ts#L780-L783

Added lines #L780 - L783 were not covered by tests
}
}, constants.NETWORK_DESTROY_WAIT_TIMEOUT * 1000);
}, constants.NETWORK_DESTROY_WAIT_TIMEOUT * 1_000);

Check warning on line 785 in src/commands/network.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/network.ts#L785

Added line #L785 was not covered by tests

await self.destroyTask(ctx, task);

Expand All @@ -794,7 +801,7 @@

try {
await tasks.run();
} catch (e: Error | any) {
} catch (e: Error | unknown) {
throw new SoloError('Error destroying network', e);
} finally {
await lease.release();
Expand Down Expand Up @@ -947,7 +954,7 @@
}

/** Adds the consensus node, envoy and haproxy components to remote config. */
public addNodesAndProxies(): ListrTask<any, any, any> {
public addNodesAndProxies(): SoloListrTask<{config: {namespace: Namespace; nodeAliases: NodeAliases}}> {
return {
title: 'Add node and proxies to remote config',
skip: (): boolean => !this.remoteConfigManager.isLoaded(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/local_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
title: 'Prompt local configuration',
skip: this.skipPromptTask,
task: async (_: any, task: SoloListrTaskWrapper<any>): Promise<void> => {
if (self.configFileExists) {
if (self.configFileExists()) {

Check warning on line 172 in src/core/config/local_config.ts

View check run for this annotation

Codecov / codecov/patch

src/core/config/local_config.ts#L172

Added line #L172 was not covered by tests
self.configManager.setFlag(flags.userEmailAddress, self.userEmailAddress);
}

Expand Down
7 changes: 7 additions & 0 deletions src/core/config/remote/remote_config_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@

/* ---------- Utilities ---------- */

/** Empties the component data inside the remote config */
public async deleteComponents() {
await this.modify(async remoteConfig => {
remoteConfig.components = ComponentsDataWrapper.initializeEmpty();
});
}

Check warning on line 229 in src/core/config/remote/remote_config_manager.ts

View check run for this annotation

Codecov / codecov/patch

src/core/config/remote/remote_config_manager.ts#L226-L229

Added lines #L226 - L229 were not covered by tests

public isLoaded(): boolean {
return !!this.remoteConfig;
}
Expand Down
Loading