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

Add EncryptionConfig to Cloud Composer's EnvironmentConfig #4310

Merged
merged 5 commits into from
Feb 17, 2021

Conversation

dzarmola
Copy link
Contributor

@dzarmola dzarmola commented Dec 11, 2020

Add a new section (EncryptionConfig) to Cloud Composer's EnvironmentConfig used for environment creation and updating

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

composer: added `encryption_config`  to `google_composer_environment` resource (TPGB only)

@google-cla google-cla bot added the cla: yes label Dec 11, 2020
@dzarmola
Copy link
Contributor Author

Right now I'm mostly hoping for some guidance regarding running tests, as I'm consistently failing with:

==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google-beta -v -run=TestAccComposerEnvironment_withDatabaseConfig -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google-beta/version.ProviderVersion=acc"
# github.com/hashicorp/terraform-provider-google-beta/v3/google-beta [github.com/hashicorp/terraform-provider-google-beta/v3/google-beta.test]
google-beta/resource_composer_environment.go:711:20: patchObj.Config.EncryptionConfig undefined (type *composer.EnvironmentConfig has no field or method EncryptionConfig)
google-beta/resource_composer_environment.go:711:46: config.EncryptionConfig undefined (type *composer.EnvironmentConfig has no field or method EncryptionConfig)
google-beta/resource_composer_environment.go:839:92: envCfg.EncryptionConfig undefined (type *composer.EnvironmentConfig has no field or method EncryptionConfig)
google-beta/resource_composer_environment.go:887:70: undefined: composer.EncryptionConfig
google-beta/resource_composer_environment.go:1026:13: transformed.EncryptionConfig undefined (type *composer.EnvironmentConfig has no field or method EncryptionConfig)
google-beta/resource_composer_environment.go:1095:111: undefined: composer.EncryptionConfig
google-beta/resource_composer_environment.go:1103:18: undefined: composer.EncryptionConfig
FAIL	github.com/hashicorp/terraform-provider-google-beta/v3/google-beta [build failed]
FAIL
make: *** [GNUmakefile:15: testacc] Error 2

@rileykarson rileykarson requested review from a team and nat-henderson and removed request for a team December 14, 2020 20:27
@@ -700,6 +722,18 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
return err
}
}
<% end -%>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to combine these two conditions since they're identical, here and elsewhere.

},
// This is a terrible clean-up step in order to get destroy to succeed,
// due to dangling firewall rules left by the Composer Environment blocking network deletion.
// TODO(emilyye): Remove this check if firewall rules bug gets fixed by Composer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe update the name on the todo if you still need it?

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 4 files changed, 181 insertions(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 4 files changed, 163 insertions(+), 1 deletion(-))

@dzarmola
Copy link
Contributor Author

In case anybody finds this while searching for the error I posted earlier - in my case the problem was an outdated Go package describing Composer API: https://pkg.go.dev/google.golang.org/api/composer/v1beta1

@nat-henderson nat-henderson requested review from slevenick and nat-henderson and removed request for nat-henderson January 28, 2021 18:15
@slevenick
Copy link
Contributor

@dzarmola You will need to rebase or merge master so that this builds successfully I believe. There were directory structure changes since this was opened

@dzarmola
Copy link
Contributor Author

Thanks, rebased.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 3 files changed, 162 insertions(+))

@slevenick
Copy link
Contributor

/gcbrun

The version of the googleapis sdk should be updated now

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=170348"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 3 files changed, 162 insertions(+))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample|TestAccComposerEnvironment_withEncryptionConfig|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthorityCmekExample You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=170443"

Copy link
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to successfully run the added test here?

I'm seeing a strange error:

Error: Error waiting to create Environment: Error waiting for Creating Environment: Error code 2, message: Http error status code: 400
Http error message: BAD REQUEST
Errors in: [GKE cluster]; Error messages:
  {"ResourceType":"gcp-types/container-v1beta1:projects.locations.clusters","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"\n\t(1) Network \"tf-test-composer-net-8587385686315371018\" has no route to the default internet gateway. To fix this, add a route with destRange '0.0.0.0/0' and nextHopGateway 'default-internet-gateway'\n\t(2) network \"tf-test-composer-net-8587385686315371018\" does not exist.","status":"INVALID_ARGUMENT",

which seems to indicate that the network isn't set up correctly. But this looks identical to the other tests in this file. This could just be a flaky test, I'll rerun

"kms_key_name": {
Type: schema.TypeString,
Required: true,
Description: `Optional. Customer-managed Encryption Key available through Google's Key Management Service. Cannot be updated.`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this cannot be updated as indicated by the description, it should probably be marked ForceNew: true to force Terraform to recreate the resource if this field is changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added!

With regard to tests - I've noticed some problems with deletion after the test is complete (a firewall rule related issue, which, based on the comments, is known to happen), but nothing at creation.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 3 files changed, 163 insertions(+))

@dzarmola
Copy link
Contributor Author

Hey, is there something I could work on here to bring us closer to merging? It's an important part for Cloud Composer CMEK integration

Copy link
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry I started this review but didn't send it!

Required: true,
Description: `Optional. Customer-managed Encryption Key available through Google's Key Management Service. Cannot be updated.`,
},
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be one line up. Currently getting:

google-beta/resource_composer_environment.go:440:10: undefined: ForceNew

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed.

@slevenick
Copy link
Contributor

/gcbrun

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=172009"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 3 files changed, 163 insertions(+))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 4 files changed, 164 insertions(+), 1 deletion(-))

@slevenick
Copy link
Contributor

/gcbrun

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=172932"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 3 files changed, 163 insertions(+))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccRedisInstanceDatasource_basic|TestAccComposerEnvironment_withEncryptionConfig|TestAccRedisInstance_redisInstanceBasicExample|TestAccRedisInstance_redisInstanceFullExample|TestAccRedisInstance_update|TestAccRedisInstance_regionFromLocation|TestAccRedisInstance_redisInstanceAuthEnabled You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=172934"

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccComposerEnvironment_withEncryptionConfig Please fix these to complete your PR

@slevenick
Copy link
Contributor

Composer encryption test is failing, but unsure if it is because of anything in the provider. Error was:

  Creation of airflow web server version failed. This may be an intermittent issue of the App Engine service. You may retry the operation later.
{"ResourceType":"appengine.v1.version","ResourceErrorCode":"504","ResourceErrorMessage":"Timed out waiting for the flex deployment to become network provisioned."}
Cloud Storage Assertions Failed: Unable to write to GCS bucket.
GCS bucket write check failed.

I'll try running it again, but is it possible that the config doesn't set up the environment correctly?

@slevenick
Copy link
Contributor

/gcbrun

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=172936"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 11 insertions(+))
Terraform Beta: Diff ( 3 files changed, 163 insertions(+))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccBigtableAppProfile_bigtableAppProfileSingleclusterExample|TestAccComposerEnvironment_withEncryptionConfig|TestAccRedisInstance_redisInstancePrivateServiceExample You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=172941"

@modular-magician
Copy link
Collaborator

Tests failed during RECORDING mode: TestAccRedisInstance_redisInstancePrivateServiceExample Please fix these to complete your PR

@slevenick slevenick self-requested a review February 17, 2021 20:30
Copy link
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Only test failing is flaky.

Thanks for the addition

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

Successfully merging this pull request may close these issues.

4 participants