-
Notifications
You must be signed in to change notification settings - Fork 53
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
Region config check #1554
Region config check #1554
Conversation
Does the PR have any schema changes?Does the PR have any schema changes?Looking good! No breaking changes found. Maintainer note: consult the runbook for dealing with any breaking changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great change. I left a couple comments to address before we merge.
provider/provider_yaml_test.go
Outdated
t.Setenv("GOOGLE_PROJECT", "") | ||
t.Setenv("GOOGLE_ZONE", "") | ||
t.Setenv("GOOGLE_REGION", "") | ||
credentialsValidationRun.Store(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not safe, since a different run of a similar test could set credentialsValidationRun
to true
between this store and a call to replay. I would prefer if remove the global state here, making credentialsValidationRun
a local variable in Provider()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to open an issue in the bridge about creating a PreCheckConfigCallback
interface, which will have the semantics of only ever being called once and we can schedule follow-up work on this. The issue you described is unlikely and will only effect tests, so I'd say it is out of scope for this PR.
That interface would be useful on the AWS side and then we can also carry it over to other t1 providers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw pulumi/pulumi-aws#3310 (comment), good idea. Will do that instead.
error: pulumi:providers:gcp resource 'default_7_6_0' has a problem: could not validate provider configuration: region "westus" is not available for project "pulumi-development". Available regions: ["asia-east1" "asia-east2" "asia-northeast1" "asia-northeast2" "asia-northeast3" "asia-south1" "asia-south2" "asia-southeast1" "asia-southeast2" "australia-southeast1" "australia-southeast2" "europe-central2" "europe-north1" "europe-southwest1" "europe-west1" "europe-west10" "europe-west12" "europe-west2" "europe-west3" "europe-west4" "europe-west6" "europe-west8" "europe-west9" "me-central1" "me-central2" "me-west1" "northamerica-northeast1" "northamerica-northeast2" "southamerica-east1" "southamerica-west1" "us-central1" "us-east1" "us-east4" "us-east5" "us-south1" "us-west1" "us-west2" "us-west3" "us-west4"] Usability nit: the list is rather long. Any chance to replace with URL? Also curious what happens if region is required but missing. I think that's the more common case than misspelling the region. But may need to be in a separate PR. Maybe it's OK, it's one of these things, clearly this is a huge improvement on status quo! |
I've adjusted the error message to point to the gcp docs. I've also separated them in txt files as in AWS.
Unfortunately I don't believe we can do anything about that without breaking existing programs, since region is not required.:
|
https://github.com/pulumi/pulumi-gcp/actions/runs/7726974699/job/21064805014?pr=1554 More test failures due to the different project names during recording and CI. I'll add a flag to skip the region check and use that in the tests. Might be good to have for users anyway, in case I'm not seeing some case in which this breaks. AWS has similar flags for the checks in preConfigureCallback |
provider/provider_test.go
Outdated
if config != nil { | ||
for k, v := range config { | ||
test.SetConfig(k, v) | ||
} | ||
} | ||
// The SetConfig above does not seem to be working here. | ||
test.T().Setenv("PULUMI_GCP_SKIP_REGION_VALIDATION", "true") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is pulumi/providertest#56 will look into it later.
return fmt.Errorf(noCredentialsErr, err) | ||
} | ||
|
||
skipRegionValidation := tfbridge.ConfigBoolValue( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a config flag to control the region validation behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. LGTM
Should fix #129 by reintroducing #1554 reverted in #1650 I've also added a mechanism to pass in options to the GCP client via `preConfigureCallback` as well as tests for that around the region list behaviour. I haven't tested with OIDC auth since it seems quite involved. The new tests should ensure that we have not introduced any failures there, LMK if you don't think this is sufficient.
Should address issue raised in #129 (comment)
Adds region validation to the GCP provider.
Error before (during up):
Error after (during preview):