Skip to content

Commit 53aa068

Browse files
committed
Set spot to default (#610)
(cherry picked from commit cf1412e)
1 parent 5f76587 commit 53aa068

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

cli/cmd/lib_cluster_config.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,18 @@ func confirmClusterConfig(clusterConfig *clusterconfig.ClusterConfig, awsCreds *
163163
items = append(items, table.KV{K: clusterconfig.RegionUserFacingKey, V: clusterConfig.Region})
164164
items = append(items, table.KV{K: clusterconfig.BucketUserFacingKey, V: clusterConfig.Bucket})
165165

166-
items = append(items, table.KV{K: clusterconfig.SpotUserFacingKey, V: s.YesNo(clusterConfig.Spot != nil && *clusterConfig.Spot)})
167166
items = append(items, table.KV{K: clusterconfig.InstanceTypeUserFacingKey, V: *clusterConfig.InstanceType})
168167
items = append(items, table.KV{K: clusterconfig.MinInstancesUserFacingKey, V: *clusterConfig.MinInstances})
169168
items = append(items, table.KV{K: clusterconfig.MaxInstancesUserFacingKey, V: *clusterConfig.MaxInstances})
169+
170+
if clusterConfig.Spot != nil && *clusterConfig.Spot != *prevConfig.Spot {
171+
items = append(items, table.KV{K: clusterconfig.SpotUserFacingKey, V: s.YesNo(clusterConfig.Spot != nil && *clusterConfig.Spot)})
172+
items = append(items, table.KV{K: clusterconfig.InstanceDistributionUserFacingKey, V: clusterConfig.SpotConfig.InstanceDistribution})
173+
items = append(items, table.KV{K: clusterconfig.OnDemandBaseCapacityUserFacingKey, V: *clusterConfig.SpotConfig.OnDemandBaseCapacity})
174+
items = append(items, table.KV{K: clusterconfig.OnDemandPercentageAboveBaseCapacityUserFacingKey, V: *clusterConfig.SpotConfig.OnDemandPercentageAboveBaseCapacity})
175+
items = append(items, table.KV{K: clusterconfig.MaxPriceUserFacingKey, V: *clusterConfig.SpotConfig.MaxPrice})
176+
items = append(items, table.KV{K: clusterconfig.InstancePoolsUserFacingKey, V: *clusterConfig.SpotConfig.InstancePools})
177+
}
170178
if clusterConfig.InstanceVolumeSize != prevConfig.InstanceVolumeSize {
171179
items = append(items, table.KV{K: clusterconfig.InstanceVolumeSizeUserFacingKey, V: clusterConfig.InstanceVolumeSize})
172180
}

docs/cluster/config.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ cluster_name: cortex
4242
# whether to collect anonymous usage stats and error reports (default: true)
4343
telemetry: true
4444

45-
# whether to use spot instances in the cluster (default: true)
46-
spot: true
45+
# whether to use spot instances in the cluster (default: false)
46+
spot: false
4747

4848
spot_config:
4949
# additional instances with identical or better specs than the primary instance type (defaults to 2 instances sorted by price)
@@ -53,6 +53,7 @@ spot_config:
5353
on_demand_base_capacity: 0
5454

5555
# percentage of on demand instances to use after the on demand base capacity has been met [0, 100] (default: 1)
56+
# note: setting this to 0 may hinder cluster scale up when spot instances are not available
5657
on_demand_percentage_above_base_capacity: 1
5758

5859
# max price for instances (defaults to the on demand price of the primary instance type)

pkg/lib/clusterconfig/clusterconfig.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ var UserValidation = &cr.StructValidation{
111111
},
112112
},
113113
{
114-
StructField: "Spot",
115-
BoolPtrValidation: &cr.BoolPtrValidation{},
114+
StructField: "Spot",
115+
BoolPtrValidation: &cr.BoolPtrValidation{
116+
Default: pointer.Bool(false),
117+
},
116118
},
117119
{
118120
StructField: "SpotConfig",
@@ -562,17 +564,6 @@ func InstallPrompt(clusterConfig *ClusterConfig, awsAccessKeyID string, awsSecre
562564
Default: defaultBucket,
563565
},
564566
},
565-
{
566-
StructField: "Spot",
567-
PromptOpts: &prompt.Options{
568-
Prompt: "use spot instances (y/n)",
569-
DefaultStr: "y",
570-
},
571-
BoolPtrValidation: &cr.BoolPtrValidation{
572-
Required: true,
573-
StrToBool: map[string]bool{"y": true, "n": false},
574-
},
575-
},
576567
{
577568
StructField: "InstanceType",
578569
PromptOpts: &prompt.Options{
@@ -717,13 +708,13 @@ func (cc *ClusterConfig) UserFacingTable() []table.KV {
717708
items = append(items, table.KV{K: ClusterNameUserFacingKey, V: cc.ClusterName})
718709
items = append(items, table.KV{K: RegionUserFacingKey, V: *cc.Region})
719710
items = append(items, table.KV{K: BucketUserFacingKey, V: *cc.Bucket})
720-
items = append(items, table.KV{K: SpotUserFacingKey, V: s.YesNo(*cc.Spot)})
721711
items = append(items, table.KV{K: InstanceTypeUserFacingKey, V: *cc.InstanceType})
722712
items = append(items, table.KV{K: MinInstancesUserFacingKey, V: *cc.MinInstances})
723713
items = append(items, table.KV{K: MaxInstancesUserFacingKey, V: *cc.MaxInstances})
724714
items = append(items, table.KV{K: InstanceVolumeSizeUserFacingKey, V: cc.InstanceVolumeSize})
715+
items = append(items, table.KV{K: SpotUserFacingKey, V: s.YesNo(*cc.Spot)})
725716

726-
if cc.Spot != nil {
717+
if cc.Spot != nil && *cc.Spot {
727718
items = append(items, table.KV{K: InstanceDistributionUserFacingKey, V: cc.SpotConfig.InstanceDistribution})
728719
items = append(items, table.KV{K: OnDemandBaseCapacityUserFacingKey, V: *cc.SpotConfig.OnDemandBaseCapacity})
729720
items = append(items, table.KV{K: OnDemandPercentageAboveBaseCapacityUserFacingKey, V: *cc.SpotConfig.OnDemandPercentageAboveBaseCapacity})

0 commit comments

Comments
 (0)