12199: Rename instance type features: a1.xl => instancetype=a1.xl
authorTom Clegg <tclegg@veritasgenetics.com>
Sun, 28 Jan 2018 21:52:13 +0000 (16:52 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Mon, 29 Jan 2018 00:33:20 +0000 (19:33 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
services/dispatchcloud/node_size.go

index 44123f85cff12dd10512e0acf9e7c1801dc0e654..9eebbab02bbc04bde9bd07e6be47333849171662 100644 (file)
@@ -234,7 +234,7 @@ func (disp *Dispatcher) sbatchArgs(container arvados.Container) ([]string, error
        } else if err != nil {
                return nil, err
        } else {
-               sbatchArgs = append(sbatchArgs, "--constraint="+it.Name)
+               sbatchArgs = append(sbatchArgs, "--constraint=instancetype="+it.Name)
        }
 
        return sbatchArgs, nil
index b8222324ac7b79646561a3ebd41dd44cb2124400..583e0d80c938179a3db45aa5a6f72ed3d045b4a0 100644 (file)
@@ -388,7 +388,7 @@ func (s *StubbedSuite) TestSbatchInstanceTypeConstraint(c *C) {
                                {Name: "a1.small", Price: 0.04, RAM: 256000000, VCPUs: 2},
                                {Name: "a1.medium", Price: 0.08, RAM: 512000000, VCPUs: 4},
                        },
-                       sbatchArgs: []string{"--constraint=a1.small"},
+                       sbatchArgs: []string{"--constraint=instancetype=a1.small"},
                },
                // No node types configured => no slurm constraint
                {
index 9cb6d3fafe6c83dc3f31ad0440dcec6490de8ee4..29832dac7702c4d51d25edf903c9abed319f9df6 100644 (file)
@@ -66,15 +66,19 @@ func ChooseInstanceType(cc *arvados.Cluster, ctr *arvados.Container) (best arvad
 //
 // SlurmNodeTypeFeatureKludge does a test-and-fix operation
 // immediately, and then periodically, in case slurm restarts and
-// forgets the list of valid features. It never returns, so it should
-// generally be invoked with "go".
+// forgets the list of valid features. It never returns (unless there
+// are no node types configured, in which case it returns
+// immediately), so it should generally be invoked with "go".
 func SlurmNodeTypeFeatureKludge(cc *arvados.Cluster) {
-       var types []string
+       if len(cc.InstanceTypes) == 0 {
+               return
+       }
+       var features []string
        for _, it := range cc.InstanceTypes {
-               types = append(types, it.Name)
+               features = append(features, "instancetype="+it.Name)
        }
        for {
-               slurmKludge(types)
+               slurmKludge(features)
                time.Sleep(time.Minute)
        }
 }
@@ -85,8 +89,8 @@ var (
        slurmErrBadGres    = "Invalid generic resource"
 )
 
-func slurmKludge(types []string) {
-       cmd := exec.Command("srun", "--gres=invalid-gres-specification", "--constraint="+strings.Join(types, "&"), "true")
+func slurmKludge(features []string) {
+       cmd := exec.Command("srun", "--gres=invalid-gres-specification", "--constraint="+strings.Join(features, "&"), "true")
        out, err := cmd.CombinedOutput()
        switch {
        case err == nil:
@@ -95,8 +99,8 @@ func slurmKludge(types []string) {
 
        case bytes.Contains(out, []byte(slurmErrBadFeature)):
                log.Printf("temporarily configuring node %q with all node type features", slurmDummyNode)
-               for _, features := range []string{strings.Join(types, ","), ""} {
-                       cmd = exec.Command("scontrol", "update", "NodeName="+slurmDummyNode, "Features="+features)
+               for _, nodeFeatures := range []string{strings.Join(features, ","), ""} {
+                       cmd = exec.Command("scontrol", "update", "NodeName="+slurmDummyNode, "Features="+nodeFeatures)
                        log.Printf("running: %q %q", cmd.Path, cmd.Args)
                        out, err := cmd.CombinedOutput()
                        if err != nil {