Skip to content

Commit e55c495

Browse files
authored
KUBE-1323: add OnHostMaintenance field to NC (#552)
1 parent ccc424a commit e55c495

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

castai/resource_node_configuration.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,13 @@ func resourceNodeConfiguration() *schema.Resource {
558558
},
559559
},
560560
},
561+
"on_host_maintenance": {
562+
Type: schema.TypeString,
563+
Optional: true,
564+
Default: nil,
565+
Description: "Maintenance behavior of the instances. If not set, the default value for spot nodes is terminate, and for non-spot nodes, it is migrate.",
566+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"migrate", "terminate"}, true)),
567+
},
561568
FieldNodeConfigurationLoadbalancers: {
562569
Type: schema.TypeList,
563570
Optional: true,
@@ -1496,6 +1503,10 @@ func toGKEConfig(obj map[string]interface{}) *sdk.NodeconfigV1GKEConfig {
14961503
}
14971504
}
14981505

1506+
if v, ok := obj["on_host_maintenance"].(string); ok && v != "" {
1507+
out.OnHostMaintenance = toPtr(sdk.NodeconfigV1GKEConfigOnHostMaintenance(v))
1508+
}
1509+
14991510
if v, ok := obj[FieldNodeConfigurationLoadbalancers].([]interface{}); ok && len(v) > 0 {
15001511
out.LoadBalancers = toGkeLoadBalancers(v)
15011512
}
@@ -1598,6 +1609,9 @@ func flattenGKEConfig(config *sdk.NodeconfigV1GKEConfig) []map[string]interface{
15981609
}
15991610
}
16001611

1612+
if v := config.OnHostMaintenance; v != nil {
1613+
m["on_host_maintenance"] = *v
1614+
}
16011615
if v := config.LoadBalancers; v != nil && len(*v) > 0 {
16021616
m[FieldNodeConfigurationLoadbalancers] = fromGkeLoadBalancers(*v)
16031617
}

castai/resource_node_configuration_gke_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestAccResourceNodeConfiguration_gke(t *testing.T) {
4141
resource.TestCheckResourceAttr(resourceName, "gke.0.network_tags.0", "ab"),
4242
resource.TestCheckResourceAttr(resourceName, "gke.0.network_tags.1", "bc"),
4343
resource.TestCheckResourceAttr(resourceName, "gke.0.zones.#", "0"),
44+
resource.TestCheckResourceAttr(resourceName, "gke.0.on_host_maintenance", "MIGRATE"),
4445
),
4546
},
4647
{
@@ -95,6 +96,7 @@ resource "castai_node_configuration" "test" {
9596
max_pods_per_node = 31
9697
network_tags = ["ab", "bc"]
9798
disk_type = "pd-balanced"
99+
on_host_maintenance = "MIGRATE"
98100
}
99101
}
100102

docs/resources/node_configuration.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)