Skip to content

Commit

Permalink
Upgrade go-ipfs version to at least 13.1 (#37)
Browse files Browse the repository at this point in the history
* Upgrade go-ipfs version to at least 13.1

* Upgrade go-ipfs in dockerfile

* Healthcheck shouldn't create new api on each poll
  • Loading branch information
mattdean-digicatapult authored Jul 20, 2022
1 parent b9ab8e2 commit 4935b73
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
set -ex
Expand Down
2 changes: 1 addition & 1 deletion app/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const vars = envalid.cleanEnv(
default: 'ipfs',
devDefault: path.resolve(__dirname, '..', `node_modules`, '.bin', 'ipfs'),
}),
IPFS_ARGS: validateArgs({ default: '["daemon"]' }),
IPFS_ARGS: validateArgs({ default: '["daemon", "--migrate"]' }),
IPFS_LOG_LEVEL: envalid.str({ default: 'info', devDefault: 'debug' }),
HEALTHCHECK_POLL_PERIOD_MS: envalid.num({ default: 30 * 1000, devDefault: 1000 }),
HEALTHCHECK_TIMEOUT_MS: envalid.num({ default: 2 * 1000, devDefault: 1000 }),
Expand Down
11 changes: 3 additions & 8 deletions app/keyWatcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ const { setupKeyWatcher } = require('./keyWatcher')
const { ConnectionError } = require('../utils/Errors')

module.exports = {
setupKeyWatcher: async ({ onUpdate }) => {
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])

Expand Down
6 changes: 4 additions & 2 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 })
Expand Down
4 changes: 2 additions & 2 deletions helm/dscp-ipfs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion helm/dscp-ipfs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -51,7 +52,7 @@ statefulSet:
image:
repository: digicatapult/dscp-ipfs
pullPolicy: IfNotPresent
tag: 'v2.5.0'
tag: 'v2.6.0'

storage:
storageClass: ""
Expand Down
36 changes: 9 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 4935b73

Please sign in to comment.