From 2fddfc7fa5d5ffa69d8040450b2fce64de02d4b5 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 10:40:25 +0000 Subject: [PATCH 01/23] IN-421: implementing metrics in servicewatcher. --- app/utils/ServiceWatcher.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index a2f100a..4e48364 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -1,3 +1,5 @@ +import * as client from 'prom-client' + import { TimeoutError } from './Errors.js' import env from '../env.js' @@ -11,6 +13,13 @@ class ServiceWatcher { this.#pollPeriod = env.HEALTHCHECK_POLL_PERIOD_MS this.#timeout = env.HEALTHCHECK_TIMEOUT_MS this.services = this.#init(apis) + this.metrics = { + peerCount: new client.Gauge({ + name: 'dscp_ipfs_swarm_peer_count', + help: 'help needed here', + labelNames: [ 'type' ] + }) + } } delay(ms, service = false) { @@ -54,6 +63,9 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) + const { __tmpConnectedPeers, __tmpDiscoveredPeers } = await new Promise((r) => r({ __tmpDiscoveredPeers: 1, __tmpConnectedPeers: 2})) + this.peerCount.set({ type: 'discovered' }, __tmpDiscoveredPeers) + this.peerCount.set({ type: 'connected' }, __tmpConnectedPeers) } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' From ac29362a11467ffe4d7c815ad58dee8785d63f60 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 10:43:01 +0000 Subject: [PATCH 02/23] IN-421: incorrect key used. --- app/utils/ServiceWatcher.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 4e48364..4e9fb1e 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -63,9 +63,9 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - const { __tmpConnectedPeers, __tmpDiscoveredPeers } = await new Promise((r) => r({ __tmpDiscoveredPeers: 1, __tmpConnectedPeers: 2})) - this.peerCount.set({ type: 'discovered' }, __tmpDiscoveredPeers) - this.peerCount.set({ type: 'connected' }, __tmpConnectedPeers) + const { __tmpConnectedPeers, __tmpDiscoveredPeers } = await new Promise((r) => r({ __tmpDiscoveredPeers: 1, __tmpConnectedPeers: 2 })) + this.metrics.peerCount.set({ type: 'discovered' }, __tmpDiscoveredPeers) + this.metrics.peerCount.set({ type: 'connected' }, __tmpConnectedPeers) } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' From 67a9cf9d753b008692672402c67d214e85312c34 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 11:21:55 +0000 Subject: [PATCH 03/23] IN-421: making some api calls to the ipfs. --- app/utils/ServiceWatcher.js | 22 +++++++-- package-lock.json | 93 ++++++++++++++++++++++++++++++++++--- package.json | 2 +- 3 files changed, 106 insertions(+), 11 deletions(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 4e9fb1e..d4512d2 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -1,7 +1,9 @@ import * as client from 'prom-client' +import fetch from 'node-fetch' import { TimeoutError } from './Errors.js' import env from '../env.js' +import axios from 'axios' class ServiceWatcher { #pollPeriod @@ -53,6 +55,21 @@ class ServiceWatcher { .filter(Boolean) } + async #updateMetrics() { + const connectedPeers = await axios({ + url: 'http://localhost:5001/api/v0/swarm/peers', + method: 'POST', + }).then(({ data }) => data) + const discoveredPeers = await axios({ + url: 'http://localhost:5001/api/v0/swarm/addrs', + method: 'POST', + }).then(({ data }) => data) + + // update instance's metrics object + this.metrics.peerCount.set({ type: 'discovered' }, Object.keys(discoveredPeers.Addrs).length) // /api/v0/swarm/connect + this.metrics.peerCount.set({ type: 'connected' }, connectedPeers.Peers?.length || 0) // /api/v0/swarm/peers + } + // starts the generator resolving after the first update // use ServiceWatcher.gen.return() to stop async start() { @@ -63,9 +80,8 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - const { __tmpConnectedPeers, __tmpDiscoveredPeers } = await new Promise((r) => r({ __tmpDiscoveredPeers: 1, __tmpConnectedPeers: 2 })) - this.metrics.peerCount.set({ type: 'discovered' }, __tmpDiscoveredPeers) - this.metrics.peerCount.set({ type: 'connected' }, __tmpConnectedPeers) + await this.#updateMetrics() + } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' diff --git a/package-lock.json b/package-lock.json index 4fe273f..bf20d0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@digicatapult/dscp-node": "^4.4.6", + "axios": "^1.2.0", "dotenv": "^16.0.3", "envalid": "^7.3.1", "express": "^4.18.2", @@ -29,7 +30,6 @@ "formdata-node": "^5.0.0", "go-ipfs": "^0.16.0", "mocha": "^10.1.0", - "node-fetch": "^3.2.10", "nodemon": "^2.0.20", "nyc": "^15.1.0", "pino-colada": "^2.2.2", @@ -1627,6 +1627,29 @@ "node": ">=8.0.0" } }, + "node_modules/axios": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.0.tgz", + "integrity": "sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -3336,6 +3359,25 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", @@ -4842,9 +4884,9 @@ } }, "node_modules/node-fetch": { - "version": "3.2.10", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", - "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.0.tgz", + "integrity": "sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==", "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", @@ -5942,6 +5984,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", @@ -8489,6 +8536,28 @@ "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==" }, + "axios": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.0.tgz", + "integrity": "sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -9776,6 +9845,11 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, + "follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + }, "foreground-child": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", @@ -10893,9 +10967,9 @@ "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" }, "node-fetch": { - "version": "3.2.10", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.2.10.tgz", - "integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.0.tgz", + "integrity": "sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==", "requires": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", @@ -11709,6 +11783,11 @@ "ipaddr.js": "1.9.1" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", diff --git a/package.json b/package.json index f249cfd..b453ea4 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "homepage": "https://github.com/digicatapult/dscp-ipfs#readme", "dependencies": { "@digicatapult/dscp-node": "^4.4.6", + "axios": "^1.2.0", "dotenv": "^16.0.3", "envalid": "^7.3.1", "express": "^4.18.2", @@ -52,7 +53,6 @@ "formdata-node": "^5.0.0", "go-ipfs": "^0.16.0", "mocha": "^10.1.0", - "node-fetch": "^3.2.10", "nodemon": "^2.0.20", "nyc": "^15.1.0", "pino-colada": "^2.2.2", From 07d53fd27ee4a1a76426b5801e8badd3fc6e6e92 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 11:24:12 +0000 Subject: [PATCH 04/23] IN-421: version bump. --- app/utils/ServiceWatcher.js | 10 ++++------ helm/dscp-ipfs/Chart.yaml | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index d4512d2..8788682 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -1,9 +1,8 @@ import * as client from 'prom-client' -import fetch from 'node-fetch' +import axios from 'axios' import { TimeoutError } from './Errors.js' import env from '../env.js' -import axios from 'axios' class ServiceWatcher { #pollPeriod @@ -19,8 +18,8 @@ class ServiceWatcher { peerCount: new client.Gauge({ name: 'dscp_ipfs_swarm_peer_count', help: 'help needed here', - labelNames: [ 'type' ] - }) + labelNames: ['type'], + }), } } @@ -66,7 +65,7 @@ class ServiceWatcher { }).then(({ data }) => data) // update instance's metrics object - this.metrics.peerCount.set({ type: 'discovered' }, Object.keys(discoveredPeers.Addrs).length) // /api/v0/swarm/connect + this.metrics.peerCount.set({ type: 'discovered' }, Object.keys(discoveredPeers.Addrs).length) // /api/v0/swarm/connect this.metrics.peerCount.set({ type: 'connected' }, connectedPeers.Peers?.length || 0) // /api/v0/swarm/peers } @@ -81,7 +80,6 @@ class ServiceWatcher { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) await this.#updateMetrics() - } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' diff --git a/helm/dscp-ipfs/Chart.yaml b/helm/dscp-ipfs/Chart.yaml index 6d4a0f9..8273f19 100644 --- a/helm/dscp-ipfs/Chart.yaml +++ b/helm/dscp-ipfs/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: dscp-ipfs -appVersion: '2.8.1' +appVersion: '2.9.0' description: A Helm chart for dscp-ipfs -version: '2.8.1' +version: '2.9.0' type: application dependencies: - name: dscp-node diff --git a/package-lock.json b/package-lock.json index bf20d0a..c51c005 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@digicatapult/dscp-ipfs", - "version": "2.8.1", + "version": "2.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@digicatapult/dscp-ipfs", - "version": "2.8.1", + "version": "2.9.0", "license": "Apache-2.0", "dependencies": { "@digicatapult/dscp-node": "^4.4.6", diff --git a/package.json b/package.json index b453ea4..32a898d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digicatapult/dscp-ipfs", - "version": "2.8.1", + "version": "2.9.0", "description": "Service for DSCP", "main": "app/index.js", "type": "module", From 87cfb2ab0ceaa7576dc6a342d241024f9628206b Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 11:27:48 +0000 Subject: [PATCH 05/23] IN-421: version update in values.yaml as well. --- helm/dscp-ipfs/values.yaml | 2 +- package-lock.json | 1 + package.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/helm/dscp-ipfs/values.yaml b/helm/dscp-ipfs/values.yaml index fc2b612..318cd85 100644 --- a/helm/dscp-ipfs/values.yaml +++ b/helm/dscp-ipfs/values.yaml @@ -52,7 +52,7 @@ statefulSet: image: repository: digicatapult/dscp-ipfs pullPolicy: IfNotPresent - tag: 'v2.8.1' + tag: 'v2.9.0' storage: storageClass: "" diff --git a/package-lock.json b/package-lock.json index c51c005..9bdb202 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "formdata-node": "^5.0.0", "go-ipfs": "^0.16.0", "mocha": "^10.1.0", + "node-fetch": "^3.3.0", "nodemon": "^2.0.20", "nyc": "^15.1.0", "pino-colada": "^2.2.2", diff --git a/package.json b/package.json index 32a898d..2398efe 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "formdata-node": "^5.0.0", "go-ipfs": "^0.16.0", "mocha": "^10.1.0", + "node-fetch": "^3.3.0", "nodemon": "^2.0.20", "nyc": "^15.1.0", "pino-colada": "^2.2.2", From f0e37a16a938b8df0dffff31564024c41d161f5e Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 14:03:12 +0000 Subject: [PATCH 06/23] IN-421: linting. --- app/utils/ServiceWatcher.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 8788682..c19a7f7 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -17,7 +17,6 @@ class ServiceWatcher { this.metrics = { peerCount: new client.Gauge({ name: 'dscp_ipfs_swarm_peer_count', - help: 'help needed here', labelNames: ['type'], }), } From 1dc079cdaa59bd0dd5d0889386221f6cafb55209 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 14:08:23 +0000 Subject: [PATCH 07/23] IN-421: simplified. --- app/env.js | 1 + app/utils/ServiceWatcher.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/env.js b/app/env.js index df52c45..e17a0ae 100644 --- a/app/env.js +++ b/app/env.js @@ -30,6 +30,7 @@ const vars = envalid.cleanEnv( LOG_LEVEL: envalid.str({ default: 'info', devDefault: 'debug' }), PORT: envalid.port({ default: 80, devDefault: 3000 }), NODE_HOST: envalid.host({ devDefault: 'localhost' }), + IPFS_API: envalid.host({ devDefault: 'localhost:5001/api/v0/' }), NODE_PORT: envalid.port({ default: 9944 }), IPFS_PATH: envalid.str({ default: '/ipfs', devDefault: path.resolve(__dirname, '..', `data`) }), IPFS_EXECUTABLE: envalid.str({ diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index c19a7f7..3747a31 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -12,6 +12,7 @@ class ServiceWatcher { constructor(apis) { this.report = {} this.#pollPeriod = env.HEALTHCHECK_POLL_PERIOD_MS + this.ipfsApiUrl = env.IPFS_API this.#timeout = env.HEALTHCHECK_TIMEOUT_MS this.services = this.#init(apis) this.metrics = { @@ -54,18 +55,18 @@ class ServiceWatcher { } async #updateMetrics() { - const connectedPeers = await axios({ - url: 'http://localhost:5001/api/v0/swarm/peers', + const { data: connectedPeers } = await axios({ + url: `${this.ipfsApiUrl}swarm/peers`, method: 'POST', - }).then(({ data }) => data) - const discoveredPeers = await axios({ - url: 'http://localhost:5001/api/v0/swarm/addrs', + }) + const { data: discoveredPeers } = await axios({ + url: `${this.ipfsApiUrl}swarm/addrs`, method: 'POST', - }).then(({ data }) => data) + }) // update instance's metrics object - this.metrics.peerCount.set({ type: 'discovered' }, Object.keys(discoveredPeers.Addrs).length) // /api/v0/swarm/connect - this.metrics.peerCount.set({ type: 'connected' }, connectedPeers.Peers?.length || 0) // /api/v0/swarm/peers + this.metrics.peerCount.set({ type: 'discovered' }, Object.keys(discoveredPeers.Addrs).length) + this.metrics.peerCount.set({ type: 'connected' }, connectedPeers.Peers?.length || 0) } // starts the generator resolving after the first update From 0779a8a1e8be94d9dd9e416dd50fe0c68008a01d Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 14:11:24 +0000 Subject: [PATCH 08/23] IN-421: before mocking api endpoint. --- app/utils/ServiceWatcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 3747a31..be407d0 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -79,7 +79,7 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - await this.#updateMetrics() + await this.#updateMetrics().catch((err) => console.log(err)) } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' From df4b088cc5b2fe427f8f6707631db66b2b65abf2 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 14:12:40 +0000 Subject: [PATCH 09/23] IN-421: re-run --- app/utils/ServiceWatcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index be407d0..3ef5e93 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -79,7 +79,7 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - await this.#updateMetrics().catch((err) => console.log(err)) + await this.#updateMetrics().catch((err) => err) } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' From b4f36ad13ccb83d0b7cde1aab26fdebd1c3ffb8a Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 15:52:31 +0000 Subject: [PATCH 10/23] IN-421: set error rather than ignore. --- app/utils/ServiceWatcher.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 3ef5e93..b091664 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -79,7 +79,9 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - await this.#updateMetrics().catch((err) => err) + await this.#updateMetrics().catch((err) => { + this.metrics = err + }) } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' From 6c6b2cfcc4722f0eb95c4a4ae97537ec9b175489 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 15:55:37 +0000 Subject: [PATCH 11/23] IN-421: Error: Missing mandatory help parameter --- app/utils/ServiceWatcher.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index b091664..7264788 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -18,6 +18,7 @@ class ServiceWatcher { this.metrics = { peerCount: new client.Gauge({ name: 'dscp_ipfs_swarm_peer_count', + help: 'a number of discovered and connected peers', labelNames: ['type'], }), } From d9397a260f31528d97052b54362a6cb7acc65857 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 16:01:09 +0000 Subject: [PATCH 12/23] IN-421: should not need to update tests. --- app/utils/ServiceWatcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 7264788..8e448b7 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -16,7 +16,7 @@ class ServiceWatcher { this.#timeout = env.HEALTHCHECK_TIMEOUT_MS this.services = this.#init(apis) this.metrics = { - peerCount: new client.Gauge({ + peerCount: this.metrics.peerCount || new client.Gauge({ name: 'dscp_ipfs_swarm_peer_count', help: 'a number of discovered and connected peers', labelNames: ['type'], From 6118f9e1d392fc5256d7829b982b28f6526344e8 Mon Sep 17 00:00:00 2001 From: Paulius Date: Fri, 25 Nov 2022 16:03:00 +0000 Subject: [PATCH 13/23] IN-421: linting --- app/utils/ServiceWatcher.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 8e448b7..8525a97 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -16,11 +16,13 @@ class ServiceWatcher { this.#timeout = env.HEALTHCHECK_TIMEOUT_MS this.services = this.#init(apis) this.metrics = { - peerCount: this.metrics.peerCount || new client.Gauge({ - name: 'dscp_ipfs_swarm_peer_count', - help: 'a number of discovered and connected peers', - labelNames: ['type'], - }), + peerCount: + this.metrics.peerCount || + new client.Gauge({ + name: 'dscp_ipfs_swarm_peer_count', + help: 'a number of discovered and connected peers', + labelNames: ['type'], + }), } } From 3380ebe4a2481feea8e1b23c5ad0fba6bc2b7291 Mon Sep 17 00:00:00 2001 From: Paulius Date: Mon, 28 Nov 2022 14:13:25 +0000 Subject: [PATCH 14/23] fixing failing tests.' --- app/env.js | 3 ++- app/utils/ServiceWatcher.js | 22 +++++++++++----------- package.json | 2 +- test/test.env | 2 ++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/env.js b/app/env.js index e17a0ae..947f6b8 100644 --- a/app/env.js +++ b/app/env.js @@ -30,7 +30,8 @@ const vars = envalid.cleanEnv( LOG_LEVEL: envalid.str({ default: 'info', devDefault: 'debug' }), PORT: envalid.port({ default: 80, devDefault: 3000 }), NODE_HOST: envalid.host({ devDefault: 'localhost' }), - IPFS_API: envalid.host({ devDefault: 'localhost:5001/api/v0/' }), + IPFS_API_HOST: envalid.host({ devDefault: 'localhost' }), + IPFS_API_PORT: envalid.host({ devDefault: '5001' }), NODE_PORT: envalid.port({ default: 9944 }), IPFS_PATH: envalid.str({ default: '/ipfs', devDefault: path.resolve(__dirname, '..', `data`) }), IPFS_EXECUTABLE: envalid.str({ diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 8525a97..88d2c00 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -12,17 +12,19 @@ class ServiceWatcher { constructor(apis) { this.report = {} this.#pollPeriod = env.HEALTHCHECK_POLL_PERIOD_MS - this.ipfsApiUrl = env.IPFS_API + this.ipfsApiUrl = `http://${env.IPFS_API_HOST}:${env.IPFS_API_PORT}/api/v0/` this.#timeout = env.HEALTHCHECK_TIMEOUT_MS this.services = this.#init(apis) this.metrics = { - peerCount: - this.metrics.peerCount || - new client.Gauge({ - name: 'dscp_ipfs_swarm_peer_count', - help: 'a number of discovered and connected peers', - labelNames: ['type'], - }), + peerCount: () => { + if (!this.metrics.peerCount) { + return new client.Gauge({ + name: 'dscp_ipfs_swarm_peer_count', + help: 'a number of discovered and connected peers', + labelNames: ['type'], + }) + } + }, } } @@ -82,9 +84,7 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - await this.#updateMetrics().catch((err) => { - this.metrics = err - }) + await this.#updateMetrics() } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' diff --git a/package.json b/package.json index 2398efe..16b1d0c 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test": "NODE_ENV=test mocha --config ./test/mocharc.cjs ./test", "test:integration": "NODE_ENV=test mocha --config ./test/mocharc.cjs ./test/integration", "test:unit": "NODE_ENV=test mocha --config ./test/mocharc-unit.cjs ./test/unit", - "lint": "eslint .", + "lint": "eslint . --fix", "depcheck": "depcheck", "start": "node app/index.js", "dev": "NODE_ENV=dev nodemon app/index.js | pino-colada", diff --git a/test/test.env b/test/test.env index b0cda9b..c6a5331 100644 --- a/test/test.env +++ b/test/test.env @@ -3,3 +3,5 @@ IPFS_LOG_LEVEL=fatal NODE_HOST=localhost HEALTHCHECK_POLL_PERIOD_MS=1000 HEALTHCHECK_TIMEOUT_MS=1000 +IPFS_API_HOST=localhost +IPFS_API_PORT=5001 From 93e91fa9cbb906b82a4c0431f8bacfbf15053283 Mon Sep 17 00:00:00 2001 From: Paulius Date: Mon, 28 Nov 2022 14:22:50 +0000 Subject: [PATCH 15/23] IN-421: sage of fixing failing tests with least effort --- app/env.js | 4 ++-- app/utils/ServiceWatcher.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/env.js b/app/env.js index 947f6b8..0e1bf84 100644 --- a/app/env.js +++ b/app/env.js @@ -30,8 +30,8 @@ const vars = envalid.cleanEnv( LOG_LEVEL: envalid.str({ default: 'info', devDefault: 'debug' }), PORT: envalid.port({ default: 80, devDefault: 3000 }), NODE_HOST: envalid.host({ devDefault: 'localhost' }), - IPFS_API_HOST: envalid.host({ devDefault: 'localhost' }), - IPFS_API_PORT: envalid.host({ devDefault: '5001' }), + IPFS_API_HOST: envalid.host({ default: 'localhost' }), + IPFS_API_PORT: envalid.host({ default: '5001' }), NODE_PORT: envalid.port({ default: 9944 }), IPFS_PATH: envalid.str({ default: '/ipfs', devDefault: path.resolve(__dirname, '..', `data`) }), IPFS_EXECUTABLE: envalid.str({ diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 88d2c00..558902e 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -84,7 +84,7 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - await this.#updateMetrics() + await this.#updateMetrics().catch((err) => this.metrics.error = err) } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' From 2042416db8a4d143ca2221f6e7692aac6fe0605b Mon Sep 17 00:00:00 2001 From: Paulius Date: Mon, 28 Nov 2022 15:31:37 +0000 Subject: [PATCH 16/23] IN-421: set devDefault instead of default. --- app/env.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/env.js b/app/env.js index 0e1bf84..947f6b8 100644 --- a/app/env.js +++ b/app/env.js @@ -30,8 +30,8 @@ const vars = envalid.cleanEnv( LOG_LEVEL: envalid.str({ default: 'info', devDefault: 'debug' }), PORT: envalid.port({ default: 80, devDefault: 3000 }), NODE_HOST: envalid.host({ devDefault: 'localhost' }), - IPFS_API_HOST: envalid.host({ default: 'localhost' }), - IPFS_API_PORT: envalid.host({ default: '5001' }), + IPFS_API_HOST: envalid.host({ devDefault: 'localhost' }), + IPFS_API_PORT: envalid.host({ devDefault: '5001' }), NODE_PORT: envalid.port({ default: 9944 }), IPFS_PATH: envalid.str({ default: '/ipfs', devDefault: path.resolve(__dirname, '..', `data`) }), IPFS_EXECUTABLE: envalid.str({ From 292ab117b8e273c4f01160edf58b932236afdfd5 Mon Sep 17 00:00:00 2001 From: Paulius Date: Tue, 29 Nov 2022 09:20:27 +0000 Subject: [PATCH 17/23] IN-421: some updates, env vars. --- app/env.js | 2 +- app/utils/ServiceWatcher.js | 2 +- test/integration/fixtures.js | 8 ++++---- test/integration/ipfs.test.js | 9 +++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/env.js b/app/env.js index 947f6b8..46a45e4 100644 --- a/app/env.js +++ b/app/env.js @@ -31,7 +31,7 @@ const vars = envalid.cleanEnv( PORT: envalid.port({ default: 80, devDefault: 3000 }), NODE_HOST: envalid.host({ devDefault: 'localhost' }), IPFS_API_HOST: envalid.host({ devDefault: 'localhost' }), - IPFS_API_PORT: envalid.host({ devDefault: '5001' }), + IPFS_API_PORT: envalid.port({ default: 5001 }), NODE_PORT: envalid.port({ default: 9944 }), IPFS_PATH: envalid.str({ default: '/ipfs', devDefault: path.resolve(__dirname, '..', `data`) }), IPFS_EXECUTABLE: envalid.str({ diff --git a/app/utils/ServiceWatcher.js b/app/utils/ServiceWatcher.js index 558902e..c8bcdf9 100644 --- a/app/utils/ServiceWatcher.js +++ b/app/utils/ServiceWatcher.js @@ -84,7 +84,7 @@ class ServiceWatcher { try { const services = await getAll services.forEach(({ name, ...rest }) => this.update(name, rest)) - await this.#updateMetrics().catch((err) => this.metrics.error = err) + await this.#updateMetrics().catch((err) => (this.metrics.error = err)) } catch (error) { // if no service assume that this is server error e.g. TypeError, Parse... const name = error.service || 'server' diff --git a/test/integration/fixtures.js b/test/integration/fixtures.js index 1fa4626..ca2d82d 100644 --- a/test/integration/fixtures.js +++ b/test/integration/fixtures.js @@ -3,7 +3,7 @@ import fs from 'fs/promises' import { spawnSync } from 'child_process' import { fileURLToPath } from 'url' -import env from '../../app/env.js' +import { IPFS_EXECUTABLE, IPFS_API_PORT, IPFS_PATH } from '../../app/env.js' import { startServer, stopServer } from './helper/server.js' import { waitForIpfsApi } from './helper/ipfs.js' @@ -11,13 +11,13 @@ const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) export const mochaGlobalSetup = async function () { - spawnSync(env.IPFS_EXECUTABLE, ['init']) - await fs.copyFile(path.join(__dirname, '..', 'config', 'node-1.json'), path.join(env.IPFS_PATH, 'config')) + spawnSync(IPFS_EXECUTABLE, ['init']) + await fs.copyFile(path.join(__dirname, '..', 'config', 'node-1.json'), path.join(IPFS_PATH, 'config')) this.stopServer = stopServer await startServer(this) - await waitForIpfsApi(`5001`) + await waitForIpfsApi(IPFS_API_PORT) } export const mochaGlobalTeardown = async function () { diff --git a/test/integration/ipfs.test.js b/test/integration/ipfs.test.js index db83544..ddb22a8 100644 --- a/test/integration/ipfs.test.js +++ b/test/integration/ipfs.test.js @@ -4,13 +4,14 @@ import { FormData, Blob } from 'formdata-node' import { expect } from 'chai' import delay from 'delay' +import { IPFS_API_PORT } from '../../app/env' import { getSwarmKey, setSwarmKey } from './helper/api.js' import { setupIPFS, waitForIpfsApi } from './helper/ipfs.js' const uploadA = async (fileName, contents) => { const form = new FormData() form.append('file', new Blob([contents]), fileName) - const body = await fetch(`http://localhost:5001/api/v0/add?cid-version=0`, { + const body = await fetch(`http://localhost:${IPFS_API_PORT}/api/v0/add?cid-version=0`, { method: 'POST', body: form, }) @@ -32,8 +33,8 @@ const download = (port) => async (hash) => { return contentText } -const downloadA = download(`5001`) -const downloadB = download(`5002`) +const downloadA = download(IPFS_API_PORT) +const downloadB = download(`5002`) //TODO mm? 50/50 to be fair since it's test i think we should ignore const setupIpfsWithSwarm = async (context) => { before(async function () { @@ -113,7 +114,7 @@ describe('ipfs', function () { context.hash = await uploadA('test-file-4.txt', 'Test 4') await setSwarmKey(context.swarmKey) await delay(500) - await waitForIpfsApi(`5001`) + await waitForIpfsApi(IPFS_API_PORT) }) it('should be retrievable', async function () { From ffe864d6b56eb3b4ce46e275c22da160bff6ec2c Mon Sep 17 00:00:00 2001 From: Paulius Date: Tue, 29 Nov 2022 09:56:50 +0000 Subject: [PATCH 18/23] IN-421: add mapping for helm. --- helm/dscp-ipfs/templates/statefulset.yaml | 5 +++++ test/integration/fixtures.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/helm/dscp-ipfs/templates/statefulset.yaml b/helm/dscp-ipfs/templates/statefulset.yaml index e78b563..c6437c3 100644 --- a/helm/dscp-ipfs/templates/statefulset.yaml +++ b/helm/dscp-ipfs/templates/statefulset.yaml @@ -98,6 +98,11 @@ spec: configMapKeyRef: name: {{ include "dscp-ipfs.fullname" . }}-config key: healthCheckPort + - name: IPFS_API_PORT + valueFrom: + configMapKeyRef: + name: {{ include "dscp-ipfs.fullname" . }}-config + key: ipfsApiPort - name: LOG_LEVEL valueFrom: configMapKeyRef: diff --git a/test/integration/fixtures.js b/test/integration/fixtures.js index ca2d82d..a40f67a 100644 --- a/test/integration/fixtures.js +++ b/test/integration/fixtures.js @@ -3,7 +3,7 @@ import fs from 'fs/promises' import { spawnSync } from 'child_process' import { fileURLToPath } from 'url' -import { IPFS_EXECUTABLE, IPFS_API_PORT, IPFS_PATH } from '../../app/env.js' +import { IPFS_EXECUTABLE, IPFS_API_PORT, IPFS_PATH } from '../../app/env' import { startServer, stopServer } from './helper/server.js' import { waitForIpfsApi } from './helper/ipfs.js' From 69b54c5cf28dead0564f8f40810731f7f8df8c8e Mon Sep 17 00:00:00 2001 From: Paulius Date: Tue, 29 Nov 2022 10:00:08 +0000 Subject: [PATCH 19/23] IN-421: missing extension on import. --- test/integration/fixtures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/fixtures.js b/test/integration/fixtures.js index a40f67a..ca2d82d 100644 --- a/test/integration/fixtures.js +++ b/test/integration/fixtures.js @@ -3,7 +3,7 @@ import fs from 'fs/promises' import { spawnSync } from 'child_process' import { fileURLToPath } from 'url' -import { IPFS_EXECUTABLE, IPFS_API_PORT, IPFS_PATH } from '../../app/env' +import { IPFS_EXECUTABLE, IPFS_API_PORT, IPFS_PATH } from '../../app/env.js' import { startServer, stopServer } from './helper/server.js' import { waitForIpfsApi } from './helper/ipfs.js' From 3986a1d901f3764501d314434fe219506ac8cebb Mon Sep 17 00:00:00 2001 From: Paulius Date: Tue, 29 Nov 2022 10:17:19 +0000 Subject: [PATCH 20/23] IN-421: is it a default export? --- test/integration/fixtures.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/fixtures.js b/test/integration/fixtures.js index ca2d82d..960a040 100644 --- a/test/integration/fixtures.js +++ b/test/integration/fixtures.js @@ -3,7 +3,7 @@ import fs from 'fs/promises' import { spawnSync } from 'child_process' import { fileURLToPath } from 'url' -import { IPFS_EXECUTABLE, IPFS_API_PORT, IPFS_PATH } from '../../app/env.js' +import env from '../../app/env.js' import { startServer, stopServer } from './helper/server.js' import { waitForIpfsApi } from './helper/ipfs.js' @@ -11,13 +11,13 @@ const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) export const mochaGlobalSetup = async function () { - spawnSync(IPFS_EXECUTABLE, ['init']) - await fs.copyFile(path.join(__dirname, '..', 'config', 'node-1.json'), path.join(IPFS_PATH, 'config')) + spawnSync(env.IPFS_EXECUTABLE, ['init']) + await fs.copyFile(path.join(__dirname, '..', 'config', 'node-1.json'), path.join(env.IPFS_PATH, 'config')) this.stopServer = stopServer await startServer(this) - await waitForIpfsApi(IPFS_API_PORT) + await waitForIpfsApi(env.IPFS_API_PORT) } export const mochaGlobalTeardown = async function () { From e54111184a6a25a273c7f48aa5fb7f964cbfe172 Mon Sep 17 00:00:00 2001 From: Paulius Date: Tue, 29 Nov 2022 10:21:12 +0000 Subject: [PATCH 21/23] IN-421: and another one... --- test/integration/ipfs.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/ipfs.test.js b/test/integration/ipfs.test.js index ddb22a8..bacf715 100644 --- a/test/integration/ipfs.test.js +++ b/test/integration/ipfs.test.js @@ -4,14 +4,14 @@ import { FormData, Blob } from 'formdata-node' import { expect } from 'chai' import delay from 'delay' -import { IPFS_API_PORT } from '../../app/env' +import env from '../../app/env.js' import { getSwarmKey, setSwarmKey } from './helper/api.js' import { setupIPFS, waitForIpfsApi } from './helper/ipfs.js' const uploadA = async (fileName, contents) => { const form = new FormData() form.append('file', new Blob([contents]), fileName) - const body = await fetch(`http://localhost:${IPFS_API_PORT}/api/v0/add?cid-version=0`, { + const body = await fetch(`http://localhost:${env.IPFS_API_PORT}/api/v0/add?cid-version=0`, { method: 'POST', body: form, }) @@ -33,7 +33,7 @@ const download = (port) => async (hash) => { return contentText } -const downloadA = download(IPFS_API_PORT) +const downloadA = download(env.IPFS_API_PORT) const downloadB = download(`5002`) //TODO mm? 50/50 to be fair since it's test i think we should ignore const setupIpfsWithSwarm = async (context) => { @@ -114,7 +114,7 @@ describe('ipfs', function () { context.hash = await uploadA('test-file-4.txt', 'Test 4') await setSwarmKey(context.swarmKey) await delay(500) - await waitForIpfsApi(IPFS_API_PORT) + await waitForIpfsApi(env.IPFS_API_PORT) }) it('should be retrievable', async function () { From 5884a7fa6ea34f5c675a29076a821d69b04b4189 Mon Sep 17 00:00:00 2001 From: Paulius Date: Tue, 29 Nov 2022 10:30:04 +0000 Subject: [PATCH 22/23] IN-421: add axios as dep. --- package-lock.json | 80 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 81 insertions(+) diff --git a/package-lock.json b/package-lock.json index 2e62517..9aa7711 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@polkadot/api": "^9.9.4", + "axios": "^1.2.0", "dotenv": "^16.0.3", "envalid": "^7.3.1", "express": "^4.18.2", @@ -1621,6 +1622,29 @@ "node": ">=8.0.0" } }, + "node_modules/axios": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.0.tgz", + "integrity": "sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -3330,6 +3354,25 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", @@ -5936,6 +5979,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", @@ -8503,6 +8551,28 @@ "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==" }, + "axios": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.2.0.tgz", + "integrity": "sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -9790,6 +9860,11 @@ "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, + "follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + }, "foreground-child": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", @@ -11723,6 +11798,11 @@ "ipaddr.js": "1.9.1" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", diff --git a/package.json b/package.json index 047d7e3..6e41d70 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "homepage": "https://github.com/digicatapult/dscp-ipfs#readme", "dependencies": { "@polkadot/api": "^9.9.4", + "axios": "^1.2.0", "dotenv": "^16.0.3", "envalid": "^7.3.1", "express": "^4.18.2", From 28602d3aa8f669ffbc0eb85528839c213d209ceb Mon Sep 17 00:00:00 2001 From: Paulius Date: Tue, 29 Nov 2022 10:41:14 +0000 Subject: [PATCH 23/23] IN-421: hardcoding. --- helm/dscp-ipfs/templates/statefulset.yaml | 2 +- test/integration/ipfs.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helm/dscp-ipfs/templates/statefulset.yaml b/helm/dscp-ipfs/templates/statefulset.yaml index c6437c3..c522612 100644 --- a/helm/dscp-ipfs/templates/statefulset.yaml +++ b/helm/dscp-ipfs/templates/statefulset.yaml @@ -98,7 +98,7 @@ spec: configMapKeyRef: name: {{ include "dscp-ipfs.fullname" . }}-config key: healthCheckPort - - name: IPFS_API_PORT + - name: IPFS_API_PORT valueFrom: configMapKeyRef: name: {{ include "dscp-ipfs.fullname" . }}-config diff --git a/test/integration/ipfs.test.js b/test/integration/ipfs.test.js index bacf715..c5c315d 100644 --- a/test/integration/ipfs.test.js +++ b/test/integration/ipfs.test.js @@ -33,8 +33,8 @@ const download = (port) => async (hash) => { return contentText } -const downloadA = download(env.IPFS_API_PORT) -const downloadB = download(`5002`) //TODO mm? 50/50 to be fair since it's test i think we should ignore +const downloadA = download(`5001`) +const downloadB = download(`5002`) const setupIpfsWithSwarm = async (context) => { before(async function () {