Skip to content

Commit 9301ce0

Browse files
committed
updates to remove recycle of haproxy
Signed-off-by: Jeromy Cannon <[email protected]>
1 parent 0f10ab4 commit 9301ce0

13 files changed

+42
-178
lines changed

src/commands/network.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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=envoy-proxy'
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=haproxy'
227227
], 1, 60 * 15, 1000) // timeout 15 minutes
228228
})

src/commands/node.mjs

Lines changed: 10 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,12 @@ export class NodeCommand extends BaseCommand {
706706
title: 'Check node proxies are ACTIVE',
707707
task: async (ctx, parentTask) => {
708708
const subTasks = []
709-
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
710709
for (const nodeId of ctx.config.nodeIds) {
711710
subTasks.push({
712711
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
713-
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
712+
task: async () => await self.k8.waitForPodReady(
713+
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
714+
1, 300, 2000)
714715
})
715716
}
716717

@@ -740,93 +741,6 @@ export class NodeCommand extends BaseCommand {
740741
return true
741742
}
742743

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-
830744
async stop (argv) {
831745
const self = this
832746

@@ -1131,11 +1045,12 @@ export class NodeCommand extends BaseCommand {
11311045
// logs will have a lot of white noise from being behind
11321046
task: async (ctx, task) => {
11331047
const subTasks = []
1134-
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
11351048
for (const nodeId of ctx.config.nodeIds) {
11361049
subTasks.push({
11371050
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
1138-
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
1051+
task: async () => await self.k8.waitForPodReady(
1052+
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
1053+
1, 300, 2000)
11391054
})
11401055
}
11411056

@@ -1474,11 +1389,12 @@ export class NodeCommand extends BaseCommand {
14741389
// logs will have a lot of white noise from being behind
14751390
task: async (ctx, task) => {
14761391
const subTasks = []
1477-
let localPort = constants.LOCAL_NODE_PROXY_START_PORT
1478-
for (const nodeId of ctx.config.allNodeIds) {
1392+
for (const nodeId of ctx.config.nodeIds) {
14791393
subTasks.push({
14801394
title: `Check proxy for node: ${chalk.yellow(nodeId)}`,
1481-
task: async () => await self.checkNetworkNodeProxyUp(nodeId, localPort++)
1395+
task: async () => await self.k8.waitForPodReady(
1396+
[`app=haproxy-${nodeId}`, 'fullstack.hedera.com/type=haproxy'],
1397+
1, 300, 2000)
14821398
})
14831399
}
14841400

@@ -1781,33 +1697,6 @@ export class NodeCommand extends BaseCommand {
17811697
}
17821698
}
17831699

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-
18111700
async bumpHederaConfigVersion (configTxtPath) {
18121701
const lines = (await readFile(configTxtPath, 'utf-8')).split('\n')
18131702

src/core/k8.mjs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -767,31 +767,6 @@ export class K8 {
767767
}
768768
}
769769

770-
async recyclePodByLabels (podLabels, maxAttempts = 30, delay = 2000, waitForPodMaxAttempts = 10, waitForPodDelay = 2000) {
771-
const podArray = await this.getPodsByLabel(podLabels)
772-
for (const pod of podArray) {
773-
const podName = pod.metadata.name
774-
await this.kubeClient.deleteNamespacedPod(podName, this.configManager.getFlag(flags.namespace))
775-
}
776-
777-
let attempts = 0
778-
while (attempts++ < maxAttempts) {
779-
try {
780-
const pods = await this.waitForPods([constants.POD_PHASE_RUNNING],
781-
podLabels, 1, waitForPodMaxAttempts, waitForPodDelay)
782-
if (pods.length === podArray.length) {
783-
return pods
784-
}
785-
} catch (e) {
786-
this.logger.warn(`deleted pod still not running [${podLabels.join(',')}, attempt: ${attempts}/${maxAttempts}]`)
787-
}
788-
789-
await sleep(delay)
790-
}
791-
792-
throw new FullstackTestingError(`pods are not running after deletion with labels [${podLabels.join(',')}]`)
793-
}
794-
795770
/**
796771
* Wait for pod
797772
* @param phases an array of acceptable phases of the pods

test/e2e/commands/account.test.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
import { AccountId, PrivateKey } from '@hashgraph/sdk'
2020
import {
21-
afterAll, beforeAll,
21+
afterAll,
22+
beforeAll,
2223
describe,
2324
expect,
2425
it
@@ -30,6 +31,7 @@ import * as version from '../../../version.mjs'
3031
import {
3132
bootstrapNetwork,
3233
getDefaultArgv,
34+
HEDERA_PLATFORM_VERSION_TAG,
3335
TEST_CLUSTER,
3436
testLogger
3537
} from '../../test_util.js'
@@ -43,7 +45,7 @@ describe('AccountCommand', () => {
4345
const testSystemAccounts = [[3, 5]]
4446
const argv = getDefaultArgv()
4547
argv[flags.namespace.name] = namespace
46-
argv[flags.releaseTag.name] = 'v0.47.0-alpha.0'
48+
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG
4749
argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM
4850
argv[flags.nodeIDs.name] = 'node0'
4951
argv[flags.generateGossipKeys.name] = true

test/e2e/commands/cluster.test.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ import {
2020
beforeEach,
2121
describe,
2222
expect,
23-
it, jest
23+
it,
24+
jest
2425
} from '@jest/globals'
2526
import {
2627
bootstrapTestVariables,
2728
getDefaultArgv,
29+
HEDERA_PLATFORM_VERSION_TAG,
2830
TEST_CLUSTER
2931
} from '../../test_util.js'
3032
import {
@@ -44,7 +46,7 @@ describe('ClusterCommand', () => {
4446
const namespace = testName
4547
const argv = getDefaultArgv()
4648
argv[flags.namespace.name] = namespace
47-
argv[flags.releaseTag.name] = 'v0.47.0-alpha.0'
49+
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG
4850
argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM
4951
argv[flags.nodeIDs.name] = 'node0'
5052
argv[flags.generateGossipKeys.name] = true

test/e2e/commands/mirror_node.test.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
*/
1818

1919
import {
20-
afterAll, afterEach, beforeAll, describe,
20+
afterAll,
21+
afterEach,
22+
beforeAll,
23+
describe,
2124
expect,
2225
it
2326
} from '@jest/globals'
@@ -28,6 +31,7 @@ import {
2831
import {
2932
bootstrapNetwork,
3033
getDefaultArgv,
34+
HEDERA_PLATFORM_VERSION_TAG,
3135
TEST_CLUSTER
3236
} from '../../test_util.js'
3337
import * as version from '../../../version.mjs'
@@ -42,7 +46,7 @@ describe('MirrorNodeCommand', () => {
4246
const namespace = testName
4347
const argv = getDefaultArgv()
4448
argv[flags.namespace.name] = namespace
45-
argv[flags.releaseTag.name] = 'v0.47.0-alpha.0'
49+
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG
4650
argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM
4751

4852
argv[flags.nodeIDs.name] = 'node0' // use a single node to reduce resource during e2e tests

test/e2e/commands/network.test.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717
*/
1818

1919
import {
20-
afterAll, beforeAll,
20+
afterAll,
21+
beforeAll,
2122
describe,
2223
expect,
2324
it
2425
} from '@jest/globals'
2526
import {
2627
bootstrapTestVariables,
27-
getDefaultArgv
28+
getDefaultArgv,
29+
HEDERA_PLATFORM_VERSION_TAG
2830
} from '../../test_util.js'
2931
import {
3032
constants
@@ -38,7 +40,7 @@ describe('NetworkCommand', () => {
3840
const namespace = testName
3941
const argv = getDefaultArgv()
4042
argv[flags.namespace.name] = namespace
41-
argv[flags.releaseTag.name] = 'v0.47.0-alpha.0'
43+
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG
4244
argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM
4345
argv[flags.nodeIDs.name] = 'node0'
4446
argv[flags.generateGossipKeys.name] = true

test/e2e/commands/relay.test.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
*/
1717

1818
import {
19-
afterAll, afterEach, describe,
19+
afterAll,
20+
afterEach,
21+
describe,
2022
expect,
2123
it
2224
} from '@jest/globals'
@@ -27,6 +29,7 @@ import {
2729
import {
2830
bootstrapNetwork,
2931
getDefaultArgv,
32+
HEDERA_PLATFORM_VERSION_TAG,
3033
TEST_CLUSTER
3134
} from '../../test_util.js'
3235
import * as version from '../../../version.mjs'
@@ -38,7 +41,7 @@ describe('RelayCommand', () => {
3841
const namespace = testName
3942
const argv = getDefaultArgv()
4043
argv[flags.namespace.name] = namespace
41-
argv[flags.releaseTag.name] = 'v0.47.0-alpha.0'
44+
argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG
4245
argv[flags.keyFormat.name] = constants.KEY_FORMAT_PEM
4346

4447
argv[flags.nodeIDs.name] = 'node0,node1'

test/e2e/core/k8_e2e.test.mjs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,4 @@ describe('K8', () => {
176176
const pvcs = await k8.listPvcsByNamespace(k8._getNamespace())
177177
expect(pvcs.length).toBeGreaterThan(0)
178178
}, defaultTimeout)
179-
180-
it('should be able to recycle pod by labels', async () => {
181-
const podLabels = ['app=haproxy-node0', 'fullstack.hedera.com/type=haproxy']
182-
const podArray1 = await k8.getPodsByLabel(podLabels)
183-
const podsArray2 = await k8.recyclePodByLabels(podLabels)
184-
expect(podsArray2.length >= podArray1.length).toBeTruthy()
185-
}, 120000)
186179
})

test/e2e/e2e_node_util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ import {
3838
import {
3939
bootstrapNetwork,
4040
getDefaultArgv,
41-
getTestConfigManager, getTmpDir,
41+
getTestConfigManager,
42+
getTmpDir,
43+
HEDERA_PLATFORM_VERSION_TAG,
4244
TEST_CLUSTER
4345
} from '../test_util.js'
4446
import { sleep } from '../../src/core/helpers.mjs'
4547
import path from 'path'
4648
import fs from 'fs'
4749
import crypto from 'crypto'
4850

49-
export function e2eNodeKeyRefreshAddTest (keyFormat, testName, mode, releaseTag = 'v0.49.0-alpha.2') {
51+
export function e2eNodeKeyRefreshAddTest (keyFormat, testName, mode, releaseTag = HEDERA_PLATFORM_VERSION_TAG) {
5052
const defaultTimeout = 20000
5153

5254
describe(`NodeCommand [testName ${testName}, mode ${mode}, keyFormat: ${keyFormat}, release ${releaseTag}]`, () => {

test/test_util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545

4646
export const testLogger = logging.NewLogger('debug', true)
4747
export const TEST_CLUSTER = 'solo-e2e'
48+
export const HEDERA_PLATFORM_VERSION_TAG = 'v0.49.0-alpha.2'
4849

4950
export function getTestCacheDir (testName) {
5051
const baseDir = 'test/data/tmp'

0 commit comments

Comments
 (0)