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

Environment variables overriding provider options have no effect #23

Open
dubinsky opened this issue Jul 9, 2024 · 2 comments
Open

Comments

@dubinsky
Copy link
Contributor

dubinsky commented Jul 9, 2024

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.

$ devpod provider options gcloud | grep DISK_SIZE
    ... 40                                             
$ echo $DISK_SIZE
50

$ devpod up github.com/...

$ devpod machine list
        NAME     | PROVIDER |  AGE   
  ---------------+----------+--------
    pulumi-ee723 | gcloud   | 1m49s

$ gcloud compute instances list
NAME                 ZONE        ... STATUS
devpod-pulumi-ee723  us-east4-b  ... RUNNING

$ gcloud compute instances describe devpod-pulumi-ee723 --zone=us-east4-b | grep diskSizeGb
  diskSizeGb: '40'
@pascalbreuninger
Copy link
Member

pascalbreuninger commented Jul 10, 2024

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

@dubinsky
Copy link
Contributor Author

@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
  • there are no on-screen instructions when adding the provider;
  • 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.

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

No branches or pull requests

2 participants