go-ethereum
go-ethereum copied to clipboard
Custom prefix for env vars
Rationale
Currently, we have GETH_
prefix for all env vars. It may cause some conflicts with k8s service env vars if there's a geth
service on the same namespace.
An example would be
GETH_PORT=tcp:<IP>:<PORT>
Implementation
On ./cmd/geth/main.go, we have the following
flags.AutoEnvVars(app.Flags, "GETH")
Maybe we can get the prefix from an environment variable with GETH
as default?
this is also happening on BSC https://github.com/bnb-chain/bsc/issues/2456
This issue is further exacerbated by https://github.com/ethereum/go-ethereum/issues/28216, making it so that it's not actually possible to execute a geth node under such circumstances.
How about add a new env: "GETH_ENV_PREFIX" to solve @exodus-justinz 's issue. https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/main.go#L261 like:
gethPrefix := "GETH"
if os.env.GETH_ENV_PREFIX != "" { // mock code
vgethPrefix = os.env.GETH_ENV_PREFIX
}
flags.AutoEnvVars(app.Flags, gethPrefix)
How about add a new env: "GETH_ENV_PREFIX"
Hm, I think I'd prefer making a simple solution rather than making things even more elaborate. Let users disable it if it gets in the way. Maybe something like this:
if os.Getenv("GETH_DISABLE_ENVVARS") == "" {
flags.AutoEnvVars(app.Flags, "GETH")
}
I'm a bit reluctant to do anything here. IMO this is not a Geth issue, this is a Kubernetes "issue". The same clash happens across the entire k8s ecosystem with tons of different projects (e.g. postgres). The solution isn't to hack every project out there to cater for k8s' weird env var injection. My 2c is that if k8s clashes with guest projects through some auto-generated env vars, then the k8s environment needs to be fixed (in this case, not naming the pod geth).