Open dubinsky opened 2 weeks ago
Hey @dubinsky, it's actually the other way round: provider options take precedence over environment variables. If you want to specify only via env vars you'll need to ensure the provider options are set to their types default value first (""
, 0
, etc..)
@pascalbreuninger thank you for the clarification!
If I understand correctly, for the provider to even look at the environment variable corresponding to a provider option, that option has to first be "disarmed" on the provider by setting it to its type's default, for instance, 0
for DISK_SIZE
.
That seems to imply that the options with the option default being the same as the default for the option's type can not be disarmed at all, and environment variables setting those options will always be ignored - for example, SERVICE_ACCOUNT
.
In reality, even where in accordance with your clarification supplying the option value in an environment variable should work, it doesn't seem to:
$ devpod provider set-options gcloud -o DISK_SIZE=0
$ devpod provider options gcloud | grep DISK_SIZE
DISK_SIZE | false | The disk size to use. | 40 | 0
$ echo $DISK_SIZE
50
$ devpod up github.com/... --open-ide=false
info googleapi: Error 400: Invalid value for field 'resource.disks[0].initializeParams.diskSizeGb': '0'. Must be greater than or equal to 1
PROJECT
environment variable is ignored when adding the provider, and default gcloud
project is used:
$ echo $PROJECT
opentorah-devpod
$ devpod provider add gcloud
done Successfully installed provider gcloud
error cannot list instances: googleapi: Error 403: Compute Engine API has not been used in project opentorah-infra before or it is disabled.
If GCP project to use is supplied in the gcloud
-specific environment variable, provider option is set to that even though PROJECT
environment variable is not set at all:
$ echo $CLOUDSDK_CORE_PROJECT
opentorah-devpod
$ echo $PROJECT
$ devpod provider add gcloud
done Successfully installed provider gcloud
done Successfully configured provider 'gcloud'
$ devpod provider options gcloud | grep PROJECT
PROJECT | true | The project id to use. | | opentorah-devpod
Design decision to make options on the provider primary and the environment variables secondary (compounded, possibly, by what looks like some implementation bugs) renders environment variables (a "traditional" and "expected" way of overriding settings :)) useless (I am yet to discover any scenario where they have any effect) and documentation's remark Options can either be set in env or ...
misleading...
Also misleading is the following:
Follow the on-screen instructions to complete the setup.
Needed variables will be:
- ZONE
- PROJECT
ZONE
environment variable is ignored, and the option is set to europe-west2-b
(which is not declared as the default value in the output of devpod provider options
);PROJECT
environment variable is also ignored as shown above.
Documentation states that the VM instance can be customized by setting options as environment variables. Presumably, this should override options set on the provider - but it does not. Example showing that
DISK_SIZE
override via an environment variable is ignored follows; other environment variables (ZONE
,SERVICE_ACCOUNT
) are also ignored.