Skip to content

Commit 128675c

Browse files
authored
Merge pull request #343 from dappnode/v0.2.26
v0.2.26 Release
2 parents f8012fd + 0767f0e commit 128675c

File tree

5 files changed

+72
-8
lines changed

5 files changed

+72
-8
lines changed

build/src/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const logs = Logs(module);
2525

2626
// Start HTTP API
2727
import "./httpApi";
28+
import { removeLegacyBindVolume } from "./modules/legacy/removeLegacyBindVolume";
2829

2930
// Start eth forward http proxy
3031
startEthForward();
@@ -200,6 +201,10 @@ async function runLegacyOps(): Promise<void> {
200201
migrateEthForward().catch(e =>
201202
logs.error(`Error migrating ETHFORWARD: ${e.stack}`)
202203
);
204+
205+
removeLegacyBindVolume().catch(e =>
206+
logs.error(`Error removing legacy BIND volume: ${e.stack}`)
207+
);
203208
}
204209

205210
runLegacyOps();

build/src/src/modules/ethClient/migrateEthchain.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from "fs";
22
import { changeEthMultiClient } from "./changeEthMultiClient";
33
import { listContainerNoThrow } from "../../modules/docker/listContainers";
44
import { dockerVolumesList, dockerDf } from "../../modules/docker/dockerApi";
5-
import { dockerRm } from "../../modules/docker/dockerCommands";
5+
import { dockerRm, dockerVolumeRm } from "../../modules/docker/dockerCommands";
66
import { migrateVolume } from "../../modules/hostScripts";
77
import { getUserSettingsSafe } from "../../utils/dockerComposeFile";
88
import * as getPath from "../../utils/getPath";
@@ -14,7 +14,9 @@ const ethchainDnpName = "ethchain.dnp.dappnode.eth";
1414

1515
const ethchainVolumes = {
1616
data: "dncore_ethchaindnpdappnodeeth_data",
17-
geth: "dncore_ethchaindnpdappnodeeth_geth"
17+
geth: "dncore_ethchaindnpdappnodeeth_geth",
18+
identity: "dncore_ethchaindnpdappnodeeth_identity",
19+
ipc: "dncore_ethchaindnpdappnodeeth_ipc"
1820
};
1921
const openEthereumVolumes = {
2022
data: "openethereumdnpdappnodeeth_data"
@@ -45,7 +47,7 @@ export async function migrateEthchain(): Promise<void> {
4547
};
4648
const isNextOpenEthereum = /parity/i.test(envs.DEFAULT_CLIENT || "");
4749

48-
const volumeMigrations = [
50+
const volumesToMigrate = [
4951
{
5052
id: "OpenEthereum data volume",
5153
from: ethchainVolumes.data,
@@ -64,6 +66,17 @@ export async function migrateEthchain(): Promise<void> {
6466
!volumes.find(vol => vol.Name === to)
6567
);
6668

69+
const volumesToRemove = [
70+
{
71+
id: "legacy identity volume",
72+
name: ethchainVolumes.identity
73+
},
74+
{
75+
id: "legacy IPC volume",
76+
name: ethchainVolumes.ipc
77+
}
78+
].filter(({ name }) => volumes.find(vol => vol.Name === name));
79+
6780
// Non-blocking step of uninstalling the DNP_ETHCHAIN
6881
if (ethchain)
6982
try {
@@ -81,7 +94,7 @@ export async function migrateEthchain(): Promise<void> {
8194
}
8295

8396
// Non-blocking step of migrating old volumes with a host script
84-
for (const { id, from, to } of volumeMigrations) {
97+
for (const { id, from, to } of volumesToMigrate) {
8598
try {
8699
// Remove all packages that are using the volume to safely move it
87100
const idsToRemove = await shell(`docker ps -aq --filter volume=${from}`);
@@ -94,11 +107,11 @@ export async function migrateEthchain(): Promise<void> {
94107
}
95108
}
96109
// Optimization to only run `docker system df -v` once, can run for +15s
97-
if (volumeMigrations.length > 0)
110+
if (volumesToMigrate.length > 0)
98111
try {
99112
// Make sure the volume was migrated successfully before removing it
100113
const { Volumes } = await dockerDf({ noCache: true });
101-
for (const { id, from } of volumeMigrations) {
114+
for (const { id, from } of volumesToMigrate) {
102115
const fromVol = Volumes.find(vol => vol.Name === from);
103116
if (!fromVol)
104117
logs.warn(`Did not delete ETHCHAIN ${id} ${from}, not found`);
@@ -116,6 +129,18 @@ export async function migrateEthchain(): Promise<void> {
116129
logs.error(`Error deleting ETHCHAIN volumes: ${e.stack}`);
117130
}
118131

132+
for (const { id, name } of volumesToRemove) {
133+
try {
134+
// Remove all packages that are using the volume to safely move it
135+
const idsToRemove = await shell(`docker ps -aq --filter volume=${name}`);
136+
if (idsToRemove) throw Error(`Volume is used by ${idsToRemove}`);
137+
await dockerVolumeRm(name);
138+
logs.info(`Removed ETHCHAIN ${id}`);
139+
} catch (e) {
140+
logs.error(`Error removing ETHCHAIN ${id}: ${e.stack}`);
141+
}
142+
}
143+
119144
// Install new package. fullnode.dappnode is assigned after install
120145
if (ethchain) {
121146
const target = isNextOpenEthereum ? "openethereum" : "geth";
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Logs from "../../logs";
2+
import shell from "../../utils/shell";
3+
import { dockerVolumesList } from "../docker/dockerApi";
4+
import { dockerVolumeRm } from "../docker/dockerCommands";
5+
const logs = Logs(module);
6+
7+
const oldBindVol = "dncore_binddnpdappnodeeth_data";
8+
const newBindVol = "dncore_binddnpdappnodeeth_bind";
9+
10+
/**
11+
* After core version 0.2.30 there will be an orphan volume of the
12+
* DNP_BIND which should be removed for asthetic versions
13+
*/
14+
export async function removeLegacyBindVolume(): Promise<void> {
15+
const volumes = await dockerVolumesList();
16+
const volumeExists = (name: string): boolean =>
17+
volumes.some(vol => vol.Name === name);
18+
19+
// nuevo-> dncore_binddnpdappnodeeth_bind
20+
// viejo-> dncore_binddnpdappnodeeth_data
21+
// Remove all packages that are using the volume to safely move it
22+
23+
if (volumeExists(oldBindVol) && volumeExists(newBindVol)) {
24+
const usersOfOld = await shell(
25+
`docker ps -aq --filter volume=${oldBindVol}`
26+
);
27+
if (usersOfOld)
28+
throw Error(`legacy BIND volume ${oldBindVol} has users: ${usersOfOld}`);
29+
30+
// Delete only if has no users
31+
await dockerVolumeRm(oldBindVol);
32+
logs.info(`Removed legacy BIND volume ${oldBindVol}`);
33+
}
34+
}

dappnode_package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dappmanager.dnp.dappnode.eth",
3-
"version": "0.2.25",
3+
"version": "0.2.26",
44
"description": "Dappnode package responsible for providing the DappNode Package Manager",
55
"type": "dncore",
66
"author": "DAppNode Association <admin@dappnode.io> (https://github.com/dappnode)",

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
build:
1313
context: .
1414
dockerfile: ./build/Dockerfile
15-
image: 'dappmanager.dnp.dappnode.eth:0.2.25'
15+
image: 'dappmanager.dnp.dappnode.eth:0.2.26'
1616
container_name: DAppNodeCore-dappmanager.dnp.dappnode.eth
1717
restart: always
1818
volumes:

0 commit comments

Comments
 (0)