Skip to content

Commit

Permalink
container: fix in-place updates for node_config.containerd_config (#…
Browse files Browse the repository at this point in the history
…12135) (#20112)

[upstream:07118df4325b99355b62c9acdaeb95102dd935a2]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Oct 30, 2024
1 parent 9d94f22 commit aa28027
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 122 deletions.
3 changes: 3 additions & 0 deletions .changelog/12135.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: fixed in-place updates for `node_config.containerd_config` in `google_container_cluster` and `google_container_node_pool`
```
36 changes: 36 additions & 0 deletions google/services/container/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1863,6 +1863,42 @@ func nodePoolNodeConfigUpdate(d *schema.ResourceData, config *transport_tpg.Conf
}
}

if d.HasChange(prefix + "node_config.0.containerd_config") {
if _, ok := d.GetOk(prefix + "node_config.0.containerd_config"); ok {
req := &container.UpdateNodePoolRequest{
Name: name,
ContainerdConfig: expandContainerdConfig(d.Get(prefix + "node_config.0.containerd_config")),
}
if req.ContainerdConfig == nil {
req.ContainerdConfig = &container.ContainerdConfig{}
req.ForceSendFields = []string{"ContainerdConfig"}
}
updateF := func() error {
clusterNodePoolsUpdateCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.NodePools.Update(nodePoolInfo.fullyQualifiedName(name), req)
if config.UserProjectOverride {
clusterNodePoolsUpdateCall.Header().Add("X-Goog-User-Project", nodePoolInfo.project)
}
op, err := clusterNodePoolsUpdateCall.Do()
if err != nil {
return err
}

// Wait until it's updated
return ContainerOperationWait(config, op,
nodePoolInfo.project,
nodePoolInfo.location,
"updating GKE node pool containerd_config", userAgent,
timeout)
}

if err := retryWhileIncompatibleOperation(timeout, npLockKey, updateF); err != nil {
return err
}

log.Printf("[INFO] Updated containerd_config for node pool %s", name)
}
}

if d.HasChange("node_config.0.disk_size_gb") ||
d.HasChange("node_config.0.disk_type") ||
d.HasChange("node_config.0.machine_type") ||
Expand Down
Loading

0 comments on commit aa28027

Please sign in to comment.