Skip to content

Commit

Permalink
CO-2314: Remove default values for new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jansyk13 committed Aug 1, 2023
1 parent 798da15 commit 8c58ef1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 5 additions & 3 deletions castai/resource_node_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func resourceNodeTemplate() *schema.Resource {
},
FieldNodeTemplateOnDemand: {
Type: schema.TypeBool,
Default: false,
Optional: true,
Computed: true,
Description: "Should include on-demand instances in the considered pool.",
},
FieldNodeTemplateUseSpotFallbacks: {
Expand All @@ -147,7 +147,6 @@ func resourceNodeTemplate() *schema.Resource {
},
FieldNodeTemplateSpotDiversityPriceIncreaseLimitPercent: {
Type: schema.TypeInt,
Default: 20,
Optional: true,
Description: "Allowed node configuration price increase when diversifying instance types. E.g. if the value is 10%, then the overall price of diversified instance types can be 10% higher than the price of the optimal configuration.",
},
Expand All @@ -159,7 +158,6 @@ func resourceNodeTemplate() *schema.Resource {
},
FieldNodeTemplateSpotInterruptionPredictionsType: {
Type: schema.TypeString,
Default: "aws-rebalance-recommendations",
Optional: true,
Description: "Spot interruption predictions type. Can be either \"aws-rebalance-recommendations\" or \"interruption-predictions\".",
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"aws-rebalance-recommendations", "interruption-predictions"}, false)),
Expand Down Expand Up @@ -882,6 +880,10 @@ func toTemplateConstraints(obj map[string]any) *sdk.NodetemplatesV1TemplateConst
}
if v, ok := obj[FieldNodeTemplateOnDemand].(bool); ok {
out.OnDemand = toPtr(v)
} else {
if v, ok := obj[FieldNodeTemplateSpot].(bool); ok {
out.Spot = toPtr(!v)
}
}
if v, ok := obj[FieldNodeTemplateStorageOptimized].(bool); ok {
out.StorageOptimized = toPtr(v)
Expand Down
6 changes: 2 additions & 4 deletions castai/resource_node_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "constraints.0.max_cpu", "100"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.use_spot_fallbacks", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.on_demand", "false"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.architectures.#", "1"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.architectures.0", "amd64"),
resource.TestCheckResourceAttr(resourceName, "is_default", "false"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.on_demand", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.enable_spot_diversity", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot_diversity_price_increase_limit_percent", "21"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot_interruption_predictions_enabled", "true"),
Expand Down Expand Up @@ -278,18 +278,17 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "custom_taints.0.value", "custom-taint-value-1"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.use_spot_fallbacks", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.on_demand", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.instance_families.#", "0"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.gpu.0.manufacturers.#", "0"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.gpu.0.include_names.#", "0"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.gpu.0.exclude_names.#", "0"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.min_cpu", "0"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.max_cpu", "0"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.use_spot_fallbacks", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.architectures.#", "1"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.architectures.0", "arm64"),
resource.TestCheckResourceAttr(resourceName, "is_default", "false"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.on_demand", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.enable_spot_diversity", "true"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot_diversity_price_increase_limit_percent", "22"),
resource.TestCheckResourceAttr(resourceName, "constraints.0.spot_interruption_predictions_enabled", "true"),
Expand Down Expand Up @@ -334,7 +333,6 @@ func testAccNodeTemplateConfig(rName, clusterName string) string {
constraints {
fallback_restore_rate_seconds = 1800
spot = true
on_demand = true
enable_spot_diversity = true
spot_diversity_price_increase_limit_percent = 21
spot_interruption_predictions_enabled = true
Expand Down

0 comments on commit 8c58ef1

Please sign in to comment.