From 8ca8fa056c94ac8c0e9da015a84a313412b42809 Mon Sep 17 00:00:00 2001 From: Jeromy Cannon Date: Thu, 25 Jan 2024 07:31:51 +0000 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 9446ce7ac4e2c9a3e54a8eb5401d21dfed407d27 Author: Jeromy Cannon Date: Wed Jan 24 21:16:43 2024 +0000 added test Signed-off-by: Jeromy Cannon commit d12877c23a5627bdf31f03843d8ebb9c2bdc7c63 Author: Jeromy Cannon Date: Wed Jan 24 19:58:14 2024 +0000 working version Signed-off-by: Jeromy Cannon commit 093386998d213c762ed3e7c3262982c8ab8e0b8d Merge: e9555a2 1772906 Author: Lenin Mehedy Date: Thu Jan 25 08:05:01 2024 +1100 Merge branch 'main' into 605-kubernetes-javascript-client commit e9555a2427e33a3f0e2a430134666f8445938713 Author: Lenin Mehedy Date: Thu Jan 25 08:00:20 2024 +1100 fix: allow namespace to be created during chart install Signed-off-by: Lenin Mehedy commit 177290664a2023ea63f191a76ee7de846cef2b60 Author: Jeromy Cannon Date: Wed Jan 24 17:25:22 2024 +0000 chore: switch back to acme-cluster-issuer from repo now that changes have be… (#691) Signed-off-by: Jeromy Cannon commit f1191e43c34660612cd5eea226818509287142ea Author: Jeromy Cannon Date: Wed Jan 24 16:28:21 2024 +0000 chore: feedback from PR review for hedera-explorer chart changes (#690) Signed-off-by: Jeromy Cannon commit 6956df20d2022d245423edd49ec28320f03b8fe8 Author: Lenin Mehedy Date: Wed Jan 24 19:54:20 2024 +1100 rename test setup script Signed-off-by: Lenin Mehedy commit 1c8ee25ca1e27a1bf7cb18fe5cd227adc5c2372c Author: Lenin Mehedy Date: Wed Jan 24 18:30:13 2024 +1100 fix test Signed-off-by: Lenin Mehedy commit a91170373d30adce7a322f3394951d8786e4b97b Author: Lenin Mehedy Date: Wed Jan 24 18:25:46 2024 +1100 fix: rename Kubectl2 to K8 Signed-off-by: Lenin Mehedy commit acd277fb6059e640977e7f1f261ae5e3536d3b58 Author: Lenin Mehedy Date: Wed Jan 24 18:17:34 2024 +1100 fix: relay command Signed-off-by: Lenin Mehedy commit 5ba143cfd6b1d478a8377c3275cba5ba1fe293d7 Author: Lenin Mehedy Date: Wed Jan 24 18:16:52 2024 +1100 fix: waitForPod Signed-off-by: Lenin Mehedy commit 119402504c53a26aa56527be58bd2682df1dd67f Author: Lenin Mehedy Date: Wed Jan 24 17:54:46 2024 +1100 fix: remove kubectl usage Signed-off-by: Lenin Mehedy commit 7387dff2af60f007bdbd95e7289604a235bd5c39 Author: Lenin Mehedy Date: Wed Jan 24 17:53:36 2024 +1100 fix: add clone method for Kubectl2 Signed-off-by: Lenin Mehedy commit af5e7a433a1c51a07acee6628e20dc09acb15dcc Author: Lenin Mehedy Date: Wed Jan 24 14:30:37 2024 +1100 fix: do not poll after copyToPod or copyFromPod Signed-off-by: Lenin Mehedy commit 5a9b96c2cea1a285e774879a92ef3808d6121859 Author: Lenin Mehedy Date: Wed Jan 24 13:04:01 2024 +1100 fix: make waitForPod non-blocking Signed-off-by: Lenin Mehedy commit 468b0b04fdc3a65934241cca92f94101ec754c3d Merge: 644c0e0 f3b3028 Author: Lenin Mehedy Date: Wed Jan 24 12:59:53 2024 +1100 Merge branch 'main' into 605-kubernetes-javascript-client Signed-off-by: Lenin Mehedy # Conflicts: # fullstack-network-manager/package-lock.json # fullstack-network-manager/package.json commit 644c0e0b91f5dd23ccbcc74b47039b1b92a3fff3 Author: Lenin Mehedy Date: Tue Jan 23 16:03:28 2024 +1100 add setup script for e2e test Signed-off-by: Lenin Mehedy commit 505ab8d713247839887779198b07f2d9debab775 Author: Lenin Mehedy Date: Tue Jan 23 15:36:18 2024 +1100 fix: check for pod readiness individually to show more info to the user Signed-off-by: Lenin Mehedy commit 2b3f9a39a282df5991fd436f977ce23e3c3c88fc Author: Lenin Mehedy Date: Tue Jan 23 15:02:11 2024 +1100 fix: e2e tests Signed-off-by: Lenin Mehedy commit f3b30283a00832e432c8aab105c7bde3103137c9 Author: Jeromy Cannon Date: Tue Jan 23 02:56:21 2024 +0000 feat: use Acme Lets Encrypt cluster issuer for TLS in Hedera Explorer (#677) Signed-off-by: Jeromy Cannon commit e44e5b20b25134ffee1dcaaaa1ffa4c2faca04b3 Author: Jeromy Cannon Date: Mon Jan 22 13:23:21 2024 +0000 feat: switch from envoy gateway to services/ingress (#672) Signed-off-by: Jeromy Cannon commit 1a5981b292043500766692b982df175d69c9af72 Author: Lenin Mehedy Date: Mon Jan 22 16:54:43 2024 +1100 fix: e2e tests and CI pipelline Signed-off-by: Lenin Mehedy commit 90b0f4dbe90c06db90ec5a9b65a6a9974bf95e35 Author: Lenin Mehedy Date: Mon Jan 22 15:54:08 2024 +1100 fix: check for namespace Signed-off-by: Lenin Mehedy commit 12c94ab1952f2842d1936857684e376001e5da9d Author: Lenin Mehedy Date: Mon Jan 22 15:45:44 2024 +1100 fix node setup Signed-off-by: Lenin Mehedy commit 214daba1b19441ed5a3e6f8b2db60341443a8962 Author: Lenin Mehedy Date: Mon Jan 22 15:12:31 2024 +1100 fix: use default namespace for cluster setup Signed-off-by: Lenin Mehedy commit b663d575c561990efef87a7d29b30e52ad2afd8b Author: Lenin Mehedy Date: Mon Jan 22 14:56:55 2024 +1100 fix: get pod IP and copy files checks Signed-off-by: Lenin Mehedy commit ec8dd5cca8e6139e4fc4e28e01cf226ab32031cf Author: Lenin Mehedy Date: Mon Jan 22 14:56:43 2024 +1100 fix: split platform code copy and extract into separate steps for better tracking Signed-off-by: Lenin Mehedy commit 6a4226c2371b39f87adfa972de4940c81db89c85 Author: Lenin Mehedy Date: Mon Jan 22 11:29:17 2024 +1100 fix: do not require kind and cluster creation functionalities User is expected to bring their own kubernetes cluster Signed-off-by: Lenin Mehedy commit 75f3c6300ec1ad9f4720e4c1f8f34fdad45cf55c Author: Lenin Mehedy Date: Fri Jan 19 14:51:41 2024 +1100 test: fix tests for missing kubect2 Signed-off-by: Lenin Mehedy commit 26dc63c67e8168420ee01d055b94a3ddfb7d1c92 Author: Lenin Mehedy Date: Fri Jan 19 14:49:49 2024 +1100 fix: use Kubect2 for node commands Signed-off-by: Lenin Mehedy commit 1415260789a14c2e73c3089ae71bd254be5820f5 Author: Lenin Mehedy Date: Fri Jan 19 12:37:38 2024 +1100 fix: replace old kubectl with kubectl2 in chart command Signed-off-by: Lenin Mehedy commit f24f9d30b53ae4783409bccf9dd593fcb09359e9 Author: Lenin Mehedy Date: Thu Jan 18 13:51:51 2024 +1100 remove unused import Signed-off-by: Lenin Mehedy commit 82a80f4fc8c79e5026b959698954e73f011357a6 Author: Lenin Mehedy Date: Wed Jan 17 16:20:53 2024 +1100 feat: implement wait for pod and add check for copy methods Signed-off-by: Lenin Mehedy commit 841bc53b3443d0f205463b4ee6dc9257365c219a Author: JeffreyDallas <39912573+JeffreyDallas@users.noreply.github.com> Date: Wed Jan 17 10:18:46 2024 -0600 chore: remove unnecessary gralde.properties (#667) Signed-off-by: Jeffrey Tang commit 02fdaa828e986062496e7b73d8bcb8753e8a4ca5 Author: Lenin Mehedy Date: Wed Jan 17 16:19:05 2024 +1100 fix: remove unnecessary polling from exec call and cache configManager for cli args Signed-off-by: Lenin Mehedy commit d51cdfaf928a9d360d196da771d876f3af846292 Author: Lenin Mehedy Date: Wed Jan 17 15:54:54 2024 +1100 fix: refactor config manager to contain the config Signed-off-by: Lenin Mehedy commit 2eddad28a3e7aab8b398b2899e86ea43988bc833 Author: Lenin Mehedy Date: Tue Jan 16 14:32:46 2024 +1100 feat: implement port forward and polling utility function Signed-off-by: Lenin Mehedy commit fc26a018d9e770253d3f1dc235d81d57532d948f Author: Lenin Mehedy Date: Tue Jan 16 09:30:05 2024 +1100 fix: use exec status to exit from polling and code cleanup Signed-off-by: Lenin Mehedy commit 7e03a6eddc3ef2568646b5d85e57cbfdb798a31e Author: Lenin Mehedy Date: Mon Jan 15 18:44:52 2024 +1100 remove incorrect docs Signed-off-by: Lenin Mehedy commit aad0af9bf4d722273600bac26e9e0edb2b27b56f Author: Lenin Mehedy Date: Mon Jan 15 18:41:27 2024 +1100 add timeout arg Signed-off-by: Lenin Mehedy commit 33913a9f6590237ee01c413613cb5fcee51d0b8d Author: Lenin Mehedy Date: Mon Jan 15 18:36:43 2024 +1100 fix: rewrite async function of a promise with polling Signed-off-by: Lenin Mehedy commit cade2bcf61c490dae8fbacb555a86b2af447aea2 Author: Lenin Mehedy Date: Mon Jan 15 16:10:31 2024 +1100 fix: remove unused args Signed-off-by: Lenin Mehedy commit 66a4817d9d3906af859bdcd532813d4bf6759515 Author: Lenin Mehedy Date: Mon Jan 15 16:09:32 2024 +1100 feat: implement hasDir and hasFile Signed-off-by: Lenin Mehedy commit f90450c5552d89fa9f06800afd42765a4a2ea557 Author: Lenin Mehedy Date: Mon Jan 15 16:00:48 2024 +1100 cleanup Signed-off-by: Lenin Mehedy commit df76d0074882aa64dec2ae132b7bb5ed27890205 Author: Lenin Mehedy Date: Mon Jan 15 15:36:45 2024 +1100 feat: implement copy file to container Signed-off-by: Lenin Mehedy commit bfd72cfdef20091e557576c3e9b98fa234b807ae Author: Lenin Mehedy Date: Mon Jan 15 12:14:22 2024 +1100 feat: implement Kubectl class using kubernetes javascript client Signed-off-by: Lenin Mehedy commit c1a765151ee4fa54fe1c874d8d0170c5c249b39e Author: swirlds-automation Date: Fri Jan 12 16:07:22 2024 +0000 chore(release): 0.17.0 [skip ci] ## [0.17.0](https://github.com/hashgraph/full-stack-testing/compare/v0.16.0...v0.17.0) (2024-01-12) ### Features * version bump ([46d58f2](https://github.com/hashgraph/full-stack-testing/commit/46d58f20050be0f56cc2bbb60d2c11bdd0378e5c)) ### Bug Fixes * allow using an existing cluster and do not require kind ([#643](https://github.com/hashgraph/full-stack-testing/issues/643)) ([6b53618](https://github.com/hashgraph/full-stack-testing/commit/6b5361854d99044538b55d522e7cebbb7a640402)) * make delete cluster ([#656](https://github.com/hashgraph/full-stack-testing/issues/656)) ([ba7426f](https://github.com/hashgraph/full-stack-testing/commit/ba7426fa3d2d772692aad206a3592de3c6d30313)) commit 46d58f20050be0f56cc2bbb60d2c11bdd0378e5c Author: Jeromy Cannon Date: Fri Jan 12 15:37:52 2024 +0000 feat: version bump Signed-off-by: Jeromy Cannon commit 35d0250be0ea1bfddf1afc58916797236ca4e524 Author: Jeromy Cannon Date: Fri Jan 12 14:50:02 2024 +0000 chore: remove axios and follow-redirect, and upgrade @hashgraph/sdk to 2.40.0 (#661) Signed-off-by: Jeromy Cannon Signed-off-by: Jeromy Cannon --- .../src/commands/chart.mjs | 27 +++++++++++++-- .../src/commands/flags.mjs | 12 ++++++- .../src/commands/prompts.mjs | 16 +++++++++ fullstack-network-manager/src/core/k8.mjs | 33 +++++++++++++++++++ .../test/e2e/core/k8_e2e.test.mjs | 5 +++ 5 files changed, 90 insertions(+), 3 deletions(-) diff --git a/fullstack-network-manager/src/commands/chart.mjs b/fullstack-network-manager/src/commands/chart.mjs index 7864eef24..66a3ce110 100644 --- a/fullstack-network-manager/src/commands/chart.mjs +++ b/fullstack-network-manager/src/commands/chart.mjs @@ -176,8 +176,10 @@ export class ChartCommand extends BaseCommand { task: async (ctx, task) => { self.configManager.load(argv) const namespace = self.configManager.getFlag(flags.namespace) + const deletePvcs = self.configManager.getFlag(flags.deletePvcs) ctx.config = { - namespace: await prompts.promptNamespaceArg(task, namespace) + namespace: await prompts.promptNamespaceArg(task, namespace), + deletePvcs: await prompts.promptDeletePvcs(task, deletePvcs) } } }, @@ -186,6 +188,24 @@ export class ChartCommand extends BaseCommand { task: async (ctx, _) => { await self.chartManager.uninstall(ctx.config.namespace, constants.CHART_FST_DEPLOYMENT_NAME) } + }, + { + title: 'Get PVCs for namespace', + task: async (ctx, _) => { + if(ctx.config.deletePvcs === true) { + ctx.config.pvcs = await self.k8.listPvcsByNamespace(ctx.config.namespace) + } + } + }, + { + title: 'Delete PVCs for namespace', + task: async (ctx, _) => { + if (ctx.config.pvcs) { + for (const pvc of ctx.config.pvcs) { + await self.k8.deletePvc(pvc, ctx.config.namespace) + } + } + } } ], { concurrent: false, @@ -286,7 +306,10 @@ export class ChartCommand extends BaseCommand { .command({ command: 'uninstall', desc: 'Uninstall network deployment chart', - builder: y => flags.setCommandFlags(y, flags.namespace), + builder: y => flags.setCommandFlags(y, + flags.namespace, + flags.deletePvcs + ), handler: argv => { chartCmd.logger.debug("==== Running 'chart uninstall' ===") chartCmd.logger.debug(argv) diff --git a/fullstack-network-manager/src/commands/flags.mjs b/fullstack-network-manager/src/commands/flags.mjs index 93974ad91..b5c5209db 100644 --- a/fullstack-network-manager/src/commands/flags.mjs +++ b/fullstack-network-manager/src/commands/flags.mjs @@ -299,6 +299,15 @@ export const enableHederaExplorerTls = { } } +export const deletePvcs = { + name: 'delete-pvcs', + definition: { + describe: 'Delete the persistent volume claims, defaults to false', + default: false, + type: 'boolean' + } +} + export const allFlags = [ devMode, clusterName, @@ -328,5 +337,6 @@ export const allFlags = [ tlsClusterIssuerName, tlsClusterIssuerNamespace, enableHederaExplorerTls, - selfSignedClusterIssuer + selfSignedClusterIssuer, + deletePvcs ] diff --git a/fullstack-network-manager/src/commands/prompts.mjs b/fullstack-network-manager/src/commands/prompts.mjs index ddf81f3bc..ad60e2032 100644 --- a/fullstack-network-manager/src/commands/prompts.mjs +++ b/fullstack-network-manager/src/commands/prompts.mjs @@ -494,3 +494,19 @@ export async function promptReplicaCount (task, input) { throw new FullstackTestingError(`input failed: ${flags.replicaCount.name}`, e) } } + +export async function promptDeletePvcs (task, input) { + try { + if (input === undefined) { + input = await task.prompt(ListrEnquirerPromptAdapter).run({ + type: 'toggle', + default: flags.deletePvcs.definition.default, + message: 'Would you like to delete persistent volume claims upon uninstall?' + }) + } + + return input + } catch (e) { + throw new FullstackTestingError(`input failed: ${flags.deletePvcs.name}`, e) + } +} diff --git a/fullstack-network-manager/src/core/k8.mjs b/fullstack-network-manager/src/core/k8.mjs index 6b352e97e..0df440216 100644 --- a/fullstack-network-manager/src/core/k8.mjs +++ b/fullstack-network-manager/src/core/k8.mjs @@ -637,6 +637,39 @@ export class K8 { }) } + /** + * Get a list of persistent volume claim names for the given namespace + * @param namespace the namespace of the persistent volume claims to return + * @returns {Promise<*[]>} list of persistent volume claims + */ + async listPvcsByNamespace (namespace) { + const pvcs = [] + const resp = await this.kubeClient.listNamespacedPersistentVolumeClaim ( + namespace + ) + + for (const item of resp.body.items) { + pvcs.push(item.metadata.name) + } + + return pvcs + } + + /** + * Delete a persistent volume claim + * @param name the name of the persistent volume claim to delete + * @param namespace the namespace of the persistent volume claim to delete + * @returns {Promise} true if the persistent volume claim was deleted + */ + async deletePvc (name, namespace) { + const resp = await this.kubeClient.deleteNamespacedPersistentVolumeClaim ( + name, + namespace + ) + + return resp.response.statusCode === 200.0 + } + _getNamespace () { const ns = this.configManager.getFlag(flags.namespace) if (!ns) throw new MissingArgumentError('namespace is not set') diff --git a/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs b/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs index c4e63667a..f66211687 100644 --- a/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs +++ b/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs @@ -131,4 +131,9 @@ describe('K8', () => { fs.rmdirSync(tmpDir, { recursive: true }) }) + + it('should be able to get two persistent volume claims', async () => { + const pvcs = await k8.listPvcsByNamespace(k8._getNamespace()) + expect(pvcs).toHaveLength(2) + }) })