@@ -2,7 +2,7 @@ import fs from "fs";
22import { changeEthMultiClient } from "./changeEthMultiClient" ;
33import { listContainerNoThrow } from "../../modules/docker/listContainers" ;
44import { dockerVolumesList , dockerDf } from "../../modules/docker/dockerApi" ;
5- import { dockerRm } from "../../modules/docker/dockerCommands" ;
5+ import { dockerRm , dockerVolumeRm } from "../../modules/docker/dockerCommands" ;
66import { migrateVolume } from "../../modules/hostScripts" ;
77import { getUserSettingsSafe } from "../../utils/dockerComposeFile" ;
88import * as getPath from "../../utils/getPath" ;
@@ -14,7 +14,9 @@ const ethchainDnpName = "ethchain.dnp.dappnode.eth";
1414
1515const 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} ;
1921const openEthereumVolumes = {
2022 data : "openethereumdnpdappnodeeth_data"
@@ -45,7 +47,7 @@ export async function migrateEthchain(): Promise<void> {
4547 } ;
4648 const isNextOpenEthereum = / p a r i t y / 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" ;
0 commit comments