dappnode / DNP_DAPPMANAGER

Dappnode package responsible for providing the Dappnode Package Manager
GNU General Public License v3.0
31 stars 39 forks source link

Prevent deleting volume if it's shared across packages #197

Closed vdo closed 5 years ago

vdo commented 5 years ago

When deleting a volume of ETHCHAIN, if it's shared with another package (for example VIPnode) it will give an error and then the ETHCHAIN package will disappear.

logs:

ERROR [registerHandler] [] : Error on restartPackageVolumes.dappmanager.dnp.dappnode.eth: Error: Command failed: docker volume rm -f dncore_ethchaindnpdappnodeeth_data
Error response from daemon: remove dncore_ethchaindnpdappnodeeth_data: volume is in use - [b2288bb3a393ee070743694656fa461fb5a33cfba417dbfc4f0d413004af0873]

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

A way to prevent that would be to check the number containers using it:

docker ps --filter=volume=dncore_ethchaindnpdappnodeeth_data  --format "{{.Names}}"
dapplion commented 5 years ago

After completing an implementation at https://github.com/dappnode/DNP_ADMIN/pull/283, I think this issue is not that simple to resolve.

Since the only deletable volumes are named volumes, if they are shared there must be a single declaration in some DNP's docker-compose. The DNP that declares the volume can be considered the "owner" of the volume, which can be obtained from the volume's name itself dncore_ethchaindnpdappnodeeth_data.

I believe that only the owner of a named volume should be allowed to remove it. Therefore, it should have the power to delete all DNPs that are using that volume (after the user is clearly warned) in order to perform the volume deletion.

Case example:

DNPs and volumes

If the user tries to remove vipnode.dnp.dappnode.eth volumes, only vipnodednpdappnodeeth_data will be removed and a modal or note will indicate that external volume dncore_ethchaindnpdappnodeeth_data can only be deleted in the ethchain.dnp.dappnode.eth DNP.

If the user tries to remove ethchain.dnp.dappnode.eth volumes, a dialog will show confirming that vipnode.dnp.dappnode.eth will be removed in order for the volume deletion to be possible. Then the DAPPMANAGER will do

# Pseudo code
docker rm vipnode.dnp.dappnode.eth
delete-volumes ethchain.dnp.dappnode.eth
docker-compose up vipnode.dnp.dappnode.eth
dapplion commented 5 years ago

Fixes https://github.com/dappnode/DNP_DAPPMANAGER/issues/217

dapplion commented 5 years ago

@vdo Has reviewed the concept and says ok

Shelpin commented 5 years ago

Checked!!

dapplion commented 5 years ago

@Shelpin pointed out that it confusing to offer the option of removing data of a DNP that has none. image

Fixed with https://github.com/dappnode/DNP_ADMIN/pull/333

Only display the 'Remove and delete data' button if necessary

Shelpin commented 5 years ago

image afther the latest commit the button is not appearing anymore but the text mentions the buttonn remove + delete data that actually does not exist anymore