Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: node template custom taints value should be optional #246

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 16 additions & 2 deletions castai/resource_node_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/resources/node_template.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading