[ARVADOS] created: 1.3.0-3255-g4cc84d125

Git user git at public.arvados.org
Sat Oct 3 00:49:43 UTC 2020


        at  4cc84d12503c936e1a32664cdee836215dc4705f (commit)


commit 4cc84d12503c936e1a32664cdee836215dc4705f
Author: Ward Vandewege <ward at curii.com>
Date:   Fri Oct 2 20:49:22 2020 -0400

    16106: add Azure spot instance support.
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/lib/cloud/azure/azure.go b/lib/cloud/azure/azure.go
index 7f949d9bd..ad1f8c532 100644
--- a/lib/cloud/azure/azure.go
+++ b/lib/cloud/azure/azure.go
@@ -491,6 +491,21 @@ func (az *azureInstanceSet) Create(
 		}
 	}
 
+	priority := compute.Regular
+	evictionPolicy := compute.Deallocate
+	var billingProfile compute.BillingProfile
+	var maxPrice float64
+	if instanceType.Preemptible {
+		priority = compute.Spot
+		evictionPolicy = compute.Delete
+		// Setting maxPrice to -1 is the equivalent of paying spot price, up to the
+		// normal price. This means the node will not be pre-empted for price
+		// reasons. It may still be pre-empted for capacity reasons though. And
+		// Azure offers *no* SLA on spot instances.
+		maxPrice = -1
+		billingProfile = compute.BillingProfile{MaxPrice: &maxPrice}
+	}
+
 	vmParameters := compute.VirtualMachine{
 		Location: &az.azconfig.Location,
 		Tags:     tags,
@@ -499,6 +514,9 @@ func (az *azureInstanceSet) Create(
 				VMSize: compute.VirtualMachineSizeTypes(instanceType.ProviderType),
 			},
 			StorageProfile: storageProfile,
+			Priority:       priority,
+			EvictionPolicy: evictionPolicy,
+			BillingProfile: &billingProfile,
 			NetworkProfile: &compute.NetworkProfile{
 				NetworkInterfaces: &[]compute.NetworkInterfaceReference{
 					{
diff --git a/lib/cloud/azure/azure_test.go b/lib/cloud/azure/azure_test.go
index 96d6dca69..b6aa9a16b 100644
--- a/lib/cloud/azure/azure_test.go
+++ b/lib/cloud/azure/azure_test.go
@@ -136,6 +136,15 @@ func GetInstanceSet() (cloud.InstanceSet, cloud.ImageID, arvados.Cluster, error)
 				Price:        .02,
 				Preemptible:  false,
 			},
+			"tinyp": {
+				Name:         "tiny",
+				ProviderType: "Standard_D1_v2",
+				VCPUs:        1,
+				RAM:          4000000000,
+				Scratch:      10000000000,
+				Price:        .002,
+				Preemptible:  true,
+			},
 		})}
 	if *live != "" {
 		var exampleCfg testConfig
@@ -185,6 +194,17 @@ func (*AzureInstanceSetSuite) TestCreate(c *check.C) {
 	c.Check(tags["TestTagName"], check.Equals, "test tag value")
 	c.Logf("inst.String()=%v Address()=%v Tags()=%v", inst.String(), inst.Address(), tags)
 
+	instPreemptable, err := ap.Create(cluster.InstanceTypes["tinyp"],
+		img, map[string]string{
+			"TestTagName": "test tag value",
+		}, "umask 0600; echo -n test-file-data >/var/run/test-file", pk)
+
+	c.Assert(err, check.IsNil)
+
+	tags = instPreemptable.Tags()
+	c.Check(tags["TestTagName"], check.Equals, "test tag value")
+	c.Logf("instPreemptable.String()=%v Address()=%v Tags()=%v", instPreemptable.String(), instPreemptable.Address(), tags)
+
 }
 
 func (*AzureInstanceSetSuite) TestListInstances(c *check.C) {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list