UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

142 lines (141 loc) 6.35 kB
import * as constants from '../core/constants.js'; import { type AccountManager } from '../core/account-manager.js'; import { BaseCommand } from './base.js'; import { type ArgvStruct } from '../types/aliases.js'; import { type ClusterReferenceName, type ComponentId, type DeploymentName, type Optional, type SoloListrTask } from '../types/index.js'; import { type NamespaceName } from '../types/namespace/namespace-name.js'; import { type CommandFlags } from '../types/flag-types.js'; import { MirrorNodeStateSchema } from '../data/schema/model/remote/state/mirror-node-state-schema.js'; import { PostgresSharedResource } from '../core/shared-resources/postgres.js'; import { SharedResourceManager } from '../core/shared-resources/shared-resource-manager.js'; import { type SoloEventBus } from '../core/events/solo-event-bus.js'; interface MirrorNodeDeployConfigClass { isChartInstalled: boolean; cacheDir: string; chartDirectory: string; mirrorNodeChartDirectory: string; clusterContext: string; clusterReference: ClusterReferenceName; namespace: NamespaceName; enableIngress: boolean; ingressControllerValueFile: string; mirrorStaticIp: string; valuesFile: string; valuesArg: string; quiet: boolean; mirrorNodeVersion: string; componentImage: string; pinger: boolean; operatorId: string; operatorKey: string; useExternalDatabase: boolean; storageType: constants.StorageType; storageReadAccessKey: string; storageReadSecrets: string; storageEndpoint: string; storageBucket: string; storageBucketPrefix: string; storageBucketRegion: string; externalDatabaseHost: Optional<string>; externalDatabaseOwnerUsername: Optional<string>; externalDatabaseOwnerPassword: Optional<string>; externalDatabaseReadonlyUsername: Optional<string>; externalDatabaseReadonlyPassword: Optional<string>; domainName: Optional<string>; forcePortForward: Optional<boolean>; releaseName: string; ingressReleaseName: string; newMirrorNodeComponent: MirrorNodeStateSchema; isLegacyChartInstalled: boolean; id: number; soloChartVersion: string; deployment: DeploymentName; forceBlockNodeIntegration: boolean; installSharedResources: boolean; parallelDeploy: boolean; } interface MirrorNodeDeployContext { config: MirrorNodeDeployConfigClass; addressBook: string; } interface MirrorNodeDestroyConfigClass { namespace: NamespaceName; clusterContext: string; isChartInstalled: boolean; clusterReference: ClusterReferenceName; id: ComponentId; releaseName: string; ingressReleaseName: string; isLegacyChartInstalled: boolean; isIngressControllerChartInstalled: boolean; } interface MirrorNodeDestroyContext { config: MirrorNodeDestroyConfigClass; } export declare class MirrorNodeCommand extends BaseCommand { private readonly postgresSharedResource; private readonly sharedResourceManager; private readonly accountManager?; private readonly eventBus?; private static readonly MIRROR_ENVIRONMENT_VARIABLE_PREFIX; private static readonly MIRROR_CHART_NAMESPACE; constructor(postgresSharedResource: PostgresSharedResource, sharedResourceManager: SharedResourceManager, accountManager?: AccountManager, eventBus?: SoloEventBus); private static readonly DEPLOY_CONFIGS_NAME; private static readonly UPGRADE_CONFIGS_NAME; static readonly DEPLOY_FLAGS_LIST: CommandFlags; static readonly UPGRADE_FLAGS_LIST: CommandFlags; static readonly DESTROY_FLAGS_LIST: CommandFlags; private prepareBlockNodeIntegrationValues; private prepareValuesArg; private deployMirrorNode; private getReleaseName; private getIngressReleaseName; private renderReleaseName; private renderIngressReleaseName; private enableSharedResourcesTask; private initializeSharedPostgresDatabaseTask; /** * Installs the mirror chart with all application components disabled in order to create the * `mirror-passwords` secret. The init script (run by {@link initializeSharedPostgresDatabaseTask}) * reads that secret to obtain the DB user passwords, so the secret must exist before init runs. * The importer must not be running during init (it would hold a session that blocks DROP DATABASE), * so we use this lightweight prime install instead of a full chart install. * * Skipped when the secret already exists (upgrade path) or when using an external database. */ /** * Deletes the `<release>-redis` secret so that the subsequent mirror chart install/upgrade * re-creates it cleanly. This is necessary because Kubernetes strategic-merge-patch does not * remove keys — stale `SPRING_DATA_REDIS_SENTINEL_NODES` values written by a previous install * (using the internal chart-managed Redis) would otherwise persist and cause pods to try to * resolve a non-existent hostname. */ private deleteStaleRedisSecretTask; private primePostgresSecretTask; private enableMirrorNodeTask; private checkPodsAreReadyNodeTask; private enablePortForwardingTask; add(argv: ArgvStruct): Promise<boolean>; upgrade(argv: ArgvStruct): Promise<boolean>; private addMirrorNodeMemoryOverrides; private validateExternalDatabaseFlags; /** * Encodes a shard.realm.num entity ID into the integer form used by the mirror node database. * Matches the encoding in EntityId.java: |10-bit shard|16-bit realm|38-bit num| */ private static encodeEntityId; destroy(argv: ArgvStruct): Promise<boolean>; /** Removes the mirror node components from remote config. */ disableMirrorNodeComponents(): SoloListrTask<MirrorNodeDestroyContext>; /** Removes the Postgres and Redis components from remote config when shared resources are destroyed. */ disableSharedResourceComponents(): SoloListrTask<MirrorNodeDestroyContext>; /** Adds the mirror node components to remote config. */ addMirrorNodeComponents(): SoloListrTask<MirrorNodeDeployContext>; close(): Promise<void>; private checkIfLegacyChartIsInstalled; private inferMirrorNodeId; private inferDestroyData; private inferInstalledIngressReleaseName; private adoptMirrorIngressControllerRbacOwnership; } export {};