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

Fixes PermaDiff Issue in google_storage_transfer_job.aws_s3_data_source.aws_access_key field #12666

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

kautikdk
Copy link
Member

@kautikdk kautikdk commented Dec 30, 2024

Fixes permadiff issue in google_storage_transfer_job resource. Ticket: b/386174536

Cause: It appears that the issue is happening because of GetOkExists used to obtain value of aws_s3_data_source.aws_access_key in the flattener. GetOkExists checks for the presence of the value regardless of zero value of the field. So here, In this case, we are always getting zero value of the field aws_s3_data_source.aws_access_key which empty list, [], and true for it's existence even though it's not specified in the config.

Solution: We can use GetOk to obtain value of the field from the config. GetOk treats zero value as absent which is use case here like other TypeList field.

Alternative: Continue using GetOkExists and checking empty vs unset each time,

aws_access_key, exist := d.GetOkExists("transfer_spec.0.aws_s3_data_source.0.aws_access_key")
if !tpgresource.IsEmptyValue(reflect.ValueOf(aws_access_key)) && exist {
data["aws_access_key"] = flattenAwsAccessKeys(d)
}

As GetOkExists is deprecated, reference, and discouraged to use, I prefer GetOk and didn't see any problem with that as all the nested fields within aws_access_key are required. So there won't be a case of empty block(without any nested field specified) and we need to separate from unset nested fields.

Testing: Currently storagetransfer service lacks acceptance tests for third-party cloud providers so there is no way to add acceptance tests.

storagetransfer: fixed a permadiff with `transfer_spec.aws_s3_data_source.aws_access_key` in `google_storage_transfer_job`

Copy link

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

@zli82016, 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.

@github-actions github-actions bot requested a review from zli82016 December 30, 2024 10:07
@kautikdk kautikdk changed the title Fixes PermaDiff Issue Fixes PermaDiff Issue in google_storage_transfer_job.aws_s3_data_source.aws_access_key field Dec 30, 2024
@modular-magician
Copy link
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 ( 1 file changed, 1 insertion(+), 1 deletion(-))
google-beta provider: Diff ( 1 file changed, 1 insertion(+), 1 deletion(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 13
Passed tests: 13
Skipped tests: 0
Affected tests: 0

Click here to see the affected service packages
  • storagetransfer

🟢 All tests passed!

View the build log

@kautikdk kautikdk changed the title Fixes PermaDiff Issue in google_storage_transfer_job.aws_s3_data_source.aws_access_key field Fixes PermaDiff Issue in google_storage_transfer_job.aws_s3_data_source.aws_access_key field Dec 30, 2024
Copy link

github-actions bot commented Jan 2, 2025

@zli82016 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@zli82016
Copy link
Member

zli82016 commented Jan 2, 2025

Copy link
Member

@zli82016 zli82016 left a comment

Choose a reason for hiding this comment

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

Add a test

@kautikdk
Copy link
Member Author

kautikdk commented Jan 3, 2025

Actually we don't have tests for third party transfer service as it requires GCP setup for storing various 3p credentials. It's not done yet so the only option is manual testing as of now.

@github-actions github-actions bot requested a review from zli82016 January 3, 2025 09:15
@zli82016
Copy link
Member

zli82016 commented Jan 3, 2025

@kautikdk , do you mind testing if the previously fixed perma diffs in #10672 are still resolved ? Thanks.

Copy link

github-actions bot commented Jan 8, 2025

@zli82016 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@kautikdk
Copy link
Member Author

kautikdk commented Jan 8, 2025

Hi @zli82016, Shared testing logs internally.

Copy link
Member

@zli82016 zli82016 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

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