projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '17948-test-collection-tool' into main. Closes #17948
[arvados.git]
/
lib
/
crunchrun
/
docker.go
diff --git
a/lib/crunchrun/docker.go
b/lib/crunchrun/docker.go
index a39b754b3d396e4c02c75a518d47940dab9212f7..656061b77ec552a811c26dfe18be870b154c1b1e 100644
(file)
--- a/
lib/crunchrun/docker.go
+++ b/
lib/crunchrun/docker.go
@@
-11,6
+11,7
@@
import (
"strings"
"time"
"strings"
"time"
+ "git.arvados.org/arvados.git/sdk/go/arvados"
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
dockerclient "github.com/docker/docker/client"
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
dockerclient "github.com/docker/docker/client"
@@
-45,13
+46,15
@@
func newDockerExecutor(containerUUID string, logf func(string, ...interface{}),
}, err
}
}, err
}
-func (e *dockerExecutor) ImageLoaded(imageID string) bool {
+func (e *dockerExecutor) LoadImage(imageID string, imageTarballPath string, container arvados.Container, arvMountPoint string,
+ containerClient *arvados.Client) error {
_, _, err := e.dockerclient.ImageInspectWithRaw(context.TODO(), imageID)
_, _, err := e.dockerclient.ImageInspectWithRaw(context.TODO(), imageID)
- return err == nil
-}
+ if err == nil {
+ // already loaded
+ return nil
+ }
-func (e *dockerExecutor) LoadImage(filename string) error {
- f, err := os.Open(filename)
+ f, err := os.Open(imageTarballPath)
if err != nil {
return err
}
if err != nil {
return err
}
@@
-186,7
+189,7
@@
func (e *dockerExecutor) Wait(ctx context.Context) (int, error) {
}
}
}
}
-func (e *dockerExecutor) startIO(stdin io.Read
Closer, stdout, stderr io.WriteClos
er) error {
+func (e *dockerExecutor) startIO(stdin io.Read
er, stdout, stderr io.Writ
er) error {
resp, err := e.dockerclient.ContainerAttach(context.TODO(), e.containerID, dockertypes.ContainerAttachOptions{
Stream: true,
Stdin: stdin != nil,
resp, err := e.dockerclient.ContainerAttach(context.TODO(), e.containerID, dockertypes.ContainerAttachOptions{
Stream: true,
Stdin: stdin != nil,
@@
-213,8
+216,7
@@
func (e *dockerExecutor) startIO(stdin io.ReadCloser, stdout, stderr io.WriteClo
return nil
}
return nil
}
-func (e *dockerExecutor) handleStdin(stdin io.ReadCloser, conn io.Writer, closeConn func() error) error {
- defer stdin.Close()
+func (e *dockerExecutor) handleStdin(stdin io.Reader, conn io.Writer, closeConn func() error) error {
defer closeConn()
_, err := io.Copy(conn, stdin)
if err != nil {
defer closeConn()
_, err := io.Copy(conn, stdin)
if err != nil {
@@
-225,7
+227,7
@@
func (e *dockerExecutor) handleStdin(stdin io.ReadCloser, conn io.Writer, closeC
// Handle docker log protocol; see
// https://docs.docker.com/engine/reference/api/docker_remote_api_v1.15/#attach-to-a-container
// Handle docker log protocol; see
// https://docs.docker.com/engine/reference/api/docker_remote_api_v1.15/#attach-to-a-container
-func (e *dockerExecutor) handleStdoutStderr(stdout, stderr io.Write
Close
r, reader io.Reader) error {
+func (e *dockerExecutor) handleStdoutStderr(stdout, stderr io.Writer, reader io.Reader) error {
header := make([]byte, 8)
var err error
for err == nil {
header := make([]byte, 8)
var err error
for err == nil {
@@
-247,14
+249,6
@@
func (e *dockerExecutor) handleStdoutStderr(stdout, stderr io.WriteCloser, reade
if err != nil {
return fmt.Errorf("error copying stdout/stderr from docker: %v", err)
}
if err != nil {
return fmt.Errorf("error copying stdout/stderr from docker: %v", err)
}
- err = stdout.Close()
- if err != nil {
- return fmt.Errorf("error writing stdout: close: %v", err)
- }
- err = stderr.Close()
- if err != nil {
- return fmt.Errorf("error writing stderr: close: %v", err)
- }
return nil
}
return nil
}