Skip to content

Add Managed Kafka Acl resource and tests.#14034

Merged
slevenick merged 10 commits intoGoogleCloudPlatform:mainfrom
amfisher-404:gmk-acl
May 21, 2025
Merged

Add Managed Kafka Acl resource and tests.#14034
slevenick merged 10 commits intoGoogleCloudPlatform:mainfrom
amfisher-404:gmk-acl

Conversation

@amfisher-404
Copy link
Copy Markdown
Contributor

@amfisher-404 amfisher-404 commented May 19, 2025

Description: Added a new Managed Kafka Acl terraform resource to the Google Terraform provider. Includes a basic create and update test.

Issue: https://b.corp.google.com/issues/374342184

`google_managed_kafka_acl`

@github-actions github-actions bot requested a review from slevenick May 19, 2025 20:49
@github-actions
Copy link
Copy Markdown

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@slevenick, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_managed_kafka_acl (3 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_managed_kafka_acl" "primary" {
  etag = # value needed
}

@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1056 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_managed_kafka_acl (3 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_managed_kafka_acl" "primary" {
  etag = # value needed
}

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 7
Skipped tests: 0
Affected tests: 2

Click here to see the affected service packages
  • managedkafka

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccManagedKafkaAcl_managedkafkaAclBasicExample
  • TestAccManagedKafkaAcl_update

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_managed_kafka_acl (3 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_managed_kafka_acl" "primary" {
  etag = # value needed
}

@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_managed_kafka_acl (3 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_managed_kafka_acl" "primary" {
  etag = # value needed
}

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 7
Skipped tests: 0
Affected tests: 2

Click here to see the affected service packages
  • managedkafka

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccManagedKafkaAcl_managedkafkaAclBasicExample
  • TestAccManagedKafkaAcl_update

Get to know how VCR tests work

1 similar comment
@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 7
Skipped tests: 0
Affected tests: 2

Click here to see the affected service packages
  • managedkafka

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccManagedKafkaAcl_managedkafkaAclBasicExample
  • TestAccManagedKafkaAcl_update

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 7
Skipped tests: 0
Affected tests: 2

Click here to see the affected service packages
  • managedkafka

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccManagedKafkaAcl_managedkafkaAclBasicExample
  • TestAccManagedKafkaAcl_update

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1056 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1056 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 7
Skipped tests: 0
Affected tests: 2

