From 4935b735bf5b429576fa9e26393835aa3c5678b0 Mon Sep 17 00:00:00 2001 From: Matthew Dean Date: Wed, 20 Jul 2022 10:16:56 +0100 Subject: [PATCH] Upgrade go-ipfs version to at least 13.1 (#37) * Upgrade go-ipfs version to at least 13.1 * Upgrade go-ipfs in dockerfile * Healthcheck shouldn't create new api on each poll --- Dockerfile | 2 +- app/env.js | 2 +- app/keyWatcher/index.js | 11 +++-------- app/server.js | 6 ++++-- helm/dscp-ipfs/Chart.yaml | 4 ++-- helm/dscp-ipfs/values.yaml | 3 ++- package-lock.json | 36 +++++++++--------------------------- package.json | 4 ++-- 8 files changed, 24 insertions(+), 44 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ba95d5..a2e7c36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apk add --no-cache git make bash gcc musl-dev WORKDIR /target -ARG IPFS_TAG="v0.10.0" +ARG IPFS_TAG="v0.13.1" RUN < { - const api = await createNodeApi() + createNodeApi, + setupKeyWatcher: async ({ api, onUpdate }) => { await setupKeyWatcher(api)({ onUpdate }) - return api }, - nodeHealthCheck: async (api = false, name = 'substrate') => { + nodeHealthCheck: async (api, name = 'substrate') => { try { - if (!api.isReady) { - const { _api } = await createNodeApi() - api = _api - } if (!(await api.isConnected)) throw new ConnectionError({ name }) const [chain, runtime] = await Promise.all([api.runtimeChain, api.runtimeVersion]) diff --git a/app/server.js b/app/server.js index 429fa30..57fa913 100644 --- a/app/server.js +++ b/app/server.js @@ -3,7 +3,7 @@ const pinoHttp = require('pino-http') const { PORT } = require('./env') const logger = require('./logger') -const { setupKeyWatcher, nodeHealthCheck } = require('./keyWatcher') +const { createNodeApi, setupKeyWatcher, nodeHealthCheck } = require('./keyWatcher') const { ipfsHealthCheack } = require('./ipfs') const { setupIpfs } = require('./ipfs') const ServiceWatcher = require('./utils/ServiceWatcher') @@ -12,13 +12,15 @@ async function createHttpServer() { const app = express() const requestLogger = pinoHttp({ logger }) const ipfs = await setupIpfs() + const api = await createNodeApi() const sw = new ServiceWatcher({ - substrate: { healthCheck: () => nodeHealthCheck({ isReady: false }) }, + substrate: { healthCheck: () => nodeHealthCheck({ api, isReady: false }) }, ipfs: { healthCheck: () => ipfsHealthCheack(ipfs) }, }) await setupKeyWatcher({ + api, onUpdate: async (value) => { await ipfs.stop() await ipfs.start({ swarmKey: value }) diff --git a/helm/dscp-ipfs/Chart.yaml b/helm/dscp-ipfs/Chart.yaml index 1e82df8..d21662f 100644 --- a/helm/dscp-ipfs/Chart.yaml +++ b/helm/dscp-ipfs/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: dscp-ipfs -appVersion: '2.5.0' +appVersion: '2.6.0' description: A Helm chart for dscp-ipfs -version: '2.5.0' +version: '2.6.0' type: application dependencies: - name: dscp-node diff --git a/helm/dscp-ipfs/values.yaml b/helm/dscp-ipfs/values.yaml index cce68ea..ab4f4bd 100644 --- a/helm/dscp-ipfs/values.yaml +++ b/helm/dscp-ipfs/values.yaml @@ -14,6 +14,7 @@ config: ipfsCommand: "/usr/local/bin/ipfs" ipfsArgs: - daemon + - "--migrate" # ipfsBootNodeAddress: /dnsaddr/blah.test.com/p2p/PeerId # Valid Format for this is /multiaddr/PeerId see https://github.com/multiformats/multiaddr ipfsLogLevel: info ipfsSwarmAddrFilters: @@ -51,7 +52,7 @@ statefulSet: image: repository: digicatapult/dscp-ipfs pullPolicy: IfNotPresent - tag: 'v2.5.0' + tag: 'v2.6.0' storage: storageClass: "" diff --git a/package-lock.json b/package-lock.json index c0dad70..728253b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@digicatapult/dscp-ipfs", - "version": "2.5.0", + "version": "2.6.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@digicatapult/dscp-ipfs", - "version": "2.5.0", + "version": "2.6.0", "license": "Apache-2.0", "dependencies": { "@digicatapult/dscp-node": "^4.2.1", @@ -25,7 +25,7 @@ "eslint-config-prettier": "^8.1.0", "eslint-plugin-prettier": "^3.3.1", "form-data": "^3.0.1", - "go-ipfs": "^0.11.0", + "go-ipfs": "^0.13.1", "mocha": "^9.2.0", "node-fetch": "npm:@achingbrain/node-fetch@^2.6.7", "nodemon": "^2.0.19", @@ -3439,15 +3439,13 @@ } }, "node_modules/go-ipfs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/go-ipfs/-/go-ipfs-0.11.0.tgz", - "integrity": "sha512-l6uZTeEZYQQpKsoI8DXV5j1UDiq7xTIwNyp5lGJmY1cR9LoWHR4lIhbSpc2DfvOv5Ly/+BC/CLvo7vIFmdmyGQ==", - "deprecated": "Version no longer supported. Upgrade to 0.12.2 or later.", + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/go-ipfs/-/go-ipfs-0.13.1.tgz", + "integrity": "sha512-LW8BKQ7DGEb0fFKlBXU8QGhr2XVoex9N7hJ7rehOYEA+t/O5KzK3OFqSIwa+S2KSwejJlAocqgf0i6/1Fj5ufA==", "dev": true, "hasInstallScript": true, "dependencies": { "cachedir": "^2.3.0", - "go-platform": "^1.0.0", "got": "^11.7.0", "gunzip-maybe": "^1.4.2", "hasha": "^5.2.2", @@ -3459,15 +3457,6 @@ "ipfs": "bin/ipfs" } }, - "node_modules/go-platform": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/go-platform/-/go-platform-1.0.0.tgz", - "integrity": "sha1-sF/2uSdAB9JGsWQjXwP39qWWJsc=", - "dev": true, - "bin": { - "go-platform": "cli.js" - } - }, "node_modules/got": { "version": "11.8.5", "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz", @@ -9490,13 +9479,12 @@ "dev": true }, "go-ipfs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/go-ipfs/-/go-ipfs-0.11.0.tgz", - "integrity": "sha512-l6uZTeEZYQQpKsoI8DXV5j1UDiq7xTIwNyp5lGJmY1cR9LoWHR4lIhbSpc2DfvOv5Ly/+BC/CLvo7vIFmdmyGQ==", + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/go-ipfs/-/go-ipfs-0.13.1.tgz", + "integrity": "sha512-LW8BKQ7DGEb0fFKlBXU8QGhr2XVoex9N7hJ7rehOYEA+t/O5KzK3OFqSIwa+S2KSwejJlAocqgf0i6/1Fj5ufA==", "dev": true, "requires": { "cachedir": "^2.3.0", - "go-platform": "^1.0.0", "got": "^11.7.0", "gunzip-maybe": "^1.4.2", "hasha": "^5.2.2", @@ -9505,12 +9493,6 @@ "unzip-stream": "^0.3.0" } }, - "go-platform": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/go-platform/-/go-platform-1.0.0.tgz", - "integrity": "sha1-sF/2uSdAB9JGsWQjXwP39qWWJsc=", - "dev": true - }, "got": { "version": "11.8.5", "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz", diff --git a/package.json b/package.json index 9a35f2f..4523bef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digicatapult/dscp-ipfs", - "version": "2.5.0", + "version": "2.6.0", "description": "Service for DSCP", "main": "app/index.js", "scripts": { @@ -47,7 +47,7 @@ "eslint-config-prettier": "^8.1.0", "eslint-plugin-prettier": "^3.3.1", "form-data": "^3.0.1", - "go-ipfs": "^0.11.0", + "go-ipfs": "^0.13.1", "mocha": "^9.2.0", "node-fetch": "npm:@achingbrain/node-fetch@^2.6.7", "nodemon": "^2.0.19",