Skip to content

fix: updates to accommodate haproxy changes in FST charts #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7745aac
updates to remove recycle of haproxy
jeromy-cannon May 22, 2024
9e74ffc
TODO
jeromy-cannon May 22, 2024
a5eb0d2
updated call in test for checking if node proxy is up
jeromy-cannon May 23, 2024
54837a0
updated call in test for checking if node proxy is up
jeromy-cannon May 23, 2024
d2124af
updated call in test for checking if node proxy is up
jeromy-cannon May 23, 2024
1442c37
updated client logger to accept more robust settings and a log file
jeromy-cannon May 23, 2024
b2adb11
moved balanceQueryShouldSucceed to test_util to be reused by mirror_n…
jeromy-cannon May 23, 2024
28c21ba
updated to use non-headless service
jeromy-cannon May 24, 2024
acdabb2
enable config log messages
matteriben May 24, 2024
a8fb584
updated to support domain names in address book from ledger
jeromy-cannon May 24, 2024
67c4bad
fixed typo
jeromy-cannon May 28, 2024
ff0d1f9
pushing current changes
jeromy-cannon May 28, 2024
205ecd6
bump fst charts to 0.26.0
jeromy-cannon May 29, 2024
6f2a45d
restore package.json
jeromy-cannon May 29, 2024
5c1f900
revert to use fqdn for externalip in config.txt
jeromy-cannon May 29, 2024
f2ad485
restore delete namespace in test
jeromy-cannon May 29, 2024
c2b205d
remove skips
jeromy-cannon May 29, 2024
e723061
get nodeId from templated renderer in reverse
jeromy-cannon May 29, 2024
419b0f3
update prepareAddressBookBase64 to handle converting FQDN into IP add…
jeromy-cannon May 29, 2024
0997279
only set the sdk logger if devMode is enabled until we get the @hashg…
jeromy-cannon May 29, 2024
6915a8b
updating naming in app and timeout for test
jeromy-cannon May 29, 2024
4e413da
increase timeout
jeromy-cannon May 29, 2024
b29878c
increase default timeout
jeromy-cannon May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,4 @@ node_modules/
coverage/
deleteme.yaml
/.nyc_output/
/.nvmrc
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"check": "remark . --quiet --frail && eslint .",
"format": "remark . --quiet --frail --output && eslint --fix .",
"test-setup": "./test/e2e/setup-e2e.sh",
"test-coverage": "npm run test && npm run test-setup && npm run test-e2e-all && npm run report-coverage"
"test-coverage": "npm run test && npm run test-setup && npm run test-e2e-all && npm run report-coverage"
},
"keywords": [
"solo",
Expand Down
1 change: 1 addition & 0 deletions resources/templates/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
<MarkerFilter marker="ADV_CRYPTO_SYSTEM" onMatch="DENY" onMismatch="NEUTRAL"/>

<!-- Startup/Restart/Reconnect -->
<MarkerFilter marker="CONFIG" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="STARTUP" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="PLATFORM_STATUS" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<MarkerFilter marker="RECONNECT" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
Expand Down
2 changes: 1 addition & 1 deletion src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export const settingTxt = {
export const app = {
name: 'app',
definition: {
describe: 'Testing app anme',
describe: 'Testing app name',
defaultValue: '',
type: 'string'
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/mirror_node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class MirrorNodeCommand extends BaseCommand {
{
title: 'Prepare address book',
task: async (ctx, _) => {
ctx.addressBook = await self.accountManager.prepareAddressBookBase64()
ctx.addressBook = await self.accountManager.prepareAddressBookBase64(ctx.config.namespace)
ctx.config.valuesArg += ` --set "hedera-mirror-node.importer.addressBook=${ctx.addressBook}"`
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/commands/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class NetworkCommand extends BaseCommand {
}
},
{
title: 'Check node pods are ready',
title: 'Check node pods are running',
task:
async (ctx, task) => {
const subTasks = []
Expand All @@ -201,7 +201,7 @@ export class NetworkCommand extends BaseCommand {
}
},
{
title: 'Check proxy pods are ready',
title: 'Check proxy pods are running',
task:
async (ctx, task) => {
const subTasks = []
Expand All @@ -211,7 +211,7 @@ export class NetworkCommand extends BaseCommand {
subTasks.push({
title: `Check HAProxy for: ${chalk.yellow(nodeId)}`,
task: () =>
self.k8.waitForPodReady([
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
'fullstack.hedera.com/type=haproxy'
], 1, 60 * 15, 1000) // timeout 15 minutes
})
Expand All @@ -222,7 +222,7 @@ export class NetworkCommand extends BaseCommand {
subTasks.push({
title: `Check Envoy Proxy for: ${chalk.yellow(nodeId)}`,
task: () =>
self.k8.waitForPodReady([
self.k8.waitForPods([constants.POD_PHASE_RUNNING], [
'fullstack.hedera.com/type=envoy-proxy'
], 1, 60 * 15, 1000) // timeout 15 minutes
})
Expand Down Expand Up @@ -372,7 +372,7 @@ export class NetworkCommand extends BaseCommand {
}
},
{
title: 'Waiting for network pods to be ready',
title: 'Waiting for network pods to be running',
task: async (ctx, _) => {
await this.k8.waitForPods([constants.POD_PHASE_RUNNING], [
'fullstack.hedera.com/type=network-node'
Expand Down
160 changes: 24 additions & 136 deletions src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
const podName = Templates.renderNetworkPodName(nodeId)

try {
await this.k8.waitForPodReady([
await this.k8.waitForPods([constants.POD_PHASE_RUNNING], [
'fullstack.hedera.com/type=network-node',
`fullstack.hedera.com/node-name=${nodeId}`
], 1, maxAttempts, delay)
Expand Down Expand Up @@ -556,11 +556,7 @@
const configTxtPath = `${config.stagingDir}/config.txt`
const template = `${constants.RESOURCES_DIR}/templates/config.template`
const appName = self.configManager.getFlag(flags.app)
if (appName !== '') {
await self.platformInstaller.prepareConfigTxt(config.nodeIds, configTxtPath, config.releaseTag, config.chainId, template, appName)
} else {
await self.platformInstaller.prepareConfigTxt(config.nodeIds, configTxtPath, config.releaseTag, config.chainId, template)
}
await self.platformInstaller.prepareConfigTxt(config.nodeIds, configTxtPath, config.releaseTag, config.chainId, template, appName || undefined)
}
}
]
Expand Down Expand Up @@ -706,11 +702,12 @@
title: 'Check node proxies are ACTIVE',
task: async (ctx, parentTask) => {
const subTasks = []
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
for (const nodeId of ctx.config.nodeIds) {
subTasks.push({
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
task: async () => await self.k8.waitForPodReady(
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
1, 300, 2000)
})
}

Expand Down Expand Up @@ -740,93 +737,6 @@
return true
}

/**
* Check if the network node proxy is up, requires close() to be called after
* @param nodeId the node id
* @param localPort the local port to forward to
* @param maxAttempts the maximum number of attempts
* @param delay the delay between attempts
* @returns {Promise<boolean>} true if the proxy is up
*/
async checkNetworkNodeProxyUp (nodeId, localPort, maxAttempts = 6, delay = 20000) {
const podLabels = [`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy']
let podArray = await this.k8.getPodsByLabel(podLabels)

let attempts = 0
let status = null
if (podArray.length > 0) {
let podName = podArray[0].metadata.name
let portForwarder = null

try {
while (attempts < maxAttempts) {
if (attempts === 0) {
try {
portForwarder = await this.k8.portForward(podName, localPort, 5555)
} catch (e) {
throw new FullstackTestingError(`failed to portForward for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
}
try {
await this.k8.testConnection('localhost', localPort)
} catch (e) {
throw new FullstackTestingError(`failed to test connection for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
}
} else if (attempts % 5 === 0) {
this.logger.debug(`Recycling proxy ${podName} [attempt: ${attempts}/${maxAttempts}]`)
try {
await this.k8.stopPortForward(portForwarder)
} catch (e) {
throw new FullstackTestingError(`failed to stop portForward for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
}
try {
await this.k8.recyclePodByLabels(podLabels)
} catch (e) {
throw new FullstackTestingError(`failed to recycle pod for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
}
podArray = await this.k8.getPodsByLabel(podLabels)
podName = podArray[0].metadata.name
try {
portForwarder = await this.k8.portForward(podName, localPort, 5555)
} catch (e) {
throw new FullstackTestingError(`failed to portForward for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
}
try {
await this.k8.testConnection('localhost', localPort)
} catch (e) {
throw new FullstackTestingError(`failed to test connection for podName ${podName} with localPort ${localPort}: ${e.message}`, e)
}
}

try {
status = await this.getNodeProxyStatus(`http://localhost:${localPort}/v2/services/haproxy/stats/native?type=backend`)
} catch (e) {
throw new FullstackTestingError(`failed to get proxy status at http://localhost:${localPort}/v2/services/haproxy/stats/native?type=backend: ${e.message}`, e)
}
if (status === 'UP') {
break
}

this.logger.debug(`Proxy ${podName} is not UP. Checking again in ${delay}ms ... [attempt: ${attempts}/${maxAttempts}]`)
attempts++
await sleep(delay)
}
} catch (e) {
throw new FullstackTestingError(`failed to check proxy for '${nodeId}' with localPort ${localPort}: ${e.message}`, e)
} finally {
if (portForwarder !== null) {
this._portForwards.push(portForwarder)
}
}

if (status === 'UP') {
this.logger.debug(`Proxy ${podName} is UP. [attempt: ${attempts}/${maxAttempts}]`)
return true
}
}

throw new FullstackTestingError(`proxy for '${nodeId}' is not UP [ attempt = ${attempts}/${maxAttempts}`)
}

async stop (argv) {
const self = this

Expand Down Expand Up @@ -1052,10 +962,11 @@

const subTasks = []
const nodeList = []
const serviceMap = await self.accountManager.getNodeServiceMap(ctx.config.namespace)
for (const serviceObject of serviceMap.values()) {
nodeList.push(serviceObject.node)
const networkNodeServicesMap = await self.accountManager.getNodeServiceMap(ctx.config.namespace)
for (const networkNodeServices of networkNodeServicesMap.values()) {
nodeList.push(networkNodeServices.nodeName)
}

for (const nodeId of config.nodeIds) {
const podName = config.podNames[nodeId]
subTasks.push({
Expand Down Expand Up @@ -1131,11 +1042,12 @@
// logs will have a lot of white noise from being behind
task: async (ctx, task) => {
const subTasks = []
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
for (const nodeId of ctx.config.nodeIds) {
subTasks.push({
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
task: async () => await self.k8.waitForPodReady(
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
1, 300, 2000)
})
}

Expand Down Expand Up @@ -1217,8 +1129,8 @@
task: async (ctx, task) => {
ctx.config.serviceMap = await self.accountManager.getNodeServiceMap(
ctx.config.namespace)
for (const serviceObject of ctx.config.serviceMap.values()) {
ctx.config.existingNodeIds.push(serviceObject.node)
for (/** @type {NetworkNodeServices} **/ const networkNodeServices of ctx.config.serviceMap.values()) {
ctx.config.existingNodeIds.push(networkNodeServices.nodeName)
}

return self.taskCheckNetworkNodePods(ctx, task, ctx.config.existingNodeIds)
Expand All @@ -1229,12 +1141,14 @@
task: async (ctx, task) => {
const values = { hedera: { nodes: [] } }
let maxNum
for (const serviceObject of ctx.config.serviceMap.values()) {
for (/** @type {NetworkNodeServices} **/ const networkNodeServices of ctx.config.serviceMap.values()) {
values.hedera.nodes.push({
accountId: serviceObject.accountId,
name: serviceObject.node
accountId: networkNodeServices.accountId,
name: networkNodeServices.nodeName
})
maxNum = maxNum > AccountId.fromString(serviceObject.accountId).num ? maxNum : AccountId.fromString(serviceObject.accountId).num
maxNum = maxNum > AccountId.fromString(networkNodeServices.accountId).num
? maxNum

Check warning on line 1150 in src/commands/node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/node.mjs#L1150

Added line #L1150 was not covered by tests
: AccountId.fromString(networkNodeServices.accountId).num
}
for (const nodeId of ctx.config.nodeIds) {
const accountId = AccountId.fromString(values.hedera.nodes[0].accountId)
Expand Down Expand Up @@ -1474,11 +1388,12 @@
// logs will have a lot of white noise from being behind
task: async (ctx, task) => {
const subTasks = []
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
for (const nodeId of ctx.config.allNodeIds) {
for (const nodeId of ctx.config.nodeIds) {
subTasks.push({
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
task: async () => await self.k8.waitForPodReady(
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
1, 300, 2000)
})
}

Expand Down Expand Up @@ -1781,33 +1696,6 @@
}
}

async getNodeProxyStatus (url) {
try {
this.logger.debug(`Fetching proxy status from: ${url}`)
const res = await fetch(url, {
method: 'GET',
signal: AbortSignal.timeout(5000),
headers: {
Authorization: `Basic ${Buffer.from(
`${constants.NODE_PROXY_USER_ID}:${constants.NODE_PROXY_PASSWORD}`).toString('base64')}`
}
})
const response = await res.json()

if (res.status === 200) {
const status = response[0]?.stats?.filter(
(stat) => stat.name === 'http_backend')[0]?.stats?.status
this.logger.debug(`Proxy status: ${status}`)
return status
} else {
this.logger.debug(`Proxy request status code: ${res.status}`)
return null
}
} catch (e) {
this.logger.error(`Error in fetching proxy status: ${e.message}`, e)
}
}

async bumpHederaConfigVersion (configTxtPath) {
const lines = (await readFile(configTxtPath, 'utf-8')).split('\n')

Expand Down
Loading
Loading