-
Notifications
You must be signed in to change notification settings - Fork 590
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
feat: support env variables to initialize db and user name #12545
Conversation
38d4993
to
56574be
Compare
Codecov Report
@@ Coverage Diff @@
## main #12545 +/- ##
==========================================
+ Coverage 69.40% 69.44% +0.03%
==========================================
Files 1440 1440
Lines 238757 238772 +15
==========================================
+ Hits 165713 165809 +96
+ Misses 73044 72963 -81
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 10 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
pub const DEFAULT_DATABASE_NAME: &str = "dev"; | ||
use std::env; | ||
|
||
pub static DEFAULT_DATABASE_NAME: LazyLock<String> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether we should make them system parameters and allow users to override them with CLI args on the first run. Or it could be confusing. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. BTW maybe it doesn't need to be a system param and just a CLI arg or sth, as it's only usage is init.
No confusion since the user must have looked up for the variable and know exactly what he wants to do.
The common usage is to specify in the docker file before starting the database.
IIUC, POSTGRES_DB
is a feature of postgres docker image, instead of postgres kernel, which has other configuration mechanism for initialization.
So, I think this solution of course works, but it's hacky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. We need to make sure it only takes effect on the first run. After the database being initialized, the default db and username should be persisted.
I believe this is also the behavior of the POSTGRES_DB
.
format!( | ||
"psql -h localhost -p 4566 -d {} -U {}", | ||
*DEFAULT_DATABASE_NAME, *DEFAULT_SUPER_USER | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually reminds me of the PGxxx
environment variables..
how about RW_? No confusion since the user must have looked up for the variable and know exactly what he wants to do. Was requested by three users. The common usage is to specify in the docker file before starting the database. |
Ping. Shall we push this forward? I think it's blocking on #12545 (comment) and no updates since then. cc. @lmatz |
Sure, let me work on it in the near future, I believe I misunderstood the previous comment above, I suppose the key point is to persist and use the persistent default users and database names to do all kinds of comparisons and checks later, right using environment variable to set the default users and database names is still acceptable❓ |
FYI, this is how |
Yeah, but only the first boot for initialization, as demonstrated in @xxchan's comment. |
Recap my idea:
Where to read the configuration will be another orthogonal topic: either through env var to be compatible with postgres server, or through some (immutable) system parameters from the configuration file. cc @yezizp2012 |
This PR has been open for 60 days with no activity. Could you please update the status? Feel free to ping a reviewer if you are waiting for review. |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
#11190 two out of three
since we have no default password being set, need someone help with the
POSTGRES_PASSWORD
oneChecklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.
Support using environment variables
POSTGRES_USER
andPOSTGRES_DB
to initialize both configs.