Skip to content

Commit 31aa66e

Browse files
feat: deprecate autoscaler policies that were replaced by node templates (#504)
* feat: deprecate autoscaler policies that were replaced by node templates * Add deprecation information and remove deprecated fields usage from examples. * Generate docs, tf lint. * Refine the deprecation messages. * Add readme outlining the details of deprecated fields. --------- Co-authored-by: Witold Konior <witold@cast.ai>
1 parent 2d19db4 commit 31aa66e

File tree

7 files changed

+61
-59
lines changed

7 files changed

+61
-59
lines changed

README.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ Migrating from 3.x.x to 4.x.x
120120
Version 4.x.x changed:
121121
* `castai_eks_clusterid` type from data source to resource
122122
123-
Having old configuration:
123+
Having old configuration:
124124
125125
```terraform
126126
data "castai_eks_clusterid" "cluster_id" {
127127
account_id = data.aws_caller_identity.current.account_id
128128
region = var.cluster_region
129129
cluster_name = var.cluster_name
130-
}
130+
}
131131
```
132132
and usage `data.castai_eks_clusterid.cluster_id.id`
133133
@@ -144,7 +144,7 @@ and usage `castai_eks_clusterid.cluster_id.id`
144144
145145
* removal of `castai_cluster_token` resource in favour of `cluster_token` in `castai_eks_cluster`
146146
147-
Having old configuration:
147+
Having old configuration:
148148
```terraform
149149
resource "castai_cluster_token" "this" {
150150
cluster_id = castai_eks_cluster.this.id
@@ -154,7 +154,7 @@ resource "castai_eks_cluster" "this" {
154154
region = var.cluster_region
155155
name = var.cluster_name
156156
}
157-
157+
158158
```
159159
and usage `castai_cluster_token.this.cluster_token`
160160
@@ -375,7 +375,7 @@ Old configuration:
375375
```hcl
376376
resource "castai_autoscaler" "castai_autoscaler_policies" {
377377
cluster_id = data.castai_eks_clusterid.cluster_id.id // or other reference
378-
378+
379379
autoscaler_policies_json = <<-EOT
380380
{
381381
"enabled": true,
@@ -441,7 +441,7 @@ resource "castai_autoscaler" "castai_autoscaler_policies" {
441441
442442
cluster_limits {
443443
enabled = true
444-
444+
445445
cpu {
446446
max_cores = 20
447447
min_cores = 1
@@ -458,6 +458,33 @@ https://github.com/castai/terraform-castai-eks-cluster/blob/main/README.md#migra
458458
If you have used `castai-gke-cluster` or other modules follow:
459459
https://github.com/castai/terraform-castai-gke-cluster/blob/main/README.md#migrating-from-4xx-to-5xx
460460
461+
Deprecations in `castai_autoscaler` (Introduced in v7.9.3)
462+
-------------------------------------------------------------------------------------------------
463+
464+
Starting with version `v7.9.3`, several fields within the `castai_autoscaler` resource (specifically under the `autoscaler_settings` block) have been deprecated.
465+
466+
These fields are planned for removal in a future major version. Users are encouraged to update their configurations to use the new recommended approaches to ensure compatibility and leverage the latest features. Most of these functionalities have been consolidated into the `castai_node_template` resource (default template) for a more unified approach to node configuration.
467+
468+
**Summary of Deprecated Fields and New Locations:**
469+
470+
1. **Headroom Configuration:**
471+
* **Deprecated:** `autoscaler_settings.headroom`, `autoscaler_settings.headroom_spot`. These configurations are deprecated. For managing cluster headroom, please refer to the CAST AI Autoscaler FAQ for recommended strategies, such as using low-priority placeholder deployments.
472+
* FAQ Link: [https://docs.cast.ai/docs/autoscaler-1#can-you-please-share-some-guidance-on-cluster-headroom-i-would-like-to-add-some-buffer-room-so-that-pods-have-a-place-to-run-when-nodes-go-down](https://docs.cast.ai/docs/autoscaler-1#can-you-please-share-some-guidance-on-cluster-headroom-i-would-like-to-add-some-buffer-room-so-that-pods-have-a-place-to-run-when-nodes-go-down)
473+
474+
2. **Node Constraints for Unschedulable Pods:**
475+
* **Deprecated:** `autoscaler_settings.unschedulable_pods.node_constraints` (including its fields like `min_cpu_cores`, `max_cpu_cores`, `min_ram_mib`, `max_ram_mib`). Use the `constraints` block (with fields like `min_cpu`, `max_cpu`, `min_memory`, `max_memory`) within the default `castai_node_template` resource.
476+
* **Deprecated:** `autoscaler_settings.unschedulable_pods.node_constraints.custom_instances_enabled`. Use the top-level `custom_instances_enabled` field in the default `castai_node_template` resource.
477+
478+
3. **Spot Instance Configuration:**
479+
* **Deprecated:** The entire `autoscaler_settings.spot_instances` block.
480+
* `spot_instances.enabled`: **New Location:** Use `constraints.spot` in the default `castai_node_template`.
481+
* `spot_instances.max_reclaim_rate`: **Note:** This field is deprecated and has no direct replacement in the node template. Setting it will have no effect.
482+
* `spot_instances.spot_backups`: **New Location:** Use `constraints.use_spot_fallbacks` and `constraints.fallback_restore_rate_seconds` in the default `castai_node_template`.
483+
* **Deprecated:** `autoscaler_settings.spot_diversity_enabled`. Use `constraints.enable_spot_diversity` in the default `castai_node_template`.
484+
* **Deprecated:** `autoscaler_settings.spot_diversity_price_increase_limit`. Use `constraints.spot_diversity_price_increase_limit_percent` in the default `castai_node_template`.
485+
486+
4. **Spot Interruption Predictions:**
487+
* **Deprecated:** `autoscaler_settings.spot_interruption_predictions` block. Use the top-level `spot_interruption_predictions_enabled` and `spot_interruption_predictions_type` fields in the default `castai_node_template` resource.
461488
462489
Developing the provider
463490
---------------------------

castai/resource_autoscaler.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func resourceAutoscaler() *schema.Resource {
141141
Optional: true,
142142
MaxItems: 1,
143143
Description: "additional headroom based on cluster's total available capacity for on-demand nodes.",
144+
Deprecated: "`headroom` is deprecated. Please refer to the FAQ for guidance on cluster headroom: https://docs.cast.ai/docs/autoscaler-1#can-you-please-share-some-guidance-on-cluster-headroom-i-would-like-to-add-some-buffer-room-so-that-pods-have-a-place-to-run-when-nodes-go-down",
144145
Elem: &schema.Resource{
145146
Schema: map[string]*schema.Schema{
146147
FieldCPUPercentage: {
@@ -171,6 +172,7 @@ func resourceAutoscaler() *schema.Resource {
171172
Optional: true,
172173
MaxItems: 1,
173174
Description: "additional headroom based on cluster's total available capacity for spot nodes.",
175+
Deprecated: "`headroom_spot` is deprecated. Please refer to the FAQ for guidance on cluster headroom: https://docs.cast.ai/docs/autoscaler-1#can-you-please-share-some-guidance-on-cluster-headroom-i-would-like-to-add-some-buffer-room-so-that-pods-have-a-place-to-run-when-nodes-go-down",
174176
Elem: &schema.Resource{
175177
Schema: map[string]*schema.Schema{
176178
FieldCPUPercentage: {
@@ -201,6 +203,7 @@ func resourceAutoscaler() *schema.Resource {
201203
Optional: true,
202204
MaxItems: 1,
203205
Description: "defines the node constraints that will be applied when autoscaling with Unschedulable Pods policy.",
206+
Deprecated: "`node_constraints` under `unschedulable_pods` is deprecated. Use the `constraints` field in the default `castai_node_template` resource instead. The default node template has `is_default = true`.",
204207
Elem: &schema.Resource{
205208
Schema: map[string]*schema.Schema{
206209
FieldMinCPUCores: {
@@ -256,7 +259,7 @@ func resourceAutoscaler() *schema.Resource {
256259
Type: schema.TypeBool,
257260
Optional: true,
258261
Default: false,
259-
Deprecated: "customInstancesEnabled is deprecated. Use custom_instances_enabled field the node template resource.",
262+
Deprecated: "`custom_instances_enabled` under `unschedulable_pods.node_constraints` is deprecated. Use the `custom_instances_enabled` field in the default `castai_node_template` resource instead. The default node template has `is_default = true`.",
260263
Description: "enable/disable custom instances policy.",
261264
},
262265
},
@@ -307,24 +310,28 @@ func resourceAutoscaler() *schema.Resource {
307310
Optional: true,
308311
MaxItems: 1,
309312
Description: "policy defining whether autoscaler can use spot instances for provisioning additional workloads.",
313+
Deprecated: "`spot_instances` is deprecated. Configure spot instance settings using the `constraints` field in the default `castai_node_template` resource. The default node template has `is_default = true`.",
310314
Elem: &schema.Resource{
311315
Schema: map[string]*schema.Schema{
312316
FieldEnabled: {
313317
Type: schema.TypeBool,
314318
Optional: true,
315319
Default: false,
320+
Deprecated: "`enabled` under `spot_instances` is deprecated. To enable spot instances, set `constraints.spot = true` in the default `castai_node_template` resource. The default node template has `is_default = true`.",
316321
Description: "enable/disable spot instances policy.",
317322
},
318323
FieldMaxReclaimRate: {
319324
Type: schema.TypeInt,
320325
Optional: true,
321326
Default: 0,
327+
Deprecated: "`max_reclaim_rate` under `spot_instances` is deprecated. This field has no direct equivalent in the `castai_node_template` resource, and setting it will have no effect.",
322328
Description: "max allowed reclaim rate when choosing spot instance type. E.g. if the value is 10%, instance types having 10% or higher reclaim rate will not be considered. Set to zero to use all instance types regardless of reclaim rate.",
323329
},
324330
FieldSpotBackups: {
325331
Type: schema.TypeList,
326332
Optional: true,
327333
MaxItems: 1,
334+
Deprecated: "`spot_backups` under `spot_instances` is deprecated. Configure spot backup behavior using `constraints.use_spot_fallbacks` and `constraints.fallback_restore_rate_seconds` in the default `castai_node_template` resource. The default node template has `is_default = true`.",
328335
Description: "policy defining whether autoscaler can use spot backups instead of spot instances when spot instances are not available.",
329336
Elem: &schema.Resource{
330337
Schema: map[string]*schema.Schema{
@@ -348,12 +355,14 @@ func resourceAutoscaler() *schema.Resource {
348355
Type: schema.TypeBool,
349356
Optional: true,
350357
Default: false,
358+
Deprecated: "`spot_diversity_enabled` is deprecated. Use the `enable_spot_diversity` field within `castai_node_template.constraints` in the default `castai_node_template` resource. The default node template has `is_default = true`.",
351359
Description: "enable/disable spot diversity policy. When enabled, autoscaler will try to balance between diverse and cost optimal instance types.",
352360
},
353361
FieldSpotDiversityPriceIncreaseLimit: {
354362
Type: schema.TypeInt,
355363
Optional: true,
356364
Default: 20,
365+
Deprecated: "`spot_diversity_price_increase_limit` is deprecated. Use `spot_diversity_price_increase_limit_percent` within `castai_node_template.constraints` in the default `castai_node_template` resource. The default node template has `is_default = true`.",
357366
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.",
358367
ValidateDiagFunc: validation.ToDiagFunc(validation.IntAtLeast(1)),
359368
},
@@ -362,6 +371,7 @@ func resourceAutoscaler() *schema.Resource {
362371
Optional: true,
363372
MaxItems: 1,
364373
Description: "configure the handling of SPOT interruption predictions.",
374+
Deprecated: "`spot_interruption_predictions` is deprecated. Use the `spot_interruption_predictions_enabled` and `spot_interruption_predictions_type` fields in the default `castai_node_template` resource. The default node template has `is_default = true`.",
365375
Elem: &schema.Resource{
366376
Schema: map[string]*schema.Schema{
367377
FieldEnabled: {

docs/resources/autoscaler.md

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

examples/aks/aks_cluster_arm_template/castai.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,6 @@ module "castai-aks-cluster" {
114114

115115
unschedulable_pods = {
116116
enabled = true
117-
118-
headroom = {
119-
enabled = true
120-
cpu_percentage = 10
121-
memory_percentage = 10
122-
}
123-
124-
headroom_spot = {
125-
enabled = true
126-
cpu_percentage = 10
127-
memory_percentage = 10
128-
}
129117
}
130118

131119
node_downscaler = {

examples/aks/aks_cluster_autoscaler_policies/castai.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,6 @@ module "castai-aks-cluster" {
130130

131131
unschedulable_pods = {
132132
enabled = true
133-
134-
headroom = {
135-
enabled = true
136-
cpu_percentage = 10
137-
memory_percentage = 10
138-
}
139-
140-
headroom_spot = {
141-
enabled = true
142-
cpu_percentage = 10
143-
memory_percentage = 10
144-
}
145133
}
146134

147135
node_downscaler = {

examples/eks/eks_cluster_autoscaler_policies/castai.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,6 @@ module "castai-eks-cluster" {
182182

183183
unschedulable_pods = {
184184
enabled = true
185-
186-
headroom = {
187-
enabled = true
188-
cpu_percentage = 10
189-
memory_percentage = 10
190-
}
191-
192-
headroom_spot = {
193-
enabled = true
194-
cpu_percentage = 10
195-
memory_percentage = 10
196-
}
197185
}
198186

199187
node_downscaler = {

examples/gke/gke_cluster_gitops/castai.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ resource "castai_node_template" "default_by_castai" {
3939
constraints {
4040
on_demand = true
4141
}
42+
43+
custom_instances_enabled = false
4244
}
4345

4446
resource "castai_node_template" "example_spot_template" {
4547
cluster_id = castai_gke_cluster.this.id
4648

47-
name = "example_spot_template"
48-
is_default = false
49-
is_enabled = true
50-
configuration_id = castai_node_configuration.default.id
51-
should_taint = true
52-
custom_instances_enabled = false # custom_instances_enabled should be set to same value(true or false) at Node templates & unschedulable_pods policy for backward compatability
49+
name = "example_spot_template"
50+
is_default = false
51+
is_enabled = true
52+
configuration_id = castai_node_configuration.default.id
53+
should_taint = true
5354

5455
custom_labels = {
5556
type = "spot"

0 commit comments

Comments
 (0)