Skip to content

Commit 8997849

Browse files
fix: updates to accommodate haproxy changes in FST charts (#321)
Signed-off-by: Jeromy Cannon <[email protected]> Signed-off-by: Matt Riben <[email protected]> Co-authored-by: Matt Riben <[email protected]>
1 parent 7b4e5b7 commit 8997849

30 files changed

+417
-287
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,4 @@ node_modules/
515515
coverage/
516516
deleteme.yaml
517517
/.nyc_output/
518+
/.nvmrc

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"check": "remark . --quiet --frail && eslint .",
2828
"format": "remark . --quiet --frail --output && eslint --fix .",
2929
"test-setup": "./test/e2e/setup-e2e.sh",
30-
"test-coverage": "npm run test && npm run test-setup && npm run test-e2e-all && npm run report-coverage"
30+
"test-coverage": "npm run test && npm run test-setup && npm run test-e2e-all && npm run report-coverage"
3131
},
3232
"keywords": [
3333
"solo",

resources/templates/log4j2.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
<MarkerFilter marker="ADV_CRYPTO_SYSTEM" onMatch="DENY" onMismatch="NEUTRAL"/>
162162

163163
<!-- Startup/Restart/Reconnect -->
164+
<MarkerFilter marker="CONFIG" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
164165
<MarkerFilter marker="STARTUP" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
165166
<MarkerFilter marker="PLATFORM_STATUS" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
166167
<MarkerFilter marker="RECONNECT" onMatch="ACCEPT" onMismatch="NEUTRAL"/>

src/commands/flags.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export const settingTxt = {
402402
export const app = {
403403
name: 'app',
404404
definition: {
405-
describe: 'Testing app anme',
405+
describe: 'Testing app name',
406406
defaultValue: '',
407407
type: 'string'
408408
}

src/commands/mirror_node.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class MirrorNodeCommand extends BaseCommand {
9494
{
9595
title: 'Prepare address book',
9696
task: async (ctx, _) => {
97-
ctx.addressBook = await self.accountManager.prepareAddressBookBase64()
97+
ctx.addressBook = await self.accountManager.prepareAddressBookBase64(ctx.config.namespace)
9898
ctx.config.valuesArg += ` --set "hedera-mirror-node.importer.addressBook=${ctx.addressBook}"`
9999
}
100100
},

src/commands/network.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class NetworkCommand extends BaseCommand {
174174
}
175175
},
176176
{
177-
title: 'Check node pods are ready',
177+
title: 'Check node pods are running',
178178
task:
179179
async (ctx, task) => {
180180
const subTasks = []
@@ -201,7 +201,7 @@ export class NetworkCommand extends BaseCommand {
201201
}
202202
},
203203
{
204-
title: 'Check proxy pods are ready',
204+
title: 'Check proxy pods are running',
205205
task:
206206
async (ctx, task) => {
207207
const subTasks = []
@@ -211,7 +211,7 @@ export class NetworkCommand extends BaseCommand {
211211
subTasks.push({
212212
title: `Check HAProxy for: ${chalk.yellow(nodeId)}`,
213213
task: () =>
214-
self.k8.waitForPodReady([
214+
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
215215
'fullstack.hedera.com/type=haproxy'
216216
], 1, 60 * 15, 1000) // timeout 15 minutes
217217
})
@@ -222,7 +222,7 @@ export class NetworkCommand extends BaseCommand {
222222
subTasks.push({
223223
title: `Check Envoy Proxy for: ${chalk.yellow(nodeId)}`,
224224
task: () =>
225-
self.k8.waitForPodReady([
225+
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
226226
'fullstack.hedera.com/type=envoy-proxy'
227227
], 1, 60 * 15, 1000) // timeout 15 minutes
228228
})
@@ -372,7 +372,7 @@ export class NetworkCommand extends BaseCommand {
372372
}
373373
},
374374
{
375-
title: 'Waiting for network pods to be ready',
375+
title: 'Waiting for network pods to be running',
376376
task: async (ctx, _) => {
377377
await this.k8.waitForPods([constants.POD_PHASE_RUNNING], [
378378
'fullstack.hedera.com/type=network-node'

src/commands/node.mjs

Lines changed: 24 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class NodeCommand extends BaseCommand {
7777
const podName = Templates.renderNetworkPodName(nodeId)
7878

7979
try {
80-
await this.k8.waitForPodReady([
80+
await this.k8.waitForPods([constants.POD_PHASE_RUNNING], [
8181
'fullstack.hedera.com/type=network-node',
8282
`fullstack.hedera.com/node-name=${nodeId}`
8383
], 1, maxAttempts, delay)
@@ -556,11 +556,7 @@ export class NodeCommand extends BaseCommand {
556556
const configTxtPath = `${config.stagingDir}/config.txt`
557557
const template = `${constants.RESOURCES_DIR}/templates/config.template`
558558
const appName = self.configManager.getFlag(flags.app)
559-
if (appName !== '') {
560-
await self.platformInstaller.prepareConfigTxt(config.nodeIds, configTxtPath, config.releaseTag, config.chainId, template, appName)
561-
} else {
562-
await self.platformInstaller.prepareConfigTxt(config.nodeIds, configTxtPath, config.releaseTag, config.chainId, template)
563-
}
559+
await self.platformInstaller.prepareConfigTxt(config.nodeIds, configTxtPath, config.releaseTag, config.chainId, template, appName || undefined)
564560
}
565561
}
566562
]
@@ -706,11 +702,12 @@ export class NodeCommand extends BaseCommand {
706702
title: 'Check node proxies are ACTIVE',
707703
task: async (ctx, parentTask) => {
708704
const subTasks = []
709-
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
710705
for (const nodeId of ctx.config.nodeIds) {
711706
subTasks.push({
712707
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
713-
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
708+
task: async () => await self.k8.waitForPodReady(
709+
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
710+
1, 300, 2000)
714711
})
715712
}
716713

@@ -740,93 +737,6 @@ export class NodeCommand extends BaseCommand {
740737
return true
741738
}
742739

743-
/**
744-
* Check if the network node proxy is up, requires close() to be called after
745-
* @param nodeId the node id
746-
* @param localPort the local port to forward to
747-
* @param maxAttempts the maximum number of attempts
748-
* @param delay the delay between attempts
749-
* @returns {Promise<boolean>} true if the proxy is up
750-
*/
751-
async checkNetworkNodeProxyUp (nodeId, localPort, maxAttempts = 6, delay = 20000) {
752-
const podLabels = [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy']
753-
let podArray = await this.k8.getPodsByLabel(podLabels)
754-
755-
let attempts = 0
756-
let status = null
757-
if (podArray.length > 0) {
758-
let podName = podArray[0].metadata.name
759-
let portForwarder = null
760-
761-
try {
762-
while (attempts < maxAttempts) {
763-
if (attempts === 0) {
764-
try {
765-
portForwarder = await this.k8.portForward(podName, localPort, 5555)
766-
} catch (e) {
767-
throw new FullstackTestingError(`failed to portForward for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
768-
}
769-
try {
770-
await this.k8.testConnection('localhost', localPort)
771-
} catch (e) {
772-
throw new FullstackTestingError(`failed to test connection for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
773-
}
774-
} else if (attempts % 5 === 0) {
775-
this.logger.debug(`Recycling proxy ${podName} [attempt: ${attempts}/${maxAttempts}]`)
776-
try {
777-
await this.k8.stopPortForward(portForwarder)
778-
} catch (e) {
779-
throw new FullstackTestingError(`failed to stop portForward for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
780-
}
781-
try {
782-
await this.k8.recyclePodByLabels(podLabels)
783-
} catch (e) {
784-
throw new FullstackTestingError(`failed to recycle pod for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
785-
}
786-
podArray = await this.k8.getPodsByLabel(podLabels)
787-
podName = podArray[0].metadata.name
788-
try {
789-
portForwarder = await this.k8.portForward(podName, localPort, 5555)
790-
} catch (e) {
791-
throw new FullstackTestingError(`failed to portForward for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
792-
}
793-
try {
794-
await this.k8.testConnection('localhost', localPort)
795-
} catch (e) {
796-
throw new FullstackTestingError(`failed to test connection for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
797-
}
798-
}
799-
800-
try {
801-
status = await this.getNodeProxyStatus(`http://localhost:${localPort}/v2/services/haproxy/stats/native?type=backend`)
802-
} catch (e) {
803-
throw new FullstackTestingError(`failed to get proxy status at http://localhost:${localPort}/v2/services/haproxy/stats/native?type=backend: ${e.message}`, e)
804-
}
805-
if (status === 'UP') {
806-
break
807-
}
808-
809-
this.logger.debug(`Proxy ${podName} is not UP. Checking again in ${delay}ms ... [attempt: ${attempts}/${maxAttempts}]`)
810-
attempts++
811-
await sleep(delay)
812-
}
813-
} catch (e) {
814-
throw new FullstackTestingError(`failed to check proxy for '${nodeId}' with localPort ${localPort}: ${e.message}`, e)
815-
} finally {
816-
if (portForwarder !== null) {
817-
this._portForwards.push(portForwarder)
818-
}
819-
}
820-
821-
if (status === 'UP') {
822-
this.logger.debug(`Proxy ${podName} is UP. [attempt: ${attempts}/${maxAttempts}]`)
823-
return true
824-
}
825-
}
826-
827-
throw new FullstackTestingError(`proxy for '${nodeId}' is not UP [ attempt = ${attempts}/${maxAttempts}`)
828-
}
829-
830740
async stop (argv) {
831741
const self = this
832742

@@ -1052,10 +962,11 @@ export class NodeCommand extends BaseCommand {
1052962

1053963
const subTasks = []
1054964
const nodeList = []
1055-
const serviceMap = await self.accountManager.getNodeServiceMap(ctx.config.namespace)
1056-
for (const serviceObject of serviceMap.values()) {
1057-
nodeList.push(serviceObject.node)
965+
const networkNodeServicesMap = await self.accountManager.getNodeServiceMap(ctx.config.namespace)
966+
for (const networkNodeServices of networkNodeServicesMap.values()) {
967+
nodeList.push(networkNodeServices.nodeName)
1058968
}
969+
1059970
for (const nodeId of config.nodeIds) {
1060971
const podName = config.podNames[nodeId]
1061972
subTasks.push({
@@ -1131,11 +1042,12 @@ export class NodeCommand extends BaseCommand {
11311042
// logs will have a lot of white noise from being behind
11321043
task: async (ctx, task) => {
11331044
const subTasks = []
1134-
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
11351045
for (const nodeId of ctx.config.nodeIds) {
11361046
subTasks.push({
11371047
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
1138-
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
1048+
task: async () => await self.k8.waitForPodReady(
1049+
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
1050+
1, 300, 2000)
11391051
})
11401052
}
11411053

@@ -1217,8 +1129,8 @@ export class NodeCommand extends BaseCommand {
12171129
task: async (ctx, task) => {
12181130
ctx.config.serviceMap = await self.accountManager.getNodeServiceMap(
12191131
ctx.config.namespace)
1220-
for (const serviceObject of ctx.config.serviceMap.values()) {
1221-
ctx.config.existingNodeIds.push(serviceObject.node)
1132+
for (/** @type {NetworkNodeServices} **/ const networkNodeServices of ctx.config.serviceMap.values()) {
1133+
ctx.config.existingNodeIds.push(networkNodeServices.nodeName)
12221134
}
12231135

12241136
return self.taskCheckNetworkNodePods(ctx, task, ctx.config.existingNodeIds)
@@ -1229,12 +1141,14 @@ export class NodeCommand extends BaseCommand {
12291141
task: async (ctx, task) => {
12301142
const values = { hedera: { nodes: [] } }
12311143
let maxNum
1232-
for (const serviceObject of ctx.config.serviceMap.values()) {
1144+
for (/** @type {NetworkNodeServices} **/ const networkNodeServices of ctx.config.serviceMap.values()) {
12331145
values.hedera.nodes.push({
1234-
accountId: serviceObject.accountId,
1235-
name: serviceObject.node
1146+
accountId: networkNodeServices.accountId,
1147+
name: networkNodeServices.nodeName
12361148
})
1237-
maxNum = maxNum > AccountId.fromString(serviceObject.accountId).num ? maxNum : AccountId.fromString(serviceObject.accountId).num
1149+
maxNum = maxNum > AccountId.fromString(networkNodeServices.accountId).num
1150+
? maxNum
1151+
: AccountId.fromString(networkNodeServices.accountId).num
12381152
}
12391153
for (const nodeId of ctx.config.nodeIds) {
12401154
const accountId = AccountId.fromString(values.hedera.nodes[0].accountId)
@@ -1474,11 +1388,12 @@ export class NodeCommand extends BaseCommand {
14741388
// logs will have a lot of white noise from being behind
14751389
task: async (ctx, task) => {
14761390
const subTasks = []
1477-
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
1478-
for (const nodeId of ctx.config.allNodeIds) {
1391+
for (const nodeId of ctx.config.nodeIds) {
14791392
subTasks.push({
14801393
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
1481-
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
1394+
task: async () => await self.k8.waitForPodReady(
1395+
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
1396+
1, 300, 2000)
14821397
})
14831398
}
14841399

@@ -1781,33 +1696,6 @@ export class NodeCommand extends BaseCommand {
17811696
}
17821697
}
17831698

1784-
async getNodeProxyStatus (url) {
1785-
try {
1786-
this.logger.debug(`Fetching proxy status from: ${url}`)
1787-
const res = await fetch(url, {
1788-
method: 'GET',
1789-
signal: AbortSignal.timeout(5000),
1790-
headers: {
1791-
Authorization: `Basic ${Buffer.from(
1792-
`${constants.NODE_PROXY_USER_ID}:${constants.NODE_PROXY_PASSWORD}`).toString('base64')}`
1793-
}
1794-
})
1795-
const response = await res.json()
1796-
1797-
if (res.status === 200) {
1798-
const status = response[0]?.stats?.filter(
1799-
(stat) => stat.name === 'http_backend')[0]?.stats?.status
1800-
this.logger.debug(`Proxy status: ${status}`)
1801-
return status
1802-
} else {
1803-
this.logger.debug(`Proxy request status code: ${res.status}`)
1804-
return null
1805-
}
1806-
} catch (e) {
1807-
this.logger.error(`Error in fetching proxy status: ${e.message}`, e)
1808-
}
1809-
}
1810-
18111699
async bumpHederaConfigVersion (configTxtPath) {
18121700
const lines = (await readFile(configTxtPath, 'utf-8')).split('\n')
18131701

0 commit comments

Comments
 (0)