Skip to content

Commit

Permalink
this.k8.>this.K0013.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Feb 11, 2025
1 parent f553ffc commit fa49246
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 40 deletions.
8 changes: 4 additions & 4 deletions src/commands/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class AccountCommand extends BaseCommand {
const namespace = await resolveNamespaceFromDeployment(this.localConfig, this.configManager, task);
const config = {namespace};

if (!(await this.k8.namespaces().has(namespace))) {
if (!(await this.K0013.namespaces().has(namespace))) {
throw new SoloError(`namespace ${namespace.name} does not exist`);
}

Expand Down Expand Up @@ -334,7 +334,7 @@ export class AccountCommand extends BaseCommand {
config.amount = flags.amount.definition.defaultValue as number;
}

if (!(await this.k8.namespaces().has(config.namespace))) {
if (!(await this.K0013.namespaces().has(config.namespace))) {
throw new SoloError(`namespace ${config.namespace} does not exist`);
}

Expand Down Expand Up @@ -412,7 +412,7 @@ export class AccountCommand extends BaseCommand {
ed25519PrivateKey: self.configManager.getFlag<string>(flags.ed25519PrivateKey) as string,
};

if (!(await this.k8.namespaces().has(config.namespace))) {
if (!(await this.K0013.namespaces().has(config.namespace))) {
throw new SoloError(`namespace ${config.namespace} does not exist`);
}

Expand Down Expand Up @@ -494,7 +494,7 @@ export class AccountCommand extends BaseCommand {
privateKey: self.configManager.getFlag<boolean>(flags.privateKey) as boolean,
};

if (!(await this.k8.namespaces().has(config.namespace))) {
if (!(await this.K0013.namespaces().has(config.namespace))) {
throw new SoloError(`namespace ${config.namespace} does not exist`);
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class ExplorerCommand extends BaseCommand {

if (config.enableIngress) {
// patch ingressClassName of mirror ingress so it can be recognized by haproxy ingress controller
await this.k8.ingresses().update(config.namespace, constants.MIRROR_NODE_RELEASE_NAME, {
await this.K0013.ingresses().update(config.namespace, constants.MIRROR_NODE_RELEASE_NAME, {
spec: {
ingressClassName: `${config.namespace}-hedera-explorer-ingress-class`,
},
Expand Down Expand Up @@ -286,7 +286,7 @@ export class ExplorerCommand extends BaseCommand {

// patch explorer ingress to use h1 protocol, haproxy ingress controller default backend protocol is h2
// to support grpc over http/2
await this.k8.ingresses().update(config.namespace, constants.HEDERA_EXPLORER_RELEASE_NAME, {
await this.K0013.ingresses().update(config.namespace, constants.HEDERA_EXPLORER_RELEASE_NAME, {
metadata: {
annotations: {
'haproxy-ingress.github.io/backend-protocol': 'h1',
Expand Down
4 changes: 2 additions & 2 deletions src/commands/mirror_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class MirrorNodeCommand extends BaseCommand {

if (ctx.config.pinger) {
const startAccId = constants.HEDERA_NODE_ACCOUNT_ID_START;
const networkPods = await this.k8.pods().list(namespace, ['solo.hedera.com/type=network-node']);
const networkPods = await this.K0013.pods().list(namespace, ['solo.hedera.com/type=network-node']);

if (networkPods.length) {
const pod = networkPods[0];
Expand Down Expand Up @@ -463,7 +463,7 @@ export class MirrorNodeCommand extends BaseCommand {
return; //! stop the execution
}

const pods = await this.k8.pods().list(namespace, ['app.kubernetes.io/name=postgres']);
const pods = await this.K0013.pods().list(namespace, ['app.kubernetes.io/name=postgres']);
if (pods.length === 0) {
throw new SoloError('postgres pod not found');
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ export class NetworkCommand extends BaseCommand {
config.valuesArg = await this.prepareValuesArg(config);
config.namespace = namespace;

if (!(await this.k8.namespaces().has(namespace))) {
await this.k8.namespaces().create(namespace);
if (!(await this.K0013.namespaces().has(namespace))) {
await this.K0013.namespaces().create(namespace);
}

// prepare staging keys directory
Expand Down
4 changes: 2 additions & 2 deletions src/commands/node/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export const stopConfigBuilder = async function (argv, ctx, task) {
deployment: this.configManager.getFlag(flags.deployment),
};

if (!(await this.k8.namespaces().has(ctx.config.namespace))) {
if (!(await this.K0013.namespaces().has(ctx.config.namespace))) {
throw new SoloError(`namespace ${ctx.config.namespace} does not exist`);
}

Expand All @@ -334,7 +334,7 @@ export const startConfigBuilder = async function (argv, ctx, task) {
const config = this.getConfig(START_CONFIGS_NAME, argv.flags, ['nodeAliases', 'namespace']) as NodeStartConfigClass;
config.namespace = await resolveNamespaceFromDeployment(this.parent.localConfig, this.configManager, task);

if (!(await this.k8.namespaces().has(config.namespace))) {
if (!(await this.K0013.namespaces().has(config.namespace))) {
throw new SoloError(`namespace ${config.namespace} does not exist`);
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class NodeCommand extends BaseCommand {
await this.accountManager.close();
if (this._portForwards) {
for (const srv of this._portForwards) {
await this.k8.pods().readByRef(null).stopPortForward(srv);
await this.K0013.pods().readByRef(null).stopPortForward(srv);
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/commands/node/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,9 @@ export class NodeCommandTasks {
subTasks.push({
title: `Start node: ${chalk.yellow(nodeAlias)}`,
task: async () => {
await this.k8.containers().readByRef(containerRef).execContainer(['systemctl', 'restart', 'network-node']);
await this.K0013.containers()
.readByRef(containerRef)
.execContainer(['systemctl', 'restart', 'network-node']);
},
});
}
Expand All @@ -1058,7 +1060,7 @@ export class NodeCommandTasks {
async (ctx: any, task: ListrTaskWrapper<any, any, any>) => {
const podRef = PodRef.of(ctx.config.namespace, PodName.of(`network-${ctx.config.debugNodeAlias}-0`));
this.logger.debug(`Enable port forwarding for JVM debugger on pod ${podRef.name}`);
await this.k8.pods().readByRef(podRef).portForward(constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT);
await this.K0013.pods().readByRef(podRef).portForward(constants.JVM_DEBUG_PORT, constants.JVM_DEBUG_PORT);
},
(ctx: any) => !ctx.config.debugNodeAlias,
);
Expand Down Expand Up @@ -1186,7 +1188,7 @@ export class NodeCommandTasks {
subTasks.push({
title: `Stop node: ${chalk.yellow(nodeAlias)}`,
task: async () =>
await this.k8.containers().readByRef(containerRef).execContainer('systemctl stop network-node'),
await this.K0013.containers().readByRef(containerRef).execContainer('systemctl stop network-node'),
});
}
}
Expand Down Expand Up @@ -1586,7 +1588,7 @@ export class NodeCommandTasks {
return new Task('Kill nodes', async (ctx: any, task: ListrTaskWrapper<any, any, any>) => {
const config = ctx.config;
for (const service of config.serviceMap.values()) {
await this.k8.pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
await this.K0013.pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
}
});
}
Expand All @@ -1600,7 +1602,7 @@ export class NodeCommandTasks {
config.serviceMap = await this.accountManager.getNodeServiceMap(config.namespace);

for (const service of config.serviceMap.values()) {
await this.k8.pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
await this.K0013.pods().readByRef(PodRef.of(config.namespace, service.nodePodName)).killPod();
}

// again, the pod names will change after the pods are killed
Expand Down Expand Up @@ -1688,7 +1690,7 @@ export class NodeCommandTasks {
.containers()
.readByRef(containerRef)
.execContainer(['bash', '-c', `mkdir -p ${savedStatePath}`]);
await this.k8.containers().readByRef(containerRef).copyTo(config.lastStateZipPath, savedStatePath);
await this.K0013.containers().readByRef(containerRef).copyTo(config.lastStateZipPath, savedStatePath);
await this.platformInstaller.setPathPermission(podRef, constants.HEDERA_HAPI_PATH);
await this.k8
.containers()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class RelayCommand extends BaseCommand {
try {
const deploymentName = this.configManager.getFlag<DeploymentName>(flags.deployment);
const namespace = NamespaceName.of(this.localConfig.deployments[deploymentName].namespace);
const secrets = await this.k8.secrets().list(namespace, [`solo.hedera.com/account-id=${operatorIdUsing}`]);
const secrets = await this.K0013.secrets().list(namespace, [`solo.hedera.com/account-id=${operatorIdUsing}`]);
if (secrets.length === 0) {
this.logger.info(`No k8s secret found for operator account id ${operatorIdUsing}, use default one`);
valuesArg += ` --set config.OPERATOR_KEY_MAIN=${constants.OPERATOR_KEY}`;
Expand Down
8 changes: 7 additions & 1 deletion src/core/certificate_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ export class CertificateManager {
const namespace = this.getNamespace();
const labels = Templates.renderGrpcTlsCertificatesSecretLabelObject(nodeAlias, type);

const isSecretCreated = await this.k8.secrets().createOrReplace(namespace, name, SecretType.OPAQUE, data, labels);
const isSecretCreated = await this.K0013.secrets().createOrReplace(
namespace,
name,
SecretType.OPAQUE,
data,
labels,
);
if (!isSecretCreated) {
throw new SoloError(`failed to create secret for TLS certificates for node '${nodeAlias}'`);
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/cluster_checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ClusterChecks {
*/
public async isCertManagerInstalled(): Promise<boolean> {
try {
const pods: Pod[] = await this.k8.pods().listForAllNamespaces(['app=cert-manager']);
const pods: Pod[] = await this.K0013.pods().listForAllNamespaces(['app=cert-manager']);

return pods.length > 0;
} catch (e) {
Expand All @@ -48,7 +48,7 @@ export class ClusterChecks {
public async isMinioInstalled(namespace: NamespaceName): Promise<boolean> {
try {
// TODO DETECT THE OPERATOR
const pods: V1Pod[] = await this.k8.pods().list(namespace, ['app=minio']);
const pods: V1Pod[] = await this.K0013.pods().list(namespace, ['app=minio']);

return pods.length > 0;
} catch (e) {
Expand All @@ -64,7 +64,7 @@ export class ClusterChecks {
*/
public async isIngressControllerInstalled(): Promise<boolean> {
try {
const ingressClassList: IngressClass[] = await this.k8.ingressClasses().list();
const ingressClassList: IngressClass[] = await this.K0013.ingressClasses().list();

return ingressClassList.length > 0;
} catch (e) {
Expand Down Expand Up @@ -99,7 +99,7 @@ export class ClusterChecks {
*/
public async isPrometheusInstalled(namespace: NamespaceName) {
try {
const pods: V1Pod[] = await this.k8.pods().list(namespace, ['app.kubernetes.io/name=prometheus']);
const pods: V1Pod[] = await this.K0013.pods().list(namespace, ['app.kubernetes.io/name=prometheus']);

return pods.length > 0;
} catch (e) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/config/remote/remote_config_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class RemoteConfigManager {
this.k8,
);
} catch {
throw new SoloError(ErrorMessages.REMOTE_CONFIG_IS_INVALID(this.k8.clusters().readCurrent()));
throw new SoloError(ErrorMessages.REMOTE_CONFIG_IS_INVALID(this.K0013.clusters().readCurrent()));
}
return this.remoteConfig;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ export class RemoteConfigManager {
*/
public async getConfigMap(): Promise<k8s.V1ConfigMap> {
try {
return await this.k8.configMaps().read(this.getNamespace(), constants.SOLO_REMOTE_CONFIGMAP_NAME);
return await this.K0013.configMaps().read(this.getNamespace(), constants.SOLO_REMOTE_CONFIGMAP_NAME);
} catch (error: any) {
if (!(error instanceof ResourceNotFoundError)) {
throw new SoloError('Failed to read remote config from cluster', error);
Expand Down Expand Up @@ -318,7 +318,7 @@ export class RemoteConfigManager {
private setDefaultContextIfNotSet(): void {
if (this.configManager.hasFlag(flags.context)) return;

const context = this.k8.contexts().readCurrent();
const context = this.K0013.contexts().readCurrent();

if (!context) {
this.logger.error("Context is not passed and default one can't be acquired", this.localConfig);
Expand Down
6 changes: 3 additions & 3 deletions src/core/lease/lease_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ export class LeaseManager {
}
const namespace = deploymentNamespace ? deploymentNamespace : clusterSetupNamespace;

if (!(await this.k8.namespaces().has(namespace))) {
await this.k8.namespaces().create(namespace);
if (!(await this.K0013.namespaces().has(namespace))) {
await this.K0013.namespaces().create(namespace);

if (!(await this.k8.namespaces().has(namespace))) {
if (!(await this.K0013.namespaces().has(namespace))) {
throw new LeaseAcquisitionError(`failed to create the '${namespace}' namespace`);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/network_nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class NetworkNodes {
* @returns a promise that resolves when the logs are downloaded
*/
public async getLogs(namespace: NamespaceName) {
const pods: V1Pod[] = await this.k8.pods().list(namespace, ['solo.hedera.com/type=network-node']);
const pods: V1Pod[] = await this.K0013.pods().list(namespace, ['solo.hedera.com/type=network-node']);

const timeString = new Date().toISOString().replace(/:/g, '-').replace(/\./g, '-');

Expand All @@ -59,7 +59,7 @@ export class NetworkNodes {
const containerRef = ContainerRef.of(podRef, ROOT_CONTAINER);
const scriptName = 'support-zip.sh';
const sourcePath = path.join(constants.RESOURCES_DIR, scriptName); // script source path
await this.k8.containers().readByRef(containerRef).copyTo(sourcePath, `${HEDERA_HAPI_PATH}`);
await this.K0013.containers().readByRef(containerRef).copyTo(sourcePath, `${HEDERA_HAPI_PATH}`);
await sleep(Duration.ofSeconds(3)); // wait for the script to sync to the file system
await this.k8
.containers()
Expand All @@ -73,7 +73,7 @@ export class NetworkNodes {
.containers()
.readByRef(containerRef)
.execContainer(['bash', '-c', `sudo chmod 0755 ${HEDERA_HAPI_PATH}/${scriptName}`]);
await this.k8.containers().readByRef(containerRef).execContainer(`${HEDERA_HAPI_PATH}/${scriptName}`);
await this.K0013.containers().readByRef(containerRef).execContainer(`${HEDERA_HAPI_PATH}/${scriptName}`);
await this.k8
.containers()
.readByRef(containerRef)
Expand Down Expand Up @@ -115,7 +115,7 @@ export class NetworkNodes {
}
const zipCommand = `tar -czf ${HEDERA_HAPI_PATH}/${podRef.name}-state.zip -C ${HEDERA_HAPI_PATH}/data/saved .`;
const containerRef = ContainerRef.of(podRef, ROOT_CONTAINER);
await this.k8.containers().readByRef(containerRef).execContainer(zipCommand);
await this.K0013.containers().readByRef(containerRef).execContainer(zipCommand);
await this.k8
.containers()
.readByRef(containerRef)
Expand Down
10 changes: 5 additions & 5 deletions src/core/platform_installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export class PlatformInstaller {

const extractScript = path.join(constants.HEDERA_USER_HOME_DIR, scriptName); // inside the container
const containerRef = ContainerRef.of(podRef, constants.ROOT_CONTAINER);
await this.k8.containers().readByRef(containerRef).execContainer(`chmod +x ${extractScript}`);
await this.k8.containers().readByRef(containerRef).execContainer([extractScript, tag]);
await this.K0013.containers().readByRef(containerRef).execContainer(`chmod +x ${extractScript}`);
await this.K0013.containers().readByRef(containerRef).execContainer([extractScript, tag]);
return true;
} catch (e: Error | any) {
const message = `failed to extract platform code in this pod '${podRef.name}': ${e.message}`;
Expand Down Expand Up @@ -127,12 +127,12 @@ export class PlatformInstaller {
throw new SoloError(`file does not exist: ${srcPath}`);
}

if (!(await this.k8.containers().readByRef(containerRef).hasDir(destDir))) {
await this.k8.containers().readByRef(containerRef).mkdir(destDir);
if (!(await this.K0013.containers().readByRef(containerRef).hasDir(destDir))) {
await this.K0013.containers().readByRef(containerRef).mkdir(destDir);
}

this.logger.debug(`Copying file into ${podRef.name}: ${srcPath} -> ${destDir}`);
await this.k8.containers().readByRef(containerRef).copyTo(srcPath, destDir);
await this.K0013.containers().readByRef(containerRef).copyTo(srcPath, destDir);

const fileName = path.basename(srcPath);
copiedFiles.push(path.join(destDir, fileName));
Expand Down

0 comments on commit fa49246

Please sign in to comment.