Skip to content

Commit

Permalink
bug: node template custom taints value should be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanstankovcast committed Nov 28, 2023
1 parent 4257187 commit b72e85e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 3 additions & 4 deletions castai/resource_node_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,9 @@ func resourceNodeTemplate() *schema.Resource {
Description: "Key of a taint to be added to nodes created from this template.",
},
FieldValue: {
Required: true,
Type: schema.TypeString,
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotWhiteSpace),
Description: "Value of a taint to be added to nodes created from this template.",
Optional: true,
Type: schema.TypeString,
Description: "Value of a taint to be added to nodes created from this template.",
},
FieldEffect: {
Optional: true,
Expand Down
20 changes: 17 additions & 3 deletions castai/resource_node_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) {
resourceName := "castai_node_template.test"
clusterName := "cost-terraform"

resource.ParallelTest(t, resource.TestCase{
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: testAccCheckNodeTemplateDestroy,
Expand All @@ -374,7 +374,7 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "custom_labels.%", "2"),
resource.TestCheckResourceAttr(resourceName, "custom_labels."+rName+"-label-key-1", rName+"-label-value-1"),
resource.TestCheckResourceAttr(resourceName, "custom_labels."+rName+"-label-key-2", rName+"-label-value-2"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.#", "3"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.#", "4"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.0.key", rName+"-taint-key-1"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.0.value", rName+"-taint-value-1"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.0.effect", "NoSchedule"),
Expand All @@ -384,6 +384,9 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "custom_taints.2.key", rName+"-taint-key-3"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.2.value", rName+"-taint-value-3"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.2.effect", "NoSchedule"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.3.key", rName+"-taint-key-4"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.3.value", ""),
resource.TestCheckResourceAttr(resourceName, "custom_taints.3.effect", "NoSchedule"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.instance_families.0.exclude.0", "m5"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.gpu.0.manufacturers.0", "NVIDIA"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.gpu.0.include_names.#", "0"),
Expand Down Expand Up @@ -423,9 +426,11 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "custom_labels.%", "2"),
resource.TestCheckResourceAttr(resourceName, "custom_labels."+rName+"-label-key-1", rName+"-label-value-1"),
resource.TestCheckResourceAttr(resourceName, "custom_labels."+rName+"-label-key-2", rName+"-label-value-2"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.#", "1"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.#", "2"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.0.key", rName+"-taint-key-1"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.0.value", rName+"-taint-value-1"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.1.key", rName+"-taint-key-2"),
resource.TestCheckResourceAttr(resourceName, "custom_taints.1.value", ""),
resource.TestCheckResourceAttr(resourceName, "constraints.0.use_spot_fallbacks", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.on_demand", "true"),
Expand Down Expand Up @@ -487,6 +492,10 @@ func testAccNodeTemplateConfig(rName, clusterName string) string {
value = "%[1]s-taint-value-3"
}
custom_taints {
key = "%[1]s-taint-key-4"
}
constraints {
fallback_restore_rate_seconds = 1800
spot = true
Expand Down Expand Up @@ -531,6 +540,11 @@ func testNodeTemplateUpdated(rName, clusterName string) string {
effect = "NoSchedule"
}
custom_taints {
key = "%[1]s-taint-key-2"
effect = "NoSchedule"
}
constraints {
use_spot_fallbacks = true
spot = true
Expand Down

0 comments on commit b72e85e

Please sign in to comment.