Skip to content

Commit

Permalink
Add DSF on resource_labels in node_config (#12877) (#9171)
Browse files Browse the repository at this point in the history
[upstream:8e47ba07a90f6b6aa3376fda0fcd7529e99a529b]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 28, 2025
1 parent 1993ca0 commit c5062b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/12877.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: fixed a diff caused by server-side set values for `node_config.resource_labels`
```
24 changes: 20 additions & 4 deletions google-beta/services/container/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,11 @@ func schemaNodeConfig() *schema.Schema {
},

"resource_labels": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Description: `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.`,
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
DiffSuppressFunc: containerNodePoolResourceLabelsDiffSuppress,
Description: `The GCE resource labels (a map of key/value pairs) to be applied to the node pool.`,
},

"local_ssd_count": {
Expand Down Expand Up @@ -1843,6 +1844,21 @@ func containerNodePoolLabelsSuppress(k, old, new string, d *schema.ResourceData)
return true
}

func containerNodePoolResourceLabelsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
// Suppress diffs for server-specified labels prefixed with "goog-gke"
if strings.Contains(k, "resource_labels.goog-gke") && new == "" {
return true
}

// Let diff be determined by resource_labels (above)
if strings.Contains(k, "resource_labels.%") {
return true
}

// For other keys, don't suppress diff.
return false
}

func flattenKubeletConfig(c *container.NodeKubeletConfig) []map[string]interface{} {
result := []map[string]interface{}{}
if c != nil {
Expand Down

0 comments on commit c5062b7

Please sign in to comment.