Skip to content

Alternative to GRPC_XDS_BOOSTRAP env variable #7605

@erikjoh

Description

@erikjoh

Goal

I’m looking into creating a utility function that can dynamically create and assign the xDS bootstrap.
This could be hooked into the application startup so that xDS can be configured across different environments (IDE, GCE, GKE) without the need of startup shell scripts etc.

While almost every programming language supports dynamically setting environment variables, Java does not.
Would it be possible to have an alternative way in java to provide the location of the bootstrap file?

Possible solution

One possible solution that doesn’t break the existing API and gRPC spec would be to also try reading e.g. a java system property (System.getProperty(“grpc.xds.bootstrap”);) at

String filePath = System.getenv(BOOTSTRAP_PATH_SYS_ENV_VAR);
if (filePath == null) {
throw new XdsInitializationException(
"Environment variable " + BOOTSTRAP_PATH_SYS_ENV_VAR + " not defined.");
}

In the case that the GRPC_XDS_BOOSTRAP environment variable isn’t found.

Maybe something as simple as:

private static final String BOOTSTRAP_PATH_SYS_PROPERTY_VAR = "grpc.xds.bootstrap";
.
.
.
String filePath = Optional.ofNullable(System.getenv(BOOTSTRAP_PATH_SYS_ENV_VAR))
                          .orElse(System.getProperty(BOOTSTRAP_PATH_SYS_PROPERTY_VAR)); 

Alternatives

Alternative solutions would most likely require larger changes to the existing classes in order to pass the config down.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions