17609: Behave better when project creation fails.
authorTom Clegg <tom@curii.com>
Tue, 8 Jun 2021 05:53:12 +0000 (01:53 -0400)
committerTom Clegg <tom@curii.com>
Tue, 8 Jun 2021 15:29:09 +0000 (11:29 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/diagnostics/cmd.go

index 2f43263e5c52c9426a46caee391ecc59c1730fce..1c7b98baf730bfdcad36c0d488d482258211c26f 100644 (file)
@@ -31,7 +31,7 @@ func (cmd Command) RunCommand(prog string, args []string, stdin io.Reader, stdou
        f.StringVar(&diag.logLevel, "log-level", "info", "logging level (debug, info, warning, error)")
        f.BoolVar(&diag.checkInternal, "internal-client", false, "check that this host is considered an \"internal\" client")
        f.BoolVar(&diag.checkExternal, "external-client", false, "check that this host is considered an \"external\" client")
-       f.IntVar(&diag.priority, "priority", 500, "priority for test container (1..1000)")
+       f.IntVar(&diag.priority, "priority", 500, "priority for test container (1..1000, or 0 to skip)")
        f.DurationVar(&diag.timeout, "timeout", 10*time.Second, "timeout for http requests")
        err := f.Parse(args)
        if err == flag.ErrHelp {
@@ -334,13 +334,17 @@ func (diag *diagnoser) runtests() {
 
        var collection arvados.Collection
        diag.dotest(90, "creating temporary collection", func() error {
+               if project.UUID == "" {
+                       return fmt.Errorf("skipping, no project to work in")
+               }
                ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
                defer cancel()
                err := client.RequestAndDecodeContext(ctx, &collection, "POST", "arvados/v1/collections", nil, map[string]interface{}{
                        "ensure_unique_name": true,
                        "collection": map[string]interface{}{
-                               "name":     "test collection",
-                               "trash_at": time.Now().Add(time.Hour)}})
+                               "owner_uuid": project.UUID,
+                               "name":       "test collection",
+                               "trash_at":   time.Now().Add(time.Hour)}})
                if err != nil {
                        return err
                }
@@ -532,6 +536,9 @@ func (diag *diagnoser) runtests() {
                        diag.debugf("skipping, caller requested priority<1 (%d)", diag.priority)
                        return nil
                }
+               if project.UUID == "" {
+                       return fmt.Errorf("skipping, no project to work in")
+               }
 
                var cr arvados.ContainerRequest
                ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))