Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Adding a file or directory mount to a database, breaks defaul volume mount #5034

Open
benosman opened this issue Feb 2, 2025 · 5 comments · Fixed by #5051
Open

[Bug]: Adding a file or directory mount to a database, breaks defaul volume mount #5034

benosman opened this issue Feb 2, 2025 · 5 comments · Fixed by #5051
Assignees
Labels
🐞 Confirmed Bug Verified issues that have been reproduced by the team. ✅ Done Issues that are fixed and a PR is ready to be merged.

Comments

@benosman
Copy link

benosman commented Feb 2, 2025

Error Message and Logs

When adding file or directory mounts to a database service (tested with mariadb and mysql), the docker compose config is broken for the default volume mount (and additional ones).

This means that the db appears to lose data and is no longer persistent. Removing the mount restores the issue. It affects the config under services.<id>.volumes, not the root volumes.

Before adding mount:

services:
    zgwg4g0kck4s8cskokos84ss:
        ...
        volumes:
            - 'app-name-db:/var/lib/mysql'
volumes:
    app-name-db:
        name: app-name-db
        external: false

After adding mount:

services:
    zgwg4g0kck4s8cskokos84ss:
        ...
        volumes:
            - '/data/coolify/databases/zgwg4g0kck4s8cskokos84ss/root/.my.cnf:/root/.my.cnf'
volumes:
    app-name-db:
        name: app-name-db
        external: false

Steps to Reproduce

  1. Create a mariadb database
  2. Start database
  3. Check docker-compose.yaml and volume should be correct.
  4. Add file mount and save
  5. Restart database
  6. Check docker-compose.yaml and volume is likely incorrect.
  7. Remove file mount and save
  8. Restart database
  9. Check docker-compose.yaml and volume should be correct.

Example Repository URL

No response

Coolify Version

v4.0.0-beta.390

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

AlmaLinux 9.5

Additional Information

The file mounts previously didn't work and was fixed after #4668

That might be a good start to see where the cause of this issue is.

@benosman benosman added 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Feb 2, 2025
@benosman
Copy link
Author

benosman commented Feb 2, 2025

I took a quick look at the code and it seems to affect all database drivers.

$docker_compose['services'][$container_name]['volumes'] is set but then overridden if $persistent_file_volumes is present. Instead it needs to create an empty array then push or to merge the two arrays.

        if (count($persistent_storages) > 0) {
            $docker_compose['services'][$container_name]['volumes'] = $persistent_storages;
        }
        if (count($persistent_file_volumes) > 0) {
            $docker_compose['services'][$container_name]['volumes'] = $persistent_file_volumes->map(function ($item) {
                return "$item->fs_path:$item->mount_path";
            })->toArray();
        }

@peaklabs-dev peaklabs-dev self-assigned this Feb 2, 2025
@peaklabs-dev peaklabs-dev added 🐞 Confirmed Bug Verified issues that have been reproduced by the team. ✅ Done Issues that are fixed and a PR is ready to be merged. and removed 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Feb 2, 2025
@peaklabs-dev peaklabs-dev added this to the v4.0.0 Stable Release milestone Feb 2, 2025
@andrasbacsai andrasbacsai linked a pull request Feb 3, 2025 that will close this issue
@github-actions github-actions bot removed 🐞 Confirmed Bug Verified issues that have been reproduced by the team. ✅ Done Issues that are fixed and a PR is ready to be merged. labels Feb 4, 2025
@benosman
Copy link
Author

benosman commented Feb 4, 2025

@peaklabs-dev @andrasbacsai - I took a look at the pull request and I couldn't see any changes to the files I expected.

Could you point me to the commit with the fix?

@peaklabs-dev
Copy link
Member

You cannot see the commit because it was only local, I committed it yesterday because of some testing and so on, but this is the commit: 5f357e3

@peaklabs-dev peaklabs-dev reopened this Feb 4, 2025
@peaklabs-dev peaklabs-dev self-assigned this Feb 4, 2025
@peaklabs-dev peaklabs-dev added 🐞 Confirmed Bug Verified issues that have been reproduced by the team. ✅ Done Issues that are fixed and a PR is ready to be merged. labels Feb 4, 2025
@benosman
Copy link
Author

benosman commented Feb 4, 2025

thanks, I saw the release and the closing of this issue, at the same time so I went to check. I've got it working locally with an override, so I will wait for the next release before upgrading.

The commit looks like it should fix it, presumably it will be rolled out to all databases?

@peaklabs-dev
Copy link
Member

yes other DBs are in testing locally.

@peaklabs-dev peaklabs-dev marked this as a duplicate of #5099 Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Confirmed Bug Verified issues that have been reproduced by the team. ✅ Done Issues that are fixed and a PR is ready to be merged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants