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

Custom prefix for env vars #29779

Open
exodus-justinz opened this issue May 15, 2024 · 5 comments
Open

Custom prefix for env vars #29779

exodus-justinz opened this issue May 15, 2024 · 5 comments

Comments

@exodus-justinz
Copy link

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?

@exodus-justinz
Copy link
Author

this is also happening on BSC bnb-chain/bsc#2456

@holiman
Copy link
Contributor

holiman commented May 15, 2024

This issue is further exacerbated by #28216, making it so that it's not actually possible to execute a geth node under such circumstances.

@zzzckck
Copy link

zzzckck commented May 15, 2024

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)

@holiman
Copy link
Contributor

holiman commented May 15, 2024

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")
	}

@karalabe
Copy link
Member

karalabe commented May 15, 2024

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).

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

No branches or pull requests

4 participants