Click here to see the affected service packages
  • managedkafka

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccManagedKafkaAcl_managedkafkaAclBasicExample
  • TestAccManagedKafkaAcl_update

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccManagedKafkaAcl_managedkafkaAclBasicExample [Debug log]
TestAccManagedKafkaAcl_update [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccManagedKafkaAcl_managedkafkaAclBasicExample [Debug log]
TestAccManagedKafkaAcl_update [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccManagedKafkaAcl_managedkafkaAclBasicExample [Debug log]
TestAccManagedKafkaAcl_update [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccManagedKafkaAcl_managedkafkaAclBasicExample [Debug log]
TestAccManagedKafkaAcl_update [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

item_type:
type: NestedObject
properties:
- name: 'principal'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

required: true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To clarify: For an Array of NestedObject where the array must not be empty, should the required annotation go on the aclEntries array field, or within the item_type NestedObject part? (I'm thinking the former.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The former.

I would guess most of the nested fields should also have required on them as well. I'd guess if someone specifies a specific acl_entry it must have a principal, so principal should be required. Similar for any other fields that must be specified for an individual entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

I would guess most of the nested fields should also have required on them as well.

Agreed. I added required for the fields without default values in prior commit ddb99a2.

Comment thread mmv1/products/managedkafka/Acl.yaml
Comment thread mmv1/products/managedkafka/Acl.yaml
Comment thread mmv1/products/managedkafka/Acl.yaml
type: String
default_value: "*"
description: 'The host. Must be set to "*" for Managed Service for Apache Kafka.'
- name: 'etag'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be output_only unless there's a reason to specify etag within Terraform

Copy link
Copy Markdown
Contributor Author

@amfisher-404 amfisher-404 May 20, 2025

Choose a reason for hiding this comment

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

The issue is, the etag does need to be provided to the API in the ACL for future updates to succeed.

Test failure with etag as output_only:

resource_managed_kafka_acl_test.go:19: Step 3/4 error: Error running apply: exit status 1
        
        Error: Error updating Acl "projects/ci-test-project-188019/locations/us-central1/clusters/tf-test-my-cluster8wqckoe84a/acls/topic/tf-test-my-acl8wqckoe84a": googleapi: Error 400: The request was invalid: etag must be specified on UpdateAcl. Use GetAcl to get the current etag
        Details:
        [
          {
            "@type": "type.googleapis.com/google.rpc.BadRequest",
            "fieldViolations": [
              {
                "field": "etag"
              }
            ]
          },
          {
            "@type": "type.googleapis.com/google.rpc.RequestInfo",
            "requestId": "4b3e5414714372b5"
          }
        ]
        
          with google_managed_kafka_acl.example,
          on terraform_plugin_test.tf line 18, in resource "google_managed_kafka_acl" "example":
          18: resource "google_managed_kafka_acl" "example" {

This is why I had gone with default_from_api, so the API-provided value is persisted in future requests. However, IMO it doesn't make sense for tests to exercise the user providing this field. Is there some better alternative you'd propose?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the API not accept requests without the etag set? In general etag should be an optional request parameter: https://google.aip.dev/154

If it's required on purpose you may be able to mark the etag field as output: true and change the type to type: Fingerprint. I believe that adds the field to every request

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We've implemented the etag on the resource level (not the request level) as specified in AIP-154. The etag is only required on Update requests, to meet the need for consistency/concurrency control: https://screenshot.googleplex.com/8NobwFxUKjof6y3. As such, there are no REQUIRED field annotations on etag; the API will return INVALID_ARGUMENT if the etag in UpdateAcl is missing.

Thanks for the suggestion. Marking etag as output:true with type:Fingerprint achieves what we're after:

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccManagedKafkaAcl_managedkafkaAclBasicExample [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🔴 Tests failed during RECORDING mode:
TestAccManagedKafkaAcl_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@github-actions github-actions bot requested a review from slevenick May 20, 2025 15:24
@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1033 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1033 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 129 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 8
Skipped tests: 0
Affected tests: 1

Click here to see the affected service packages
  • managedkafka

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccManagedKafkaAcl_update

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccManagedKafkaAcl_update [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1055 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_managed_kafka_acl (3 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_managed_kafka_acl" "primary" {
  etag = # value needed
}

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 9
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • managedkafka

🟢 All tests passed!

View the build log

Comment thread mmv1/products/managedkafka/Acl.yaml Outdated
type: String
default_value: "*"
description: 'The host. Must be set to "*" for Managed Service for Apache Kafka.'
- name: 'etag'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the API not accept requests without the etag set? In general etag should be an optional request parameter: https://google.aip.dev/154

If it's required on purpose you may be able to mark the etag field as output: true and change the type to type: Fingerprint. I believe that adds the field to every request

@github-actions github-actions bot requested a review from slevenick May 21, 2025 21:44
Co-authored-by: Sam Levenick <slevenick@google.com>
@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1067 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1067 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 6 files changed, 1067 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1067 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 139 insertions(+))
Open in Cloud Shell: Diff ( 4 files changed, 137 insertions(+))

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 9
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • managedkafka
🟢 All tests passed!

View the build log

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 9
Passed tests: 9
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • managedkafka
🟢 All tests passed!

View the build log

Copy link
Copy Markdown
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.

Thanks!

@slevenick slevenick added this pull request to the merge queue May 21, 2025
Merged via the queue into GoogleCloudPlatform:main with commit 8fe07d5 May 21, 2025
27 checks passed
@amfisher-404 amfisher-404 deleted the gmk-acl branch May 21, 2025 22:29
NandiniAgrawal15 pushed a commit to NandiniAgrawal15/magic-modules that referenced this pull request Jun 5, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Jun 25, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Jun 25, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
jingqizz pushed a commit to jingqizz/magic-modules that referenced this pull request Jul 9, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Jul 28, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Jul 28, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Jul 28, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
BBBmau pushed a commit to BBBmau/magic-modules that referenced this pull request Jul 28, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
NandiniAgrawal15 pushed a commit to NandiniAgrawal15/magic-modules that referenced this pull request Sep 4, 2025
Co-authored-by: Sam Levenick <slevenick@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants