Skip to content

Commit 3281b86

Browse files
modular-magicianslevenick
authored andcommitted
Add DSF on resource_labels in node_config (#12877) (#9171)
[upstream:8e47ba07a90f6b6aa3376fda0fcd7529e99a529b] Signed-off-by: Modular Magician <[email protected]>
1 parent 5e0c5c1 commit 3281b86

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

.changelog/12877.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
container: fixed a diff caused by server-side set values for `node_config.resource_labels`
3+
```

google-beta/services/container/node_config.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,11 @@ func schemaNodeConfig() *schema.Schema {
235235
},
236236

237237
"resource_labels": {
238-
Type: schema.TypeMap,
239-
Optional: true,
240-
Elem: &schema.Schema{Type: schema.TypeString},
241-
Description: `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.`,
238+
Type: schema.TypeMap,
239+
Optional: true,
240+
Elem: &schema.Schema{Type: schema.TypeString},
241+
DiffSuppressFunc: containerNodePoolResourceLabelsDiffSuppress,
242+
Description: `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.`,
242243
},
243244

244245
"local_ssd_count": {
@@ -1832,6 +1833,21 @@ func containerNodePoolLabelsSuppress(k, old, new string, d *schema.ResourceData)
18321833
return true
18331834
}
18341835

1836+
func containerNodePoolResourceLabelsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
1837+
// Suppress diffs for server-specified labels prefixed with "goog-gke"
1838+
if strings.Contains(k, "resource_labels.goog-gke") && new == "" {
1839+
return true
1840+
}
1841+
1842+
// Let diff be determined by resource_labels (above)
1843+
if strings.Contains(k, "resource_labels.%") {
1844+
return true
1845+
}
1846+
1847+
// For other keys, don't suppress diff.
1848+
return false
1849+
}
1850+
18351851
func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface{} {
18361852
result := []map[string]interface{}{}
18371853
if c != nil {

0 commit comments

Comments
 (0)