From: Tom Clegg Date: Tue, 12 Jul 2022 19:31:41 +0000 (-0400) Subject: 17344: Load alpine docker image for diagnostics. X-Git-Tag: 2.5.0~115^2~15 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/ba1114ac181b6648a798385058e6c18d92ec56ef 17344: Load alpine docker image for diagnostics. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/lib/diagnostics/cmd.go b/lib/diagnostics/cmd.go index 71fe1c5dc6..467c2f0b51 100644 --- a/lib/diagnostics/cmd.go +++ b/lib/diagnostics/cmd.go @@ -30,6 +30,7 @@ func (Command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s f := flag.NewFlagSet(prog, flag.ContinueOnError) 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") f.StringVar(&diag.logLevel, "log-level", "info", "logging level (debug, info, warning, error)") + f.StringVar(&diag.dockerImage, "docker-image", "alpine:latest", "image to use when running a test container") 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, or 0 to skip)") @@ -60,6 +61,7 @@ type diagnoser struct { logLevel string priority int projectName string + dockerImage string checkInternal bool checkExternal bool timeout time.Duration @@ -545,7 +547,7 @@ func (diag *diagnoser) runtests() { err := client.RequestAndDecodeContext(ctx, &cr, "POST", "arvados/v1/container_requests", nil, map[string]interface{}{"container_request": map[string]interface{}{ "owner_uuid": project.UUID, "name": fmt.Sprintf("diagnostics container request %s", timestamp), - "container_image": "arvados/jobs", + "container_image": diag.dockerImage, "command": []string{"echo", timestamp}, "use_existing": false, "output_path": "/mnt/output", diff --git a/lib/install/init.go b/lib/install/init.go index 11a62f18e9..3eeac5c549 100644 --- a/lib/install/init.go +++ b/lib/install/init.go @@ -351,6 +351,29 @@ func (initcmd *initCommand) RunCommand(prog string, args []string, stdin io.Read fmt.Fprintln(stderr, "...looks good") } + if out, err := exec.CommandContext(ctx, "docker", "version").CombinedOutput(); err == nil && strings.Contains(string(out), "\nServer:\n") { + fmt.Fprintln(stderr, "loading alpine docker image for diagnostics...") + cmd := exec.CommandContext(ctx, "docker", "pull", "alpine") + cmd.Stdout = stderr + cmd.Stderr = stderr + err = cmd.Run() + if err != nil { + err = fmt.Errorf("%v: %w", cmd.Args, err) + return 1 + } + cmd = exec.CommandContext(ctx, "arv", "root", "keep", "docker", "alpine") + cmd.Stdout = stderr + cmd.Stderr = stderr + err = cmd.Run() + if err != nil { + err = fmt.Errorf("%v: %w", cmd.Args, err) + return 1 + } + fmt.Fprintln(stderr, "...done") + } else { + fmt.Fprintln(stderr, "docker is not installed -- skipping step of downloading 'alpine' image") + } + fmt.Fprintln(stderr, "Setup complete. You should now be able to log in to workbench2 at", cluster.Services.Workbench2.ExternalURL.String()) return 0