7478: Preemptable instances support on GoSDK & dispatchcloud instance chooser
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Wed, 23 May 2018 19:13:04 +0000 (16:13 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Wed, 23 May 2018 19:13:04 +0000 (16:13 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

lib/dispatchcloud/node_size.go
lib/dispatchcloud/node_size_test.go
sdk/go/arvados/config.go
sdk/go/arvados/container.go

index 2ca405060390c65df2f961f7c7a83e5a278d0687..f145901c32fd5a51e50b55df7b91268de6969c93 100644 (file)
@@ -47,6 +47,7 @@ func ChooseInstanceType(cc *arvados.Cluster, ctr *arvados.Container) (best arvad
                case it.Scratch < needScratch:
                case it.RAM < needRAM:
                case it.VCPUs < needVCPUs:
+               case it.Preemptable != ctr.SchedulingParameters.Preemptable:
                case it.Price == best.Price && (it.RAM < best.RAM || it.VCPUs < best.VCPUs):
                        // Equal price, but worse specs
                default:
index 0c02a0e3e1be45bfeb6b2371287a4ce664de1d98..9a5e704695138cb54adb6791dcf3f61f8eb5e3ba 100644 (file)
@@ -91,3 +91,31 @@ func (*NodeSizeSuite) TestChoose(c *check.C) {
                c.Check(best.Scratch >= 2*GiB, check.Equals, true)
        }
 }
+
+func (*NodeSizeSuite) TestChoosePreemptable(c *check.C) {
+       menu := []arvados.InstanceType{
+               {Price: 4.4, RAM: 4000000000, VCPUs: 8, Scratch: 2 * GiB, Preemptable: true, Name: "costly"},
+               {Price: 2.2, RAM: 2000000000, VCPUs: 4, Scratch: 2 * GiB, Name: "almost best"},
+               {Price: 2.2, RAM: 2000000000, VCPUs: 4, Scratch: 2 * GiB, Preemptable: true, Name: "best"},
+               {Price: 1.1, RAM: 1000000000, VCPUs: 2, Scratch: 2 * GiB, Preemptable: true, Name: "small"},
+       }
+       best, err := ChooseInstanceType(&arvados.Cluster{InstanceTypes: menu}, &arvados.Container{
+               Mounts: map[string]arvados.Mount{
+                       "/tmp": {Kind: "tmp", Capacity: 2 * GiB},
+               },
+               RuntimeConstraints: arvados.RuntimeConstraints{
+                       VCPUs:        2,
+                       RAM:          987654321,
+                       KeepCacheRAM: 123456789,
+               },
+               SchedulingParameters: arvados.SchedulingParameters{
+                       Preemptable: true,
+               },
+       })
+       c.Check(err, check.IsNil)
+       c.Check(best.Name, check.Equals, "best")
+       c.Check(best.RAM >= 1234567890, check.Equals, true)
+       c.Check(best.VCPUs >= 2, check.Equals, true)
+       c.Check(best.Scratch >= 2*GiB, check.Equals, true)
+       c.Check(best.Preemptable, check.Equals, true)
+}
index 9ed0eacf23e6d753c1b6c2a0f781282c96dde8cc..b0c7069cd98007ec0f24ad45cb809c137784eaae 100644 (file)
@@ -62,6 +62,7 @@ type InstanceType struct {
        RAM          int64
        Scratch      int64
        Price        float64
+       Preemptable  bool
 }
 
 // GetThisSystemNode returns a SystemNode for the node we're running
index daafc4995448524f7fe3794b9facd13e01480823..e71bcd5d0da5cdeaebdc6dfd3be05cd81d681d58 100644 (file)
@@ -52,7 +52,8 @@ type RuntimeConstraints struct {
 // SchedulingParameters specify a container's scheduling parameters
 // such as Partitions
 type SchedulingParameters struct {
-       Partitions []string `json:"partitions"`
+       Partitions  []string `json:"partitions"`
+       Preemptable bool     `json:"preemptable"`
 }
 
 // ContainerList is an arvados#containerList resource.