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

Add DSF on resource_labels in node_config #9171

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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