1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
23 "git.arvados.org/arvados.git/lib/cmd"
24 "git.arvados.org/arvados.git/lib/config"
25 "git.arvados.org/arvados.git/sdk/go/arvados"
26 "git.arvados.org/arvados.git/sdk/go/ctxlog"
27 "git.arvados.org/arvados.git/sdk/go/health"
28 "github.com/sirupsen/logrus"
33 func (Command) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
35 f := flag.NewFlagSet(prog, flag.ContinueOnError)
36 f.StringVar(&diag.projectName, "project-name", "scratch area for diagnostics", "name of project to find/create in home project and use for temporary/test objects")
37 f.StringVar(&diag.logLevel, "log-level", "info", "logging level (debug, info, warning, error)")
38 f.StringVar(&diag.dockerImage, "docker-image", "", "image to use when running a test container (default: use embedded hello-world image)")
39 f.BoolVar(&diag.checkInternal, "internal-client", false, "check that this host is considered an \"internal\" client")
40 f.BoolVar(&diag.checkExternal, "external-client", false, "check that this host is considered an \"external\" client")
41 f.BoolVar(&diag.verbose, "v", false, "verbose: include more information in report")
42 f.IntVar(&diag.priority, "priority", 500, "priority for test container (1..1000, or 0 to skip)")
43 f.DurationVar(&diag.timeout, "timeout", 10*time.Second, "timeout for http requests")
44 if ok, code := cmd.ParseFlags(f, prog, args, "", stderr); !ok {
47 diag.logger = ctxlog.New(stdout, "text", diag.logLevel)
48 diag.logger.SetFormatter(&logrus.TextFormatter{DisableTimestamp: true, DisableLevelTruncation: true, PadLevelText: true})
50 if len(diag.errors) == 0 {
51 diag.logger.Info("--- no errors ---")
54 if diag.logger.Level > logrus.ErrorLevel {
55 fmt.Fprint(stdout, "\n--- cut here --- error summary ---\n\n")
56 for _, e := range diag.errors {
64 // docker save hello-world > hello-world.tar
66 //go:embed hello-world.tar
67 var HelloWorldDockerImage []byte
69 type diagnoser struct {
85 func (diag *diagnoser) debugf(f string, args ...interface{}) {
86 diag.logger.Debugf(" ... "+f, args...)
89 func (diag *diagnoser) infof(f string, args ...interface{}) {
90 diag.logger.Infof(" ... "+f, args...)
93 func (diag *diagnoser) verbosef(f string, args ...interface{}) {
95 diag.logger.Infof(" ... "+f, args...)
99 func (diag *diagnoser) warnf(f string, args ...interface{}) {
100 diag.logger.Warnf(" ... "+f, args...)
103 func (diag *diagnoser) errorf(f string, args ...interface{}) {
104 diag.logger.Errorf(f, args...)
105 diag.errors = append(diag.errors, fmt.Sprintf(f, args...))
108 // Run the given func, logging appropriate messages before and after,
109 // adding timing info, etc.
111 // The id argument should be unique among tests, and shouldn't change
112 // when other tests are added/removed.
113 func (diag *diagnoser) dotest(id int, title string, fn func() error) {
114 if diag.done == nil {
115 diag.done = map[int]bool{}
116 } else if diag.done[id] {
117 diag.errorf("(bug) reused test id %d", id)
121 diag.logger.Infof("%4d: %s", id, title)
124 elapsed := fmt.Sprintf("%d ms", time.Now().Sub(t0)/time.Millisecond)
126 diag.errorf("%4d: %s (%s): %s", id, title, elapsed, err)
128 diag.logger.Debugf("%4d: %s (%s): ok", id, title, elapsed)
132 func (diag *diagnoser) runtests() {
133 client := arvados.NewClientFromEnv()
135 if client.APIHost == "" || client.AuthToken == "" {
136 diag.errorf("ARVADOS_API_HOST and ARVADOS_API_TOKEN environment variables are not set -- aborting without running any tests")
140 hostname, err := os.Hostname()
142 diag.warnf("error getting hostname: %s")
144 diag.verbosef("hostname = %s", hostname)
147 diag.dotest(5, "running health check (same as `arvados-server check`)", func() error {
148 ldr := config.NewLoader(&bytes.Buffer{}, ctxlog.New(&bytes.Buffer{}, "text", "info"))
149 ldr.SetupFlags(flag.NewFlagSet("diagnostics", flag.ContinueOnError))
150 cfg, err := ldr.Load()
152 diag.infof("skipping because config could not be loaded: %s", err)
155 cluster, err := cfg.GetCluster("")
159 if cluster.SystemRootToken != os.Getenv("ARVADOS_API_TOKEN") {
160 return fmt.Errorf("diagnostics usage error: %s is readable but SystemRootToken does not match $ARVADOS_API_TOKEN (to fix, either run 'arvados-client sudo diagnostics' to load everything from config file, or set ARVADOS_CONFIG=- to load nothing from config file)", ldr.Path)
162 agg := &health.Aggregator{Cluster: cluster}
163 resp := agg.ClusterHealth()
164 for _, e := range resp.Errors {
165 diag.errorf("health check: %s", e)
167 if len(resp.Errors) > 0 {
168 diag.infof("consider running `arvados-server check -yaml` for a comprehensive report")
170 diag.verbosef("reported clock skew = %v", resp.ClockSkew)
171 reported := map[string]bool{}
172 for _, result := range resp.Checks {
173 version := strings.SplitN(result.Metrics.Version, " (go", 2)[0]
174 if version != "" && !reported[version] {
175 diag.verbosef("arvados version = %s", version)
176 reported[version] = true
179 reported = map[string]bool{}
180 for _, result := range resp.Checks {
181 if result.Server != "" && !reported[result.Server] {
182 diag.verbosef("http frontend version = %s", result.Server)
183 reported[result.Server] = true
186 reported = map[string]bool{}
187 for _, result := range resp.Checks {
188 if sha := result.ConfigSourceSHA256; sha != "" && !reported[sha] {
189 diag.verbosef("config file sha256 = %s", sha)
196 var dd arvados.DiscoveryDocument
197 ddpath := "discovery/v1/apis/arvados/v1/rest"
198 diag.dotest(10, fmt.Sprintf("getting discovery document from https://%s/%s", client.APIHost, ddpath), func() error {
199 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
201 err := client.RequestAndDecodeContext(ctx, &dd, "GET", ddpath, nil, nil)
205 diag.verbosef("BlobSignatureTTL = %d", dd.BlobSignatureTTL)
209 var cluster arvados.Cluster
210 cfgpath := "arvados/v1/config"
212 diag.dotest(20, fmt.Sprintf("getting exported config from https://%s/%s", client.APIHost, cfgpath), func() error {
213 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
215 err := client.RequestAndDecodeContext(ctx, &cluster, "GET", cfgpath, nil, nil)
219 diag.verbosef("Collections.BlobSigning = %v", cluster.Collections.BlobSigning)
224 var user arvados.User
225 diag.dotest(30, "getting current user record", func() error {
226 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
228 err := client.RequestAndDecodeContext(ctx, &user, "GET", "arvados/v1/users/current", nil, nil)
232 diag.verbosef("user uuid = %s", user.UUID)
237 diag.errorf("cannot proceed without cluster config -- aborting without running any further tests")
241 // uncomment to create some spurious errors
242 // cluster.Services.WebDAVDownload.ExternalURL.Host = "0.0.0.0:9"
244 // TODO: detect routing errors here, like finding wb2 at the
246 for i, svc := range []*arvados.Service{
247 &cluster.Services.Keepproxy,
248 &cluster.Services.WebDAV,
249 &cluster.Services.WebDAVDownload,
250 &cluster.Services.Websocket,
251 &cluster.Services.Workbench1,
252 &cluster.Services.Workbench2,
254 diag.dotest(40+i, fmt.Sprintf("connecting to service endpoint %s", svc.ExternalURL), func() error {
255 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
258 if strings.HasPrefix(u.Scheme, "ws") {
259 // We can do a real websocket test elsewhere,
260 // but for now we'll just check the https
262 u.Scheme = "http" + u.Scheme[2:]
264 if svc == &cluster.Services.WebDAV && strings.HasPrefix(u.Host, "*") {
265 u.Host = "d41d8cd98f00b204e9800998ecf8427e-0" + u.Host[1:]
267 req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
271 resp, err := http.DefaultClient.Do(req)
280 for i, url := range []string{
281 cluster.Services.Controller.ExternalURL.String(),
282 cluster.Services.Keepproxy.ExternalURL.String() + "d41d8cd98f00b204e9800998ecf8427e+0",
283 cluster.Services.WebDAVDownload.ExternalURL.String(),
285 diag.dotest(50+i, fmt.Sprintf("checking CORS headers at %s", url), func() error {
286 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
288 req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
292 req.Header.Set("Origin", "https://example.com")
293 resp, err := http.DefaultClient.Do(req)
297 if hdr := resp.Header.Get("Access-Control-Allow-Origin"); hdr != "*" {
298 return fmt.Errorf("expected \"Access-Control-Allow-Origin: *\", got %q", hdr)
304 var keeplist arvados.KeepServiceList
305 diag.dotest(60, "checking internal/external client detection", func() error {
306 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
308 err := client.RequestAndDecodeContext(ctx, &keeplist, "GET", "arvados/v1/keep_services/accessible", nil, arvados.ListOptions{Limit: 999999})
310 return fmt.Errorf("error getting keep services list: %s", err)
311 } else if len(keeplist.Items) == 0 {
312 return fmt.Errorf("controller did not return any keep services")
314 found := map[string]int{}
315 for _, ks := range keeplist.Items {
316 found[ks.ServiceType]++
318 isInternal := found["proxy"] == 0 && len(keeplist.Items) > 0
319 isExternal := found["proxy"] > 0 && found["proxy"] == len(keeplist.Items)
321 diag.infof("controller returned only proxy services, this host is treated as \"external\"")
322 } else if isInternal {
323 diag.infof("controller returned only non-proxy services, this host is treated as \"internal\"")
325 if (diag.checkInternal && !isInternal) || (diag.checkExternal && !isExternal) {
326 return fmt.Errorf("expecting internal=%v external=%v, but found internal=%v external=%v", diag.checkInternal, diag.checkExternal, isInternal, isExternal)
331 for i, ks := range keeplist.Items {
334 Host: net.JoinHostPort(ks.ServiceHost, fmt.Sprintf("%d", ks.ServicePort)),
337 if ks.ServiceSSLFlag {
340 diag.dotest(61+i, fmt.Sprintf("reading+writing via keep service at %s", u.String()), func() error {
341 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
343 req, err := http.NewRequestWithContext(ctx, "PUT", u.String()+"d41d8cd98f00b204e9800998ecf8427e", nil)
347 req.Header.Set("Authorization", "Bearer "+client.AuthToken)
348 resp, err := http.DefaultClient.Do(req)
352 defer resp.Body.Close()
353 body, err := ioutil.ReadAll(resp.Body)
355 return fmt.Errorf("reading response body: %s", err)
357 loc := strings.TrimSpace(string(body))
358 if !strings.HasPrefix(loc, "d41d8") {
359 return fmt.Errorf("unexpected response from write: %q", body)
362 req, err = http.NewRequestWithContext(ctx, "GET", u.String()+loc, nil)
366 req.Header.Set("Authorization", "Bearer "+client.AuthToken)
367 resp, err = http.DefaultClient.Do(req)
371 defer resp.Body.Close()
372 body, err = ioutil.ReadAll(resp.Body)
374 return fmt.Errorf("reading response body: %s", err)
377 return fmt.Errorf("unexpected response from read: %q", body)
384 var project arvados.Group
385 diag.dotest(80, fmt.Sprintf("finding/creating %q project", diag.projectName), func() error {
386 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
388 var grplist arvados.GroupList
389 err := client.RequestAndDecodeContext(ctx, &grplist, "GET", "arvados/v1/groups", nil, arvados.ListOptions{
390 Filters: []arvados.Filter{
391 {"name", "=", diag.projectName},
392 {"group_class", "=", "project"},
393 {"owner_uuid", "=", user.UUID}},
396 return fmt.Errorf("list groups: %s", err)
398 if len(grplist.Items) > 0 {
399 project = grplist.Items[0]
400 diag.verbosef("using existing project, uuid = %s", project.UUID)
403 diag.debugf("list groups: ok, no results")
404 err = client.RequestAndDecodeContext(ctx, &project, "POST", "arvados/v1/groups", nil, map[string]interface{}{"group": map[string]interface{}{
405 "name": diag.projectName,
406 "group_class": "project",
409 return fmt.Errorf("create project: %s", err)
411 diag.verbosef("created project, uuid = %s", project.UUID)
415 var collection arvados.Collection
416 diag.dotest(90, "creating temporary collection", func() error {
417 if project.UUID == "" {
418 return fmt.Errorf("skipping, no project to work in")
420 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
422 err := client.RequestAndDecodeContext(ctx, &collection, "POST", "arvados/v1/collections", nil, map[string]interface{}{
423 "ensure_unique_name": true,
424 "collection": map[string]interface{}{
425 "owner_uuid": project.UUID,
426 "name": "test collection",
427 "trash_at": time.Now().Add(time.Hour)}})
431 diag.verbosef("ok, uuid = %s", collection.UUID)
435 if collection.UUID != "" {
437 diag.dotest(9990, "deleting temporary collection", func() error {
438 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
440 return client.RequestAndDecodeContext(ctx, nil, "DELETE", "arvados/v1/collections/"+collection.UUID, nil, nil)
445 // Read hello-world.tar to find image ID, so we can upload it
446 // as "sha256:{...}.tar"
449 tr := tar.NewReader(bytes.NewReader(HelloWorldDockerImage))
451 hdr, err := tr.Next()
456 diag.errorf("internal error/bug: cannot read embedded docker image tar file: %s", err)
459 if s := strings.TrimSuffix(hdr.Name, ".json"); len(s) == 64 && s != hdr.Name {
464 diag.errorf("internal error/bug: cannot find {sha256}.json file in embedded docker image tar file")
468 tarfilename := "sha256:" + imageSHA2 + ".tar"
470 diag.dotest(100, "uploading file via webdav", func() error {
471 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
473 if collection.UUID == "" {
474 return fmt.Errorf("skipping, no test collection")
476 req, err := http.NewRequestWithContext(ctx, "PUT", cluster.Services.WebDAVDownload.ExternalURL.String()+"c="+collection.UUID+"/"+tarfilename, bytes.NewReader(HelloWorldDockerImage))
478 return fmt.Errorf("BUG? http.NewRequest: %s", err)
480 req.Header.Set("Authorization", "Bearer "+client.AuthToken)
481 resp, err := http.DefaultClient.Do(req)
483 return fmt.Errorf("error performing http request: %s", err)
486 if resp.StatusCode != http.StatusCreated {
487 return fmt.Errorf("status %s", resp.Status)
489 diag.debugf("ok, status %s", resp.Status)
490 err = client.RequestAndDecodeContext(ctx, &collection, "GET", "arvados/v1/collections/"+collection.UUID, nil, nil)
492 return fmt.Errorf("get updated collection: %s", err)
494 diag.debugf("ok, pdh %s", collection.PortableDataHash)
498 davurl := cluster.Services.WebDAV.ExternalURL
499 davWildcard := strings.HasPrefix(davurl.Host, "*--") || strings.HasPrefix(davurl.Host, "*.")
500 diag.dotest(110, fmt.Sprintf("checking WebDAV ExternalURL wildcard (%s)", davurl), func() error {
501 if davurl.Host == "" {
502 return fmt.Errorf("host missing - content previews will not work")
504 if !davWildcard && !cluster.Collections.TrustAllContent {
505 diag.warnf("WebDAV ExternalURL has no leading wildcard and TrustAllContent==false - content previews will not work")
510 for i, trial := range []struct {
516 {false, false, http.StatusNotFound, strings.Replace(davurl.String(), "*", "d41d8cd98f00b204e9800998ecf8427e-0", 1) + "foo"},
517 {false, false, http.StatusNotFound, strings.Replace(davurl.String(), "*", "d41d8cd98f00b204e9800998ecf8427e-0", 1) + tarfilename},
518 {false, false, http.StatusNotFound, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=d41d8cd98f00b204e9800998ecf8427e+0/_/foo"},
519 {false, false, http.StatusNotFound, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=d41d8cd98f00b204e9800998ecf8427e+0/_/" + tarfilename},
520 {true, true, http.StatusOK, strings.Replace(davurl.String(), "*", strings.Replace(collection.PortableDataHash, "+", "-", -1), 1) + tarfilename},
521 {true, false, http.StatusOK, cluster.Services.WebDAVDownload.ExternalURL.String() + "c=" + collection.UUID + "/_/" + tarfilename},
523 diag.dotest(120+i, fmt.Sprintf("downloading from webdav (%s)", trial.fileurl), func() error {
524 if trial.needWildcard && !davWildcard {
525 diag.warnf("skipping collection-id-in-vhost test because WebDAV ExternalURL has no leading wildcard")
528 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
530 if trial.needcoll && collection.UUID == "" {
531 return fmt.Errorf("skipping, no test collection")
533 req, err := http.NewRequestWithContext(ctx, "GET", trial.fileurl, nil)
537 req.Header.Set("Authorization", "Bearer "+client.AuthToken)
538 resp, err := http.DefaultClient.Do(req)
542 defer resp.Body.Close()
543 body, err := ioutil.ReadAll(resp.Body)
545 return fmt.Errorf("reading response: %s", err)
547 if resp.StatusCode != trial.status {
548 return fmt.Errorf("unexpected response status: %s", resp.Status)
550 if trial.status == http.StatusOK && !bytes.Equal(body, HelloWorldDockerImage) {
552 if len(excerpt) > 128 {
553 excerpt = append([]byte(nil), body[:128]...)
554 excerpt = append(excerpt, []byte("[...]")...)
556 return fmt.Errorf("unexpected response content: len %d, %q", len(body), excerpt)
562 var vm arvados.VirtualMachine
563 diag.dotest(130, "getting list of virtual machines", func() error {
564 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
566 var vmlist arvados.VirtualMachineList
567 err := client.RequestAndDecodeContext(ctx, &vmlist, "GET", "arvados/v1/virtual_machines", nil, arvados.ListOptions{Limit: 999999})
571 if len(vmlist.Items) < 1 {
572 diag.warnf("no VMs found")
579 diag.dotest(140, "getting workbench1 webshell page", func() error {
580 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
583 diag.warnf("skipping, no vm available")
586 webshelltermurl := cluster.Services.Workbench1.ExternalURL.String() + "virtual_machines/" + vm.UUID + "/webshell/testusername"
587 diag.debugf("url %s", webshelltermurl)
588 req, err := http.NewRequestWithContext(ctx, "GET", webshelltermurl, nil)
592 req.Header.Set("Authorization", "Bearer "+client.AuthToken)
593 resp, err := http.DefaultClient.Do(req)
597 defer resp.Body.Close()
598 body, err := ioutil.ReadAll(resp.Body)
600 return fmt.Errorf("reading response: %s", err)
602 if resp.StatusCode != http.StatusOK {
603 return fmt.Errorf("unexpected response status: %s %q", resp.Status, body)
608 diag.dotest(150, "connecting to webshell service", func() error {
609 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
612 diag.warnf("skipping, no vm available")
615 u := cluster.Services.WebShell.ExternalURL
616 webshellurl := u.String() + vm.Hostname + "?"
617 if strings.HasPrefix(u.Host, "*") {
618 u.Host = vm.Hostname + u.Host[1:]
619 webshellurl = u.String() + "?"
621 diag.debugf("url %s", webshellurl)
622 req, err := http.NewRequestWithContext(ctx, "POST", webshellurl, bytes.NewBufferString(url.Values{
625 "session": {"xyzzy"},
626 "rooturl": {webshellurl},
631 req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
632 resp, err := http.DefaultClient.Do(req)
636 defer resp.Body.Close()
637 diag.debugf("response status %s", resp.Status)
638 body, err := ioutil.ReadAll(resp.Body)
640 return fmt.Errorf("reading response: %s", err)
642 diag.debugf("response body %q", body)
643 // We don't speak the protocol, so we get a 400 error
644 // from the webshell server even if everything is
645 // OK. Anything else (404, 502, ???) indicates a
647 if resp.StatusCode != http.StatusBadRequest {
648 return fmt.Errorf("unexpected response status: %s, %q", resp.Status, body)
653 diag.dotest(160, "running a container", func() error {
654 if diag.priority < 1 {
655 diag.infof("skipping (use priority > 0 if you want to run a container)")
658 if project.UUID == "" {
659 return fmt.Errorf("skipping, no project to work in")
662 timestamp := time.Now().Format(time.RFC3339)
663 ctrCommand := []string{"echo", timestamp}
664 if diag.dockerImage == "" {
665 if collection.UUID == "" {
666 return fmt.Errorf("skipping, no test collection to use as docker image")
668 diag.dockerImage = collection.PortableDataHash
669 ctrCommand = []string{"/hello"}
672 var cr arvados.ContainerRequest
673 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
676 err := client.RequestAndDecodeContext(ctx, &cr, "POST", "arvados/v1/container_requests", nil, map[string]interface{}{"container_request": map[string]interface{}{
677 "owner_uuid": project.UUID,
678 "name": fmt.Sprintf("diagnostics container request %s", timestamp),
679 "container_image": diag.dockerImage,
680 "command": ctrCommand,
681 "use_existing": false,
682 "output_path": "/mnt/output",
683 "output_name": fmt.Sprintf("diagnostics output %s", timestamp),
684 "priority": diag.priority,
685 "state": arvados.ContainerRequestStateCommitted,
686 "mounts": map[string]map[string]interface{}{
688 "kind": "collection",
692 "runtime_constraints": arvados.RuntimeConstraints{
695 KeepCacheRAM: 1 << 26,
701 diag.verbosef("container request uuid = %s", cr.UUID)
702 diag.verbosef("container uuid = %s", cr.ContainerUUID)
704 timeout := 10 * time.Minute
705 diag.infof("container request submitted, waiting up to %v for container to run", arvados.Duration(timeout))
706 deadline := time.Now().Add(timeout)
708 var c arvados.Container
709 for ; cr.State != arvados.ContainerRequestStateFinal && time.Now().Before(deadline); time.Sleep(2 * time.Second) {
710 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(diag.timeout))
713 crStateWas := cr.State
714 err := client.RequestAndDecodeContext(ctx, &cr, "GET", "arvados/v1/container_requests/"+cr.UUID, nil, nil)
718 if cr.State != crStateWas {
719 diag.debugf("container request state = %s", cr.State)
723 err = client.RequestAndDecodeContext(ctx, &c, "GET", "arvados/v1/containers/"+cr.ContainerUUID, nil, nil)
727 if c.State != cStateWas {
728 diag.debugf("container state = %s", c.State)
734 if cr.State != arvados.ContainerRequestStateFinal {
735 err := client.RequestAndDecodeContext(context.Background(), &cr, "PATCH", "arvados/v1/container_requests/"+cr.UUID, nil, map[string]interface{}{
736 "container_request": map[string]interface{}{
740 diag.infof("error canceling container request %s: %s", cr.UUID, err)
742 diag.debugf("canceled container request %s", cr.UUID)
744 return fmt.Errorf("timed out waiting for container to finish; container request %s state was %q, container %s state was %q", cr.UUID, cr.State, c.UUID, c.State)
746 if c.State != arvados.ContainerStateComplete {
747 return fmt.Errorf("container request %s is final but container %s did not complete: container state = %q", cr.UUID, cr.ContainerUUID, c.State)
750 return fmt.Errorf("container exited %d", c.ExitCode)