Skip to content

Commit

Permalink
Azure spot instances in the instance pool
Browse files Browse the repository at this point in the history
  • Loading branch information
alexott authored and nfx committed Mar 24, 2021
1 parent cb1f4ea commit 5a804bb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
5 changes: 4 additions & 1 deletion compute/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ func modifyClusterRequest(clusterModel *Cluster) {
clusterModel.AzureAttributes = nil
}
if clusterModel.GcpAttributes != nil {
clusterModel.GcpAttributes = nil
gcpAttributes := GcpAttributes{
GoogleServiceAccount: clusterModel.GcpAttributes.GoogleServiceAccount,
}
clusterModel.GcpAttributes = &gcpAttributes
}
clusterModel.EnableElasticDisk = false
clusterModel.NodeTypeID = ""
Expand Down
36 changes: 35 additions & 1 deletion compute/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ func TestResourceClusterUpdate_FailNumWorkersZero(t *testing.T) {
require.Equal(t, true, strings.Contains(err.Error(), "NumWorkers could be 0 only for SingleNode clusters"))
}

func TestModifyClusterRequest(t *testing.T) {
func TestModifyClusterRequestAws(t *testing.T) {
c := Cluster{
InstancePoolID: "a",
AwsAttributes: &AwsAttributes{
Expand All @@ -1072,3 +1072,37 @@ func TestModifyClusterRequest(t *testing.T) {
assert.Equal(t, "", c.DriverNodeTypeID)
assert.Equal(t, false, c.EnableElasticDisk)
}

func TestModifyClusterRequestAzure(t *testing.T) {
c := Cluster{
InstancePoolID: "a",
AzureAttributes: &AzureAttributes{
FirstOnDemand: 1,
},
EnableElasticDisk: true,
NodeTypeID: "d",
DriverNodeTypeID: "e",
}
modifyClusterRequest(&c)
assert.Nil(t, c.AzureAttributes)
assert.Equal(t, "", c.NodeTypeID)
assert.Equal(t, "", c.DriverNodeTypeID)
assert.Equal(t, false, c.EnableElasticDisk)
}

func TestModifyClusterRequestGcp(t *testing.T) {
c := Cluster{
InstancePoolID: "a",
GcpAttributes: &GcpAttributes{
UsePreemptibleExecutors: true,
},
EnableElasticDisk: true,
NodeTypeID: "d",
DriverNodeTypeID: "e",
}
modifyClusterRequest(&c)
assert.Equal(t, false, c.GcpAttributes.UsePreemptibleExecutors)
assert.Equal(t, "", c.NodeTypeID)
assert.Equal(t, "", c.DriverNodeTypeID)
assert.Equal(t, false, c.EnableElasticDisk)
}

0 comments on commit 5a804bb

Please sign in to comment.