Skip to content

Commit

Permalink
fix: relay command
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <lenin.mehedy@swirldslabs.com>
  • Loading branch information
leninmehedy committed Jan 24, 2024
1 parent 5ba143c commit acd277f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
10 changes: 10 additions & 0 deletions fullstack-network-manager/src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ export const releaseTag = {
}
}

export const relayReleaseTag = {
name: 'relay-release',
definition: {
describe: 'Relay release tag to be used (e.g. v0.39.1)',
default: '',
type: 'string'
}
}

export const cacheDir = {
name: 'cache-dir',
definition: {
Expand Down Expand Up @@ -306,6 +315,7 @@ export const allFlags = [
deployCertManagerCrds,
acmeClusterIssuer,
releaseTag,
relayReleaseTag,
cacheDir,
nodeIDs,
force,
Expand Down
20 changes: 20 additions & 0 deletions fullstack-network-manager/src/commands/prompts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ export async function promptReleaseTag (task, input) {
}
}

export async function promptRelayReleaseTag (task, input) {
try {
if (!input) {
input = await task.prompt(ListrEnquirerPromptAdapter).run({
type: 'text',
default: flags.relayReleaseTag.definition.default,
message: 'Enter relay release version:'
})
}

if (!input) {
throw new FullstackTestingError('relay-release-tag cannot be empty')
}

return input
} catch (e) {
throw new FullstackTestingError(`input failed: ${flags.releaseTag.name}`, e)
}
}

export async function promptCacheDir (task, input) {
try {
if (!input) {
Expand Down
21 changes: 10 additions & 11 deletions fullstack-network-manager/src/commands/relay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { constants } from '../core/index.mjs'
import * as prompts from './prompts.mjs'

export class RelayCommand extends BaseCommand {
prepareValuesArg (valuesFile, nodeIDs, chainID, releaseTag, replicaCount, operatorID, operatorKey) {
prepareValuesArg (valuesFile, nodeIDs, chainID, relayRelease, replicaCount, operatorID, operatorKey) {
let valuesArg = ''
if (valuesFile) {
const valuesFiles = valuesFile.split(',')
Expand All @@ -23,8 +23,8 @@ export class RelayCommand extends BaseCommand {
valuesArg += ` --set config.CHAIN_ID=${chainID}`
}

if (releaseTag) {
valuesArg += ` --set image.tag=${releaseTag.replace(/^v/, '')}`
if (relayRelease) {
valuesArg += ` --set image.tag=${relayRelease.replace(/^v/, '')}`
}

if (replicaCount) {
Expand Down Expand Up @@ -76,7 +76,7 @@ export class RelayCommand extends BaseCommand {
const valuesFile = self.configManager.getFlag(flags.valuesFile)
const nodeIds = self.configManager.getFlag(flags.nodeIDs)
const chainId = self.configManager.getFlag(flags.chainId)
const releaseTag = self.configManager.getFlag(flags.releaseTag)
const relayRelease = self.configManager.getFlag(flags.relayReleaseTag)
const replicaCount = self.configManager.getFlag(flags.replicaCount)
const operatorId = self.configManager.getFlag(flags.operatorId)
const operatorKey = self.configManager.getFlag(flags.operatorKey)
Expand All @@ -92,7 +92,7 @@ export class RelayCommand extends BaseCommand {
valuesFile: await prompts.promptValuesFile(task, valuesFile),
nodeIds: await prompts.promptNodeIdsArg(task, nodeIds),
chainId: await prompts.promptChainId(task, chainId),
releaseTag: await prompts.promptReleaseTag(task, releaseTag),
relayRelease: await prompts.promptRelayReleaseTag(task, relayRelease),
replicaCount: await prompts.promptReplicaCount(task, replicaCount),
operatorId: await prompts.promptOperatorId(task, operatorId),
operatorKey: await prompts.promptOperatorId(task, operatorKey)
Expand All @@ -114,13 +114,12 @@ export class RelayCommand extends BaseCommand {
ctx.config.valuesFile,
ctx.config.nodeIds,
ctx.config.chainId,
ctx.config.releaseTag,
ctx.config.relayRelease,
ctx.config.replicaCount,
ctx.config.operatorId,
ctx.config.operatorKey
)
},
skip: (ctx, _) => ctx.isChartInstalled
}
},
{
title: 'Install JSON RPC Relay',
Expand All @@ -132,10 +131,10 @@ export class RelayCommand extends BaseCommand {

await this.chartManager.install(namespace, releaseName, chartPath, '', valuesArg)

await this.kubectl2.waitForPod(constants.POD_STATUS_READY, [
await this.kubectl2.waitForPod(constants.POD_STATUS_RUNNING, [
'app=hedera-json-rpc-relay',
`app.kubernetes.io/instance=${releaseName}`
], 1)
], 1, 120, 1000)

this.logger.showList('Deployed Relays', await self.chartManager.getInstalledCharts(namespace))
}
Expand Down Expand Up @@ -220,7 +219,7 @@ export class RelayCommand extends BaseCommand {
flags.replicaCount,
flags.chainId,
flags.nodeIDs,
flags.releaseTag,
flags.relayReleaseTag,
flags.operatorId,
flags.operatorKey
)
Expand Down

0 comments on commit acd277f

Please sign in to comment.