Skip to content

Commit 837fff1

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 76bd958 commit 837fff1

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

.changelog/12877.txt

Lines changed: 3 additions & 0 deletions
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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,11 @@ func schemaNodeConfig() *schema.Schema {
237237
},
238238

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

246247
"local_ssd_count": {
@@ -1720,6 +1721,21 @@ func containerNodePoolLabelsSuppress(k, old, new string, d *schema.ResourceData)
17201721
return true
17211722
}
17221723

1724+
func containerNodePoolResourceLabelsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
1725+
// Suppress diffs for server-specified labels prefixed with "goog-gke"
1726+
if strings.Contains(k, "resource_labels.goog-gke") && new == "" {
1727+
return true
1728+
}
1729+
1730+
// Let diff be determined by resource_labels (above)
1731+
if strings.Contains(k, "resource_labels.%") {
1732+
return true
1733+
}
1734+
1735+
// For other keys, don't suppress diff.
1736+
return false
1737+
}
1738+
17231739
func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface{} {
17241740
result := []map[string]interface{}{}
17251741
if c != nil {

0 commit comments

Comments
 (0)