Skip to content

Commit

Permalink
max_pods_per_node is GA now. (#2429)
Browse files Browse the repository at this point in the history
Merged PR #2429.
  • Loading branch information
nat-henderson authored and modular-magician committed Oct 8, 2019
1 parent 253783c commit 6fde5d4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 55 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
24 changes: 11 additions & 13 deletions third_party/terraform/resources/resource_container_cluster.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,13 @@ func resourceContainerCluster() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
},

"default_max_pods_per_node": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Computed: true,
},

<% unless version == 'ga' -%>
"vertical_pod_autoscaling": {
Type: schema.TypeList,
Expand Down Expand Up @@ -745,13 +752,6 @@ func resourceContainerCluster() *schema.Resource {
Type: schema.TypeString,
},

"default_max_pods_per_node": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Computed: true,
},

"database_encryption": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -961,11 +961,9 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er
ResourceLabels: expandStringMap(d, "resource_labels"),
}

<% unless version == 'ga' -%>
if v, ok := d.GetOk("default_max_pods_per_node"); ok {
cluster.DefaultMaxPodsConstraint = expandDefaultMaxPodsConstraint(v)
}
<% end -%>

// Only allow setting node_version on create if it's set to the equivalent master version,
// since `InitialClusterVersion` only accepts valid master-style versions.
Expand Down Expand Up @@ -1208,9 +1206,6 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
if err := d.Set("cluster_autoscaling", flattenClusterAutoscaling(cluster.Autoscaling)); err != nil {
return err
}
if cluster.DefaultMaxPodsConstraint != nil {
d.Set("default_max_pods_per_node", cluster.DefaultMaxPodsConstraint.MaxPodsPerNode)
}
if err := d.Set("authenticator_groups_config", flattenAuthenticatorGroupsConfig(cluster.AuthenticatorGroupsConfig)); err != nil {
return err
}
Expand All @@ -1220,6 +1215,9 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
return err
}
<% end -%>
if cluster.DefaultMaxPodsConstraint != nil {
d.Set("default_max_pods_per_node", cluster.DefaultMaxPodsConstraint.MaxPodsPerNode)
}
if err := d.Set("node_config", flattenNodeConfig(cluster.NodeConfig)); err != nil {
return err
}
Expand Down Expand Up @@ -2385,7 +2383,6 @@ func expandPodSecurityPolicyConfig(configured interface{}) *containerBeta.PodSec
<% end -%>
}

<% unless version == 'ga' -%>
func expandDefaultMaxPodsConstraint(v interface{}) *containerBeta.MaxPodsConstraint {
if v == nil {
return nil
Expand All @@ -2396,6 +2393,7 @@ func expandDefaultMaxPodsConstraint(v interface{}) *containerBeta.MaxPodsConstra
}
}

<% unless version == 'ga' -%>
func expandResourceUsageExportConfig(configured interface{}) *containerBeta.ResourceUsageExportConfig {
l := configured.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ var schemaNodePool = map[string]*schema.Schema{
},

"max_pods_per_node": &schema.Schema{
<% if version.nil? || version == 'ga' -%>
Removed: "This field is in beta. Use it in the the google-beta provider instead. See https://terraform.io/docs/providers/google/provider_versions.html for more details.",
<% end -%>
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Expand Down Expand Up @@ -516,13 +513,11 @@ func expandNodePool(d *schema.ResourceData, prefix string) (*containerBeta.NodeP
}
}

<% unless version == 'ga' -%>
if v, ok := d.GetOk(prefix + "max_pods_per_node"); ok {
np.MaxPodsConstraint = &containerBeta.MaxPodsConstraint{
MaxPodsPerNode: int64(v.(int)),
}
}
<% end -%>

if v, ok := d.GetOk(prefix + "management"); ok {
managementConfig := v.([]interface{})[0].(map[string]interface{})
Expand Down Expand Up @@ -583,11 +578,9 @@ func flattenNodePool(d *schema.ResourceData, config *Config, np *containerBeta.N
}
}

<% unless version == 'ga' -%>
if np.MaxPodsConstraint != nil {
nodePool["max_pods_per_node"] = np.MaxPodsConstraint.MaxPodsPerNode
}
<% end -%>

nodePool["management"] = []map[string]interface{}{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func TestAccContainerNodePool_basic(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand All @@ -53,14 +52,12 @@ func TestAccContainerNodePool_nodeLocations(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
}
<% end -%>

<% unless version == 'ga' -%>
func TestAccContainerNodePool_maxPodsPerNode(t *testing.T) {
t.Parallel()

Expand All @@ -79,12 +76,10 @@ func TestAccContainerNodePool_maxPodsPerNode(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
}
<% end -%>

func TestAccContainerNodePool_namePrefix(t *testing.T) {
t.Parallel()
Expand All @@ -103,7 +98,7 @@ func TestAccContainerNodePool_namePrefix(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"name_prefix", "max_pods_per_node"},
ImportStateVerifyIgnore: []string{"name_prefix"},
},
},
})
Expand All @@ -126,7 +121,6 @@ func TestAccContainerNodePool_noName(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand All @@ -152,7 +146,7 @@ func TestAccContainerNodePool_withNodeConfig(t *testing.T) {
ImportStateVerify: true,
// autoscaling.# = 0 is equivalent to no autoscaling at all,
// but will still cause an import diff
ImportStateVerifyIgnore: []string{"autoscaling.#", "max_pods_per_node"},
ImportStateVerifyIgnore: []string{"autoscaling.#"},
},
resource.TestStep{
Config: testAccContainerNodePool_withNodeConfigUpdate(cluster, nodePool),
Expand All @@ -163,7 +157,7 @@ func TestAccContainerNodePool_withNodeConfig(t *testing.T) {
ImportStateVerify: true,
// autoscaling.# = 0 is equivalent to no autoscaling at all,
// but will still cause an import diff
ImportStateVerifyIgnore: []string{"autoscaling.#", "max_pods_per_node"},
ImportStateVerifyIgnore: []string{"autoscaling.#"},
},
},
})
Expand All @@ -190,7 +184,7 @@ func TestAccContainerNodePool_withNodeConfigTaints(t *testing.T) {
ImportStateVerify: true,
// autoscaling.# = 0 is equivalent to no autoscaling at all,
// but will still cause an import diff
ImportStateVerifyIgnore: []string{"autoscaling.#", "max_pods_per_node"},
ImportStateVerifyIgnore: []string{"autoscaling.#"},
},
// Once taints are in GA, consider merging this test with the _withNodeConfig test.
},
Expand Down Expand Up @@ -222,7 +216,6 @@ func TestAccContainerNodePool_withWorkloadMetadataConfig(t *testing.T) {
ImportStateVerifyIgnore: []string{
"node_config.0.workload_metadata_config.#",
"node_config.0.workload_metadata_config.0.node_metadata",
"max_pods_per_node",
},
},
},
Expand Down Expand Up @@ -295,7 +288,6 @@ func TestAccContainerNodePool_withGPU(t *testing.T) {
ResourceName: "google_container_node_pool.np_with_gpu",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand Down Expand Up @@ -332,7 +324,6 @@ func TestAccContainerNodePool_withManagement(t *testing.T) {
ResourceName: "google_container_node_pool.np_with_management",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
resource.TestStep{
Config: testAccContainerNodePool_withManagement(cluster, nodePool, management),
Expand All @@ -349,7 +340,6 @@ func TestAccContainerNodePool_withManagement(t *testing.T) {
ResourceName: "google_container_node_pool.np_with_management",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand All @@ -370,7 +360,6 @@ func TestAccContainerNodePool_withNodeConfigScopeAlias(t *testing.T) {
ResourceName: "google_container_node_pool.np_with_node_config_scope_alias",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand Down Expand Up @@ -399,7 +388,6 @@ func TestAccContainerNodePool_regionalAutoscaling(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
resource.TestStep{
Config: testAccContainerNodePool_updateAutoscaling(cluster, np),
Expand All @@ -412,7 +400,6 @@ func TestAccContainerNodePool_regionalAutoscaling(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
resource.TestStep{
Config: testAccContainerNodePool_basic(cluster, np),
Expand All @@ -427,7 +414,7 @@ func TestAccContainerNodePool_regionalAutoscaling(t *testing.T) {
ImportStateVerify: true,
// autoscaling.# = 0 is equivalent to no autoscaling at all,
// but will still cause an import diff
ImportStateVerifyIgnore: []string{"autoscaling.#", "max_pods_per_node"},
ImportStateVerifyIgnore: []string{"autoscaling.#"},
},
},
})
Expand Down Expand Up @@ -455,7 +442,6 @@ func TestAccContainerNodePool_autoscaling(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
resource.TestStep{
Config: testAccContainerNodePool_updateAutoscaling(cluster, np),
Expand All @@ -468,7 +454,6 @@ func TestAccContainerNodePool_autoscaling(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
resource.TestStep{
Config: testAccContainerNodePool_basic(cluster, np),
Expand All @@ -483,7 +468,7 @@ func TestAccContainerNodePool_autoscaling(t *testing.T) {
ImportStateVerify: true,
// autoscaling.# = 0 is equivalent to no autoscaling at all,
// but will still cause an import diff
ImportStateVerifyIgnore: []string{"autoscaling.#", "max_pods_per_node"},
ImportStateVerifyIgnore: []string{"autoscaling.#"},
},
},
})
Expand All @@ -510,7 +495,6 @@ func TestAccContainerNodePool_resize(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
{
Config: testAccContainerNodePool_resize(cluster, np),
Expand All @@ -522,7 +506,6 @@ func TestAccContainerNodePool_resize(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand All @@ -546,7 +529,6 @@ func TestAccContainerNodePool_version(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
{
Config: testAccContainerNodePool_updateVersion(cluster, np),
Expand All @@ -555,7 +537,6 @@ func TestAccContainerNodePool_version(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
{
Config: testAccContainerNodePool_version(cluster, np),
Expand All @@ -564,7 +545,6 @@ func TestAccContainerNodePool_version(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand All @@ -588,7 +568,6 @@ func TestAccContainerNodePool_regionalClusters(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand All @@ -612,7 +591,6 @@ func TestAccContainerNodePool_012_ConfigModeAttr(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
{
Config: testAccContainerNodePool_012_ConfigModeAttr2(cluster, np),
Expand All @@ -621,7 +599,6 @@ func TestAccContainerNodePool_012_ConfigModeAttr(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
},
})
Expand All @@ -646,7 +623,6 @@ func TestAccContainerNodePool_EmptyGuestAccelerator(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
{
// Test alternative way to specify an empty node pool
Expand All @@ -656,7 +632,6 @@ func TestAccContainerNodePool_EmptyGuestAccelerator(t *testing.T) {
ResourceName: "google_container_node_pool.np",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"max_pods_per_node"},
},
{
// Assert that changes in count from 1 result in a diff
Expand Down Expand Up @@ -782,7 +757,6 @@ resource "google_container_node_pool" "np" {
}
<% end -%>

<% unless version == 'ga' -%>
func testAccContainerNodePool_maxPodsPerNode(cluster, np string) string {
return fmt.Sprintf(`
resource "google_compute_network" "container_network" {
Expand Down Expand Up @@ -838,7 +812,6 @@ resource "google_container_node_pool" "np" {
initial_node_count = 2
}`, cluster, cluster, np)
}
<% end -%>

func testAccContainerNodePool_regionalClusters(cluster, np string) string {
return fmt.Sprintf(`
Expand Down

0 comments on commit 6fde5d4

Please sign in to comment.