13581: Adds log message when no instance types are configured.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Thu, 14 Jun 2018 15:04:22 +0000 (12:04 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Thu, 14 Jun 2018 15:04:22 +0000 (12:04 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

lib/dispatchcloud/node_size_test.go
services/crunch-dispatch-slurm/crunch-dispatch-slurm.go

index 31944cfa5f12f6c6d99c18cdc1ae577733faab86..e2a729f4d040efc0190507b322640c0e5bbc6b43 100644 (file)
@@ -32,8 +32,7 @@ func (*NodeSizeSuite) TestChooseUnsatisfiable(c *check.C) {
                        {Price: 2.2, RAM: 2000000000, VCPUs: 4, Name: "small2"},
                        {Price: 4.4, RAM: 4000000000, VCPUs: 8, Name: "small4", Scratch: GiB},
                }}, ctr)
-               err, ok := err.(ConstraintsNotSatisfiableError)
-               c.Check(ok, check.Equals, true)
+               c.Check(err, check.FitsTypeOf, ConstraintsNotSatisfiableError{})
        }
 
        for _, rc := range []arvados.RuntimeConstraints{
index 8c5b220b4f0df6bb87a1650516a2fba0e7f591e1..d1f19dd7b5702e2431471bc7ce2164f553a8cb11 100644 (file)
@@ -277,15 +277,17 @@ func (disp *Dispatcher) runContainer(_ *dispatch.Dispatcher, ctr arvados.Contain
                        var text string
                        if err, ok := err.(dispatchcloud.ConstraintsNotSatisfiableError); ok {
                                var logBuf bytes.Buffer
-                               logBuf.WriteString(fmt.Sprintf("cannot run container %s: %s\n", ctr.UUID, err))
-                               if len(err.AvailableTypes) > 0 {
-                                       logBuf.WriteString("Available instance types:\n")
-                               }
-                               for _, t := range err.AvailableTypes {
-                                       logBuf.WriteString(fmt.Sprintf(
-                                               "Type %q: %d VCPUs, %d RAM, %d Scratch, %f Price\n",
-                                               t.Name, t.VCPUs, t.RAM, t.Scratch, t.Price,
-                                       ))
+                               fmt.Fprintf(&logBuf, "cannot run container %s: %s\n", ctr.UUID, err)
+                               if len(err.AvailableTypes) == 0 {
+                                       fmt.Fprint(&logBuf, "No instance types are configured.\n")
+                               } else {
+                                       fmt.Fprint(&logBuf, "Available instance types:\n")
+                                       for _, t := range err.AvailableTypes {
+                                               fmt.Fprintf(&logBuf,
+                                                       "Type %q: %d VCPUs, %d RAM, %d Scratch, %f Price\n",
+                                                       t.Name, t.VCPUs, t.RAM, t.Scratch, t.Price,
+                                               )
+                                       }
                                }
                                text = logBuf.String()
                                disp.UpdateState(ctr.UUID, dispatch.Cancelled)