diff --git a/cli/docker.go b/cli/docker.go index 190b282..928a7c2 100644 --- a/cli/docker.go +++ b/cli/docker.go @@ -648,7 +648,7 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Docker bootDir := filepath.Join(imgMeta.HomeDir, ".coder") blog.Infof("Creating %q directory to host Coder assets...", bootDir) - _, _, err = dockerutil.ExecContainer(ctx, client, dockerutil.ExecConfig{ + _, err = dockerutil.ExecContainer(ctx, client, dockerutil.ExecConfig{ ContainerID: containerID, User: imgMeta.UID, Cmd: "mkdir", diff --git a/dockerutil/container.go b/dockerutil/container.go index 4c72c89..1d27d4e 100644 --- a/dockerutil/container.go +++ b/dockerutil/container.go @@ -114,7 +114,7 @@ func BootstrapContainer(ctx context.Context, client DockerClient, conf Bootstrap var err error for r, n := retry.New(time.Second, time.Second*2), 0; r.Wait(ctx) && n < 10; n++ { var out io.Reader - out, _, err = ExecContainer(ctx, client, ExecConfig{ + out, err = ExecContainer(ctx, client, ExecConfig{ ContainerID: conf.ContainerID, User: conf.User, Cmd: "/bin/sh", diff --git a/dockerutil/exec.go b/dockerutil/exec.go index 964e406..47423ed 100644 --- a/dockerutil/exec.go +++ b/dockerutil/exec.go @@ -26,7 +26,7 @@ type ExecConfig struct { // ExecContainer runs a command in a container. It returns the output and any error. // If an error occurs during the execution of the command, the output is appended to the error. -func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig) (io.Reader, int, error) { +func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig) (io.Reader, error) { exec, err := client.ContainerExecCreate(ctx, config.ContainerID, dockertypes.ExecConfig{ Detach: config.Detach, Cmd: append([]string{config.Cmd}, config.Args...), @@ -37,23 +37,23 @@ func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig) Env: config.Env, }) if err != nil { - return nil, 0, xerrors.Errorf("exec create: %w", err) + return nil, xerrors.Errorf("exec create: %w", err) } resp, err := client.ContainerExecAttach(ctx, exec.ID, dockertypes.ExecStartCheck{}) if err != nil { - return nil, 0, xerrors.Errorf("attach to exec: %w", err) + return nil, xerrors.Errorf("attach to exec: %w", err) } defer resp.Close() if config.Stdin != nil { _, err = io.Copy(resp.Conn, config.Stdin) if err != nil { - return nil, 0, xerrors.Errorf("copy stdin: %w", err) + return nil, xerrors.Errorf("copy stdin: %w", err) } err = resp.CloseWrite() if err != nil { - return nil, 0, xerrors.Errorf("close write: %w", err) + return nil, xerrors.Errorf("close write: %w", err) } } @@ -75,24 +75,24 @@ func ExecContainer(ctx context.Context, client DockerClient, config ExecConfig) _, err = io.Copy(wr, resp.Reader) if err != nil { - return nil, 0, xerrors.Errorf("copy cmd output: %w", err) + return nil, xerrors.Errorf("copy cmd output: %w", err) } resp.Close() inspect, err := client.ContainerExecInspect(ctx, exec.ID) if err != nil { - return nil, 0, xerrors.Errorf("exec inspect: %w", err) + return nil, xerrors.Errorf("exec inspect: %w", err) } if inspect.Running { - return nil, 0, xerrors.Errorf("unexpectedly still running") + return nil, xerrors.Errorf("unexpectedly still running") } if inspect.ExitCode > 0 { - return nil, 0, xerrors.Errorf("%s: exit code %d", buf.Bytes(), inspect.ExitCode) + return nil, xerrors.Errorf("%s: exit code %d", buf.Bytes(), inspect.ExitCode) } - return &buf, inspect.Pid, nil + return &buf, nil } func GetExecPID(ctx context.Context, client DockerClient, execID string) (int, error) { diff --git a/dockerutil/image.go b/dockerutil/image.go index 257cf50..5d545d2 100644 --- a/dockerutil/image.go +++ b/dockerutil/image.go @@ -191,14 +191,14 @@ func GetImageMetadata(ctx context.Context, client DockerClient, image, username return ImageMetadata{}, xerrors.Errorf("CVMs do not support NFS volumes") } - _, _, err = ExecContainer(ctx, client, ExecConfig{ + _, err = ExecContainer(ctx, client, ExecConfig{ ContainerID: inspect.ID, Cmd: "stat", Args: []string{"/sbin/init"}, }) initExists := err == nil - out, _, err := ExecContainer(ctx, client, ExecConfig{ + out, err := ExecContainer(ctx, client, ExecConfig{ ContainerID: inspect.ID, Cmd: "getent", Args: []string{"passwd", username}, diff --git a/integration/integrationtest/docker.go b/integration/integrationtest/docker.go index 4ee8412..088952c 100644 --- a/integration/integrationtest/docker.go +++ b/integration/integrationtest/docker.go @@ -33,7 +33,7 @@ const ( HelloWorldImage = "gcr.io/coder-dev-1/sreya/hello-world" // UbuntuImage is just vanilla ubuntu (80MB) but the user is set to a non-root // user . - UbuntuImage = "gcr.io/coder-dev-1/sreya/ubuntu-coder:jon" + UbuntuImage = "gcr.io/coder-dev-1/sreya/ubuntu-coder" ) // TODO use df to determine if an environment is running in a docker container or not.