allow min node counts of 0 for node pool autoscaling (#468)

This commit is contained in:
Dana Hoffman 2017-09-26 15:57:51 -07:00 committed by GitHub
parent 5874819e21
commit 617ad7362b
2 changed files with 12 additions and 5 deletions

View File

@ -76,7 +76,7 @@ func resourceContainerNodePool() *schema.Resource {
"min_node_count": &schema.Schema{ "min_node_count": &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ValidateFunc: validation.IntAtLeast(1), ValidateFunc: validation.IntAtLeast(0),
}, },
"max_node_count": &schema.Schema{ "max_node_count": &schema.Schema{
@ -127,6 +127,7 @@ func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) e
Enabled: true, Enabled: true,
MinNodeCount: int64(autoscaling["min_node_count"].(int)), MinNodeCount: int64(autoscaling["min_node_count"].(int)),
MaxNodeCount: int64(autoscaling["max_node_count"].(int)), MaxNodeCount: int64(autoscaling["max_node_count"].(int)),
ForceSendFields: []string{"MinNodeCount"},
} }
} }

View File

@ -77,18 +77,24 @@ func TestAccContainerNodePool_autoscaling(t *testing.T) {
Config: testAccContainerNodePool_autoscaling(cluster, np), Config: testAccContainerNodePool_autoscaling(cluster, np),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"), testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.min_node_count", "1"),
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.max_node_count", "3"),
), ),
}, },
resource.TestStep{ resource.TestStep{
Config: testAccContainerNodePool_updateAutoscaling(cluster, np), Config: testAccContainerNodePool_updateAutoscaling(cluster, np),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"), testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.min_node_count", "0"),
resource.TestCheckResourceAttr("google_container_node_pool.np", "autoscaling.0.max_node_count", "5"),
), ),
}, },
resource.TestStep{ resource.TestStep{
Config: testAccContainerNodePool_basic(cluster, np), Config: testAccContainerNodePool_basic(cluster, np),
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckContainerNodePoolMatches("google_container_node_pool.np"), testAccCheckContainerNodePoolMatches("google_container_node_pool.np"),
resource.TestCheckNoResourceAttr("google_container_node_pool.np", "autoscaling.0.min_node_count"),
resource.TestCheckNoResourceAttr("google_container_node_pool.np", "autoscaling.0.max_node_count"),
), ),
}, },
}, },
@ -249,7 +255,7 @@ resource "google_container_node_pool" "np" {
cluster = "${google_container_cluster.cluster.name}" cluster = "${google_container_cluster.cluster.name}"
initial_node_count = 2 initial_node_count = 2
autoscaling { autoscaling {
min_node_count = 1 min_node_count = 0
max_node_count = 5 max_node_count = 5
} }
}`, cluster, np) }`, cluster, np)