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

ENV inconsistency for database user and others variables #425

Open
sausix opened this issue Dec 28, 2024 · 2 comments
Open

ENV inconsistency for database user and others variables #425

sausix opened this issue Dec 28, 2024 · 2 comments

Comments

@sausix
Copy link

sausix commented Dec 28, 2024

This bug report is probably early but it should help on development.
Because it affects: seafileltd/seafile-mc:12.0-latest
I'm new to seafile but I have developing background.

For testing I have set various variables to their own name like this so you can recognize origins:

MYSQL_PASSWORD=MYSQL_PASSWORD
MYSQL_USER=MYSQL_USER
MYSQL_USER_PASSWD=MYSQL_USER_PASSWD
MYSQL_DB_USER=MYSQL_DB_USER
DB_PASSWORD=DB_PASSWORD
...

Looks like there are multiple environment variables for the same setting according to documentation and my code insights:

  • MYSQL_USER
  • MYSQL_DB_USER
  • SEAFILE_MYSQL_DB_USER

Setting all these variables to different values still results in a hardcoded user "seafile":
CREATE USER 'seafile'@'%.%.%.%' IDENTIFIED BY 'DB_PASSWORD'
(I've enabled general-log in mariadbd)

Probably because of here:
https://github.com/haiwen/seafile-docker/blob/master/scripts/scripts_12.0/bootstrap.py#L145

That would be ok, but other code uses other variables what results in these errors:
Access denied for user 'SEAFILE_MYSQL_DB_USER'@'172.21.0.4' (using password: YES)

Please only allow one scheme. I would recommend to throw warnings if an old or deprecated environment variable is set to avoid silent misconfigurations.

Also only these ENVs are used:

[email protected]
INIT_SEAFILE_ADMIN_PASSWORD=asecret

But previously it looks like it was:

[email protected]
SEAFILE_ADMIN_PASSWORD=asecret

Is there a reason for that breaking old names?

Another minor bug:

A lot of warnings occur in the logs like this (mariadbd verbosity set to 4):

seafile-mysql      | 2024-12-28 22:51:44 8 [Warning] Could not read packet: fd: 47  state: 1  read_length: 4  errno: 11  vio_errno: 1158  length: 0
seafile-mysql      | 2024-12-28 22:51:44 8 [Warning] Aborted connection 8 to db: 'seahub_db' user: 'seafile' host: '172.21.0.4' (Got an error reading communication packets)

Probably because of missing close() calls after connects for example here: https://github.com/haiwen/seafile-docker/blob/master/scripts/scripts_12.0/setup-seafile-mysql.py#L475

A little bit context manager logic could help a lot:
https://stackoverflow.com/questions/31214658/can-i-use-pymysql-connect-with-with-statement

Yeah... These are just warnings but it burnt a lot of my time today finding the root cause of:
Error happened during creating seafile admin.

I spent a lot of time today for this and could not get a modified image running to offer PRs. Sorry.
Affects mariadb:latest and mariadb:10.11 with seafileltd/seafile-mc:12.0-latest.

@SkywalkerSpace
Copy link
Contributor

SkywalkerSpace commented Dec 30, 2024

Thanks for your feedback, we will fix the mysql connect issue.

SEAFILE_MYSQL_DB_USER is used to transfer the db_user to seadoc. If you do not use seadoc, you can ignore this configuration. In Seafile, default db_user is 'seafile'.

INIT_*** is only used for init Seafile. When you have deployed Seafile, you can remove these configurations in .env.

@sausix
Copy link
Author

sausix commented Dec 30, 2024

@SkywalkerSpace
Thank you. Don't forget the hardcoded "seafile" db user. That was my main issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants