stefanpejcic / OpenPanel

A highly customizable web hosting control panel built with Docker 🐳
https://openpanel.com
216 stars 33 forks source link

Resizing EXT4 storage file for user on Overlay2 docker storage driver #275

Closed stefanpejcic closed 5 days ago

stefanpejcic commented 5 days ago

OpenPanel version(s) affected

0.3.5

What OS are you using?

Ubuntu

Description

When changing storage file limits for a plan, the opencli plans-apply script goes over all users on that plan and updates their storage file to the new quota. However the changes are not reflected as the loopback device is still of the old quota.

How to reproduce

  1. create paln with storage of 10gb
  2. add user on that plan
  3. change plan limits for storage file to 20gb
  4. check available disk space on /home/user

Possible Solution

No response

Additional Context

this is what we use for resizing:

docker stop USERNAME
umount /home/USERNAME
fallocate -l 20g /home/storage_file_USERNAME
e2fsck -f -y /home/storage_file_USERNAME
resize2fs /home/storage_file_USERNAME
mount -o loop /home/storage_file_USERNAME /home/USERNAME
docker start USERNAME

ps. this worked on devicemapper driver!

stefanpejcic commented 5 days ago

this is resolved by stopping all system containers before the process

cd /root
compose_services=$(docker compose ps --services)    # saved list of active services
docker compose down                                 # stopped all

### do the plan edit

opencli server-recreate_hosts                       # recreate hosts file if network limit was edited
docker compose up -d $compose_services              # start all services that were active
df -h                                               # check disk is increased

it is now added to plan-apply script to do it for each user on the plan, but should be optimized when multiple users are on the same plan, to just stop and start once before editing their du limits.