Skip to content

Commit

Permalink
fix permadiff thrashing (#6908) (#13171)
Browse files Browse the repository at this point in the history
Co-authored-by: Edward Sun <sunedward@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun committed Dec 5, 2022
1 parent a381116 commit 8ccdc21
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/6908.txt
@@ -0,0 +1,3 @@
```release-note:bug
container: fixed GKE permadiff/thrashing when `update_settings. max_surge` or `update_settings. max_unavailable` values are updating on `google_container_node_pool`
```
8 changes: 8 additions & 0 deletions google/resource_container_node_pool.go
Expand Up @@ -1474,6 +1474,10 @@ func nodePoolUpdate(d *schema.ResourceData, meta interface{}, nodePoolInfo *Node
if v, ok := upgradeSettingsConfig["max_surge"]; ok {
upgradeSettings.MaxSurge = int64(v.(int))
}
// max_unavailable not be preserved if only max_surge is updated
if v, ok := upgradeSettingsConfig["max_unavailable"]; ok {
upgradeSettings.MaxUnavailable = int64(v.(int))
}
}

if d.HasChange(prefix + "upgrade_settings.0.max_unavailable") {
Expand All @@ -1483,6 +1487,10 @@ func nodePoolUpdate(d *schema.ResourceData, meta interface{}, nodePoolInfo *Node
if v, ok := upgradeSettingsConfig["max_unavailable"]; ok {
upgradeSettings.MaxUnavailable = int64(v.(int))
}
// max_surge not be preserved if only max_unavailable is updated
if v, ok := upgradeSettingsConfig["max_surge"]; ok {
upgradeSettings.MaxSurge = int64(v.(int))
}
}

if d.HasChange(prefix + "upgrade_settings.0.blue_green_settings") {
Expand Down
8 changes: 8 additions & 0 deletions google/resource_container_node_pool_test.go
Expand Up @@ -475,6 +475,14 @@ func TestAccContainerNodePool_withUpgradeSettings(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccContainerNodePool_withUpgradeSettings(cluster, np, 2, 1, "SURGE", "", 0, 0.0, ""),
},
{
ResourceName: "google_container_node_pool.with_upgrade_settings",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccContainerNodePool_withUpgradeSettings(cluster, np, 1, 1, "SURGE", "", 0, 0.0, ""),
},
Expand Down

0 comments on commit 8ccdc21

Please sign in to comment.