INC-3971 Fix TF intermittent false diff detection issue #767
INC-3971 Fix TF intermittent false diff detection issue #767Cynthia Qin (cqin-confluent) wants to merge 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses an intermittent issue where Terraform falsely detects configuration diffs for confluent_kafka_topic resources, causing unnecessary in-place updates on existing topics that haven't been modified.
Key Changes
- Added a
DiffSuppressFuncto the topic config schema that suppresses diffs when configuration keys exist in the old state but are removed from the new configuration - Added comprehensive unit tests to verify the diff suppression logic works correctly
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/provider/resource_kafka_topic.go |
Added DiffSuppressFunc to config schema to prevent false positive diffs |
internal/provider/resource_kafka_topic_test.go |
Added unit tests to verify diff suppression behavior |
| return true | ||
| } | ||
|
|
||
| // when old value exists but new value is empty, check if key is in new config and suppress diff if not |
There was a problem hiding this comment.
The comment has inconsistent spacing and should end with a period for consistency: "// When old value exists but new value is empty, check if key is in new config and suppress diff if not."
| // when old value exists but new value is empty, check if key is in new config and suppress diff if not | |
| // When old value exists but new value is empty, check if the key is in the new config and suppress the diff if not. |
| configKey = strings.TrimPrefix(k, "config.") | ||
| } | ||
|
|
||
| if newConfigs, ok := d.GetOk(paramConfigs); ok { |
There was a problem hiding this comment.
The logic should handle the case where d.GetOk(paramConfigs) returns false. Consider adding an explicit return statement or handling the else case to make the intention clearer.
Kostya Linou (linouk23)
left a comment
There was a problem hiding this comment.
Could you also attach the actual responses from the Kafka REST API? I’m curious why we can’t see topic settings with empty values in the first place.
Release Notes
New Features
Bug Fixes
confluent_kafka_topicresources configsExamples
Checklist
Test & Reviewsection below.Blast Radiussection below.What
This change fix the intermittent phantom issue of TF falsely detecting diffs in
confluent_kafka_topicresources configs on existing topics and prompt for in-place updates despite the topic haven't been modifiedBlast Radius
Confluent Cloud customer who are updating
confluent_kafka_topicresource config will be blocked.References
More context on the TF drift issue
INC-3971 channel
Test & Review