Skip to content

Commit e2a9c31

Browse files
committed
K17
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 5477c6d commit e2a9c31

16 files changed

+209
-96
lines changed

src/core/certificate_manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {Templates} from './templates.js';
88
import {GrpcProxyTlsEnums} from './enumerations.js';
99

1010
import {type ConfigManager} from './config_manager.js';
11-
import {type K8Factory} from './kube/K0017.js';
11+
import {type K8Factory} from './kube/k8_factory.js';
1212
import {type SoloLogger} from './logging.js';
1313
import {type ListrTaskWrapper} from 'listr2';
1414
import {type NodeAlias} from '../types/aliases.js';

src/core/cluster_checks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as constants from './constants.js';
66
import {patchInject} from './dependency_injection/container_helper.js';
77
import {type SoloLogger} from './logging.js';
88
import {inject, injectable} from 'tsyringe-neo';
9-
import {type K8Factory} from './kube/K0017.js';
9+
import {type K8Factory} from './kube/k8_factory.js';
1010
import {type Pod} from './kube/resources/pod/pod.js';
1111
import {type IngressClass} from './kube/resources/ingress_class/ingress_class.js';
1212
import {type V1Pod, type V1ConfigMap} from '@kubernetes/client-node';

src/core/config/local_config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class LocalConfig implements LocalConfigData {
151151
this.logger.info(`Wrote local config to ${this.filePath}: ${yamlContent}`);
152152
}
153153

154-
public promptLocalConfigTask(K0017: K0018): SoloListrTask<any> {
154+
public promptLocalConfigTask(k8Factory: K0018): SoloListrTask<any> {
155155
const self = this;
156156

157157
return {
@@ -201,7 +201,7 @@ export class LocalConfig implements LocalConfigData {
201201
if (!isQuiet) {
202202
const promptedContexts: string[] = [];
203203
for (const cluster of parsedClusters) {
204-
const kubeContexts = K0017.contexts().list();
204+
const kubeContexts = k8Factory.default().contexts().list();
205205
const context: string = await flags.context.prompt(task, kubeContexts, cluster);
206206
self.clusterContextMapping[cluster] = context;
207207
promptedContexts.push(context);
@@ -210,7 +210,7 @@ export class LocalConfig implements LocalConfigData {
210210
}
211211
self.configManager.setFlag(flags.context, promptedContexts.join(','));
212212
} else {
213-
const context = K0017.contexts().readCurrent();
213+
const context = k8Factory.default().contexts().readCurrent();
214214
for (const cluster of parsedClusters) {
215215
self.clusterContextMapping[cluster] = context;
216216
}

src/core/config/remote/remote_config_manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {Flags as flags} from '../../../commands/flags.js';
1010
import * as yaml from 'yaml';
1111
import {ComponentsDataWrapper} from './components_data_wrapper.js';
1212
import {RemoteConfigValidator} from './remote_config_validator.js';
13-
import {type K8Factory} from '../../kube/K0017.js';
13+
import {type K8Factory} from '../../kube/k8_factory.js';
1414
import {type ClusterRef, type Context, type DeploymentName, type NamespaceNameAsString} from './types.js';
1515
import {type SoloLogger} from '../../logging.js';
1616
import {type ConfigManager} from '../../config_manager.js';
@@ -38,7 +38,7 @@ export class RemoteConfigManager {
3838
private remoteConfig: Optional<RemoteConfigDataWrapper>;
3939

4040
/**
41-
* @param K0017 - The Kubernetes client used for interacting with ConfigMaps.
41+
* @param k8Factory - The Kubernetes client used for interacting with ConfigMaps.
4242
* @param logger - The logger for recording activity and errors.
4343
* @param localConfig - Local configuration for the remote config.
4444
* @param configManager - Manager to retrieve application flags and settings.

src/core/config/remote/remote_config_validator.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as constants from '../../constants.js';
55
import {SoloError} from '../../errors.js';
66

7-
import {type K8Factory} from '../../kube/K0017.js';
7+
import {type K8Factory} from '../../kube/k8_factory.js';
88
import {type ComponentsDataWrapper} from './components_data_wrapper.js';
99
import {type BaseComponent} from './components/base_component.js';
1010
import {type NamespaceName} from '../../kube/resources/namespace/namespace_name.js';
@@ -20,7 +20,7 @@ export class RemoteConfigValidator {
2020
*
2121
* @param namespace - namespace to validate the components in.
2222
* @param components - components which to validate.
23-
* @param K0017 - to validate the elements.
23+
* @param k8Factory - to validate the elements.
2424
* TODO: Make compatible with multi-cluster K0018 implementation
2525
*/
2626
public static async validateComponents(
@@ -29,12 +29,12 @@ export class RemoteConfigValidator {
2929
k8Factory: K0018,
3030
): Promise<void> {
3131
await Promise.all([
32-
...RemoteConfigValidator.validateRelays(namespace, components, K0017),
33-
...RemoteConfigValidator.validateHaProxies(namespace, components, K0017),
34-
...RemoteConfigValidator.validateMirrorNodes(namespace, components, K0017),
35-
...RemoteConfigValidator.validateEnvoyProxies(namespace, components, K0017),
36-
...RemoteConfigValidator.validateConsensusNodes(namespace, components, K0017),
37-
...RemoteConfigValidator.validateMirrorNodeExplorers(namespace, components, K0017),
32+
...RemoteConfigValidator.validateRelays(namespace, components, k8Factory),
33+
...RemoteConfigValidator.validateHaProxies(namespace, components, k8Factory),
34+
...RemoteConfigValidator.validateMirrorNodes(namespace, components, k8Factory),
35+
...RemoteConfigValidator.validateEnvoyProxies(namespace, components, k8Factory),
36+
...RemoteConfigValidator.validateConsensusNodes(namespace, components, k8Factory),
37+
...RemoteConfigValidator.validateMirrorNodeExplorers(namespace, components, k8Factory),
3838
]);
3939
}
4040

@@ -45,7 +45,7 @@ export class RemoteConfigValidator {
4545
): Promise<void>[] {
4646
return Object.values(components.relays).map(async component => {
4747
try {
48-
const pods: V1Pod[] = await K0017.pods().list(namespace, [constants.SOLO_RELAY_LABEL]);
48+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, [constants.SOLO_RELAY_LABEL]);
4949

5050
// to return the generic error message
5151
if (!pods.length) throw new Error('Pod not found');
@@ -62,7 +62,10 @@ export class RemoteConfigValidator {
6262
): Promise<void>[] {
6363
return Object.values(components.haProxies).map(async component => {
6464
try {
65-
const pods: V1Pod[] = await K0017.pods().list(namespace, [`app=${component.name}`]);
65+
const pods: V1Pod[] = await k8Factory
66+
.default()
67+
.pods()
68+
.list(namespace, [`app=${component.name}`]);
6669

6770
// to return the generic error message
6871
if (!pods.length) throw new Error('Pod not found');
@@ -79,7 +82,7 @@ export class RemoteConfigValidator {
7982
): Promise<void>[] {
8083
return Object.values(components.mirrorNodes).map(async component => {
8184
try {
82-
const pods: V1Pod[] = await K0017.pods().list(namespace, constants.SOLO_HEDERA_MIRROR_IMPORTER);
85+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, constants.SOLO_HEDERA_MIRROR_IMPORTER);
8386

8487
// to return the generic error message
8588
if (!pods.length) throw new Error('Pod not found');
@@ -96,7 +99,10 @@ export class RemoteConfigValidator {
9699
): Promise<void>[] {
97100
return Object.values(components.envoyProxies).map(async component => {
98101
try {
99-
const pods: V1Pod[] = await K0017.pods().list(namespace, [`app=${component.name}`]);
102+
const pods: V1Pod[] = await k8Factory
103+
.default()
104+
.pods()
105+
.list(namespace, [`app=${component.name}`]);
100106

101107
// to return the generic error message
102108
if (!pods.length) throw new Error('Pod not found');
@@ -113,7 +119,10 @@ export class RemoteConfigValidator {
113119
): Promise<void>[] {
114120
return Object.values(components.consensusNodes).map(async component => {
115121
try {
116-
const pods: V1Pod[] = await K0017.pods().list(namespace, [`app=network-${component.name}`]);
122+
const pods: V1Pod[] = await k8Factory
123+
.default()
124+
.pods()
125+
.list(namespace, [`app=network-${component.name}`]);
117126

118127
// to return the generic error message
119128
if (!pods.length) throw new Error('Pod not found');
@@ -130,7 +139,7 @@ export class RemoteConfigValidator {
130139
): Promise<void>[] {
131140
return Object.values(components.mirrorNodeExplorers).map(async component => {
132141
try {
133-
const pods: V1Pod[] = await K0017.pods().list(namespace, [constants.SOLO_HEDERA_EXPLORER_LABEL]);
142+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, [constants.SOLO_HEDERA_EXPLORER_LABEL]);
134143

135144
// to return the generic error message
136145
if (!pods.length) throw new Error('Pod not found');

src/core/kube/k8_client/k8_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {SoloError} from '../../errors.js';
66
import {type ConfigManager} from '../../config_manager.js';
77
import {type SoloLogger} from '../../logging.js';
88
import {container} from 'tsyringe-neo';
9-
import {type K8Factory} from '../K0017.js';
9+
import {type K8Factory} from '../k8_factory.js';
1010
import {type Namespaces} from '../resources/namespace/namespaces.js';
1111
import {K8ClientClusters} from '../k8_client/resources/cluster/k8_client_clusters.js';
1212
import {type Clusters} from '../resources/cluster/clusters.js';

src/core/network_nodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {sleep} from './helpers.js';
1313
import {Duration} from './time/duration.js';
1414
import {inject, injectable} from 'tsyringe-neo';
1515
import {type SoloLogger} from './logging.js';
16-
import {type K8Factory} from './kube/K0017.js';
16+
import {type K8Factory} from './kube/k8_factory.js';
1717
import {patchInject} from './dependency_injection/container_helper.js';
1818
import {type V1Pod} from '@kubernetes/client-node';
1919
import {InjectTokens} from './dependency_injection/inject_tokens.js';

test/e2e/commands/network.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ describe('NetworkCommand', () => {
146146
expect(chartInstalledStatus).to.be.false;
147147

148148
// check if pvc are deleted
149-
await expect(K0017.pvcs().list(namespace, [])).eventually.to.have.lengthOf(0);
149+
await expect(k8Factory.default().pvcs().list(namespace, [])).eventually.to.have.lengthOf(0);
150150

151151
// check if secrets are deleted
152-
await expect(K0017.secrets().list(namespace)).eventually.to.have.lengthOf(0);
152+
await expect(k8Factory.default().secrets().list(namespace)).eventually.to.have.lengthOf(0);
153153
} catch (e) {
154154
networkCmd.logger.showUserError(e);
155155
expect.fail();

test/e2e/commands/separate_node_update.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ e2eTestSuite(
7777

7878
it('cache current version of private keys', async () => {
7979
existingServiceMap = await bootstrapResp.opts.accountManager.getNodeServiceMap(namespace);
80-
existingNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(existingServiceMap, K0017, getTmpDir());
80+
existingNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(
81+
existingServiceMap,
82+
k8Factory,
83+
getTmpDir(),
84+
);
8185
}).timeout(Duration.ofMinutes(8).toMillis());
8286

8387
it('should succeed with init command', async () => {
@@ -132,7 +136,7 @@ e2eTestSuite(
132136
it('signing key and tls key should not match previous one', async () => {
133137
const currentNodeIdsPrivateKeysHash = await getNodeAliasesPrivateKeysHash(
134138
existingServiceMap,
135-
K0017,
139+
k8Factory,
136140
getTmpDir(),
137141
);
138142

@@ -158,12 +162,16 @@ e2eTestSuite(
158162

159163
it('config.txt should be changed with new account id', async () => {
160164
// read config.txt file from first node, read config.txt line by line, it should not contain value of newAccountId
161-
const pods: V1Pod[] = await K0017.pods().list(namespace, ['solo.hedera.com/type=network-node']);
165+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, ['solo.hedera.com/type=network-node']);
162166
const podName: PodName = PodName.of(pods[0].metadata.name);
163167
const podRef: PodRef = PodRef.of(namespace, podName);
164168
const containerRef: ContainerRef = ContainerRef.of(podRef, ROOT_CONTAINER);
165169
const tmpDir: string = getTmpDir();
166-
await K0017.containers().readByRef(containerRef).copyFrom(`${HEDERA_HAPI_PATH}/config.txt`, tmpDir);
170+
await k8Factory
171+
.default()
172+
.containers()
173+
.readByRef(containerRef)
174+
.copyFrom(`${HEDERA_HAPI_PATH}/config.txt`, tmpDir);
167175
const configTxt: string = fs.readFileSync(`${tmpDir}/config.txt`, 'utf8');
168176
console.log('config.txt:', configTxt);
169177

test/e2e/commands/separate_node_upgrade.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ e2eTestSuite(
4949
describe('Node upgrade', async () => {
5050
const nodeCmd = bootstrapResp.cmd.nodeCmd;
5151
const accountCmd = bootstrapResp.cmd.accountCmd;
52-
const K0017 = bootstrapResp.opts.k8Factory;
52+
const k8Factory = bootstrapResp.opts.k8Factory;
5353

5454
after(async function () {
5555
this.timeout(Duration.ofMinutes(10).toMillis());
5656

5757
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(namespace);
58-
await K0017.namespaces().delete(namespace);
58+
await k8Factory.default().namespaces().delete(namespace);
5959
});
6060

6161
it('should succeed with init command', async () => {
@@ -96,11 +96,13 @@ e2eTestSuite(
9696
it('network nodes version file was upgraded', async () => {
9797
// copy the version.txt file from the pod data/upgrade/current directory
9898
const tmpDir: string = getTmpDir();
99-
const pods: V1Pod[] = await K0017.pods().list(namespace, ['solo.hedera.com/type=network-node']);
99+
const pods: V1Pod[] = await k8Factory.default().pods().list(namespace, ['solo.hedera.com/type=network-node']);
100100
const podName: PodName = PodName.of(pods[0].metadata.name);
101101
const podRef: PodRef = PodRef.of(namespace, podName);
102102
const containerRef: ContainerRef = ContainerRef.of(podRef, ROOT_CONTAINER);
103-
await K0017.containers()
103+
await k8Factory
104+
.default()
105+
.containers()
104106
.readByRef(containerRef)
105107
.copyFrom(`${HEDERA_HAPI_PATH}/data/upgrade/current/version.txt`, tmpDir);
106108

0 commit comments

Comments
 (0)