Conversation
45a6a80 to
05ac553
Compare
05ac553 to
88b67cc
Compare
ba79c2b to
96b96b2
Compare
I'm feeling like I may need a second opinion on this one. I would love for us not to go the way of (1), for the reasons you outlined. It'd be awesome for us to be able to tell users, "just set your PG* variables," without then listing a bunch of caveats/exceptions. That said, option (2) would definitely be a change from our current approach. Option (3) is also something that devs would need to understand and regularly interact with. In particular:
IMO it'd be non-ideal if it ended up being harder to use the I'm not opposed to options (2) or (3), but they do feel like big enough departures from the status quo that I think we should get wider sign-off before implementing one of them. Though just to throw out an option 4, is there any possibility of moving the logic in env.d/000_DB-env-defaults into Backend? If Backend were solely responsible for converting Is there anything outside Backend that uses the |
| # if the PGSERVICE mechanism — libpq named configurations (specified through this env var) | ||
| # sourced from a file (referenced through PGSERVICEFILE env var) is used, leave everything be. | ||
| if ! [[ -v PGSERVICE ]]; then |
There was a problem hiding this comment.
What's the reason for these new lines? Feels like this should maybe go in its own PR.
There was a problem hiding this comment.
It was an omission, this proviso should've been in #1647. I want dodge a bit of PR-busywork. It's all on-topic :-)
There was a problem hiding this comment.
I definitely get not wanting to open a million different PRs, but I'd encourage a separate PR in this case. I promise to review it quickly. 😅 I have specific questions about these lines, but asking them here feels a tad off-topic. I think having that conversation in its own PR would make the change more transparent — both to those following this work now and to our future selves doing Git archeology.
Not always, unfortunately. E.g., at https://docs.getodk.org/central-backup/ we recommend: docker compose exec service node /usr/odk/lib/bin/restore.js ... |
We can provide a wrapper for that. I'm starting to think we might want a generic wrapper so that you can go |
I considered that same thing ;-) and felt it doesn't solve the problem, it just moves the environment setting from an easy to reach for place (eg Yes, |
|
I think there must be a way to set the shell used when doing |
Yeah, no, |
|
It's still feeling like we should probably pull more people into this conversation (perhaps on Thursday). But let me throw out some thoughts.
That feels pretty ergonomic to me — just inserting Couple of follow-up questions about
This feels like a new use case, so maybe it's not something we need to be backwards-compatible about. I don't feel like it commits us to
Could you say more about the aspects of the problem that it doesn't solve? Are there concrete use cases outside The main purpose of the |
|
It's probably clear that I lean toward my option 4 currently. But most of all, I just want to understand the various options better (pros and cons) so that the tradeoffs are clear if/when we discuss as a team. |
👍
Yes.
Yes — and we may want to consider wrapping the scripts of
💯 . We need the wrapper to effect the fallback defaults, because we can't do it with Docker, mainly because it can't distinguish between unset and empty variables. Just migrate the .env!Doing things in a non-backward compatible way would save a lot of trouble and keep things cleaner and clearer, and we should at least consider it.
The use case for being able to verify your DB connection without involving ODK code is, for instance, for when you've been supplied with credentials for some provisioned DB and you're troubleshooting why you can't connect. And then you call over the sysadmin. You have a much stronger troubleshooting case when it's "I have these PG* vars in my process environment, exactly like the Postgres docs say, and I have the
True, of course there's a way, but it would be very easy if one could just access it the same way as central does, without having to copy/paste connection specifics from some config file.
That's very true! Just having the
hmmmm, we should use
Well, all the DB utilities one might want to use (
I'm now really thinking that we should dispense with all this runtime handling of backwards compat and defaults. I feel there's a big cost associated with it, in terms of extra code paths (to maintain, to test), unobviousness of what gets decided when and where, etc. There's no substitute for the congruence of "see env var in |
Problem:
A bit of circling around in #1647 eventually resulted in a solution that would use Bash's expressiveness to deal with the
PG*environment variables and in particular, backward compatibility for legacyDB_*variables. Defaults for thePG*env vars would not be defined via the docker environment (as we can't express what we want in Dockerese, to start with, it cannot distinguish between variable-undefined and variable-empty).Thus in
start-odk.shwe would do the necessary work. But, the environment created there would not be set for any randomdocker compose exec service [...]command. Only the env vars set through Docker's mechanisms are applied for those.The central-related commands we run are run through wrappers in
files/service/scripts, in addition to theodk-cmdwrapper (for creating users etc) that we steer users towards via the docs.So if we set the environment variables when those wrappers are executed, we'll be good.
This PR implements that idea.
As a recap, the alternatives are:
DB_*env vars and be done with it.PG*configuration.odk-cmdand the scripts inscripts/), but of course since previously there weren't any obvious advantages to using those wrappers, we haven't been dogfooding them. For instance here in Frontend we have been doing variantsdocker exec node [...].js, which then ends in tears as the DB defaults haven't been set. So, a bit of cognitive overhead for us devs.What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
See discussion above.
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
See discussion above.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No changes necessary. In the docs we steer users to
odk-cmd.Before submitting this PR, please make sure you have:
nextbranch OR only changed documentation/infrastructure (masteris stable and used in production)