Added getImage() setImage() to the ThinContainerExecRunner interface
authorNico Cesar <nico@nicocesar.com>
Tue, 16 Mar 2021 15:25:25 +0000 (11:25 -0400)
committerNico Cesar <nico@nicocesar.com>
Tue, 16 Mar 2021 15:25:25 +0000 (11:25 -0400)
Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico@curii.com>

build/run-tests.sh
lib/crunchrun/container_exec_types.go
lib/crunchrun/crunchrun.go
lib/crunchrun/crunchrun_test.go
lib/crunchrun/docker_adapter.go
lib/crunchrun/singularity.go

index d6dc43416a5bc8bf8e3aab56c0a5df78c2e759e5..4a2a12c17e162c64d722d22d86785d3bfcc71051 100755 (executable)
@@ -964,7 +964,7 @@ install_services/api() {
         set -ex
         cd "$WORKSPACE/services/api"
         export RAILS_ENV=test
-        if "$bundle" exec rails db:environment:set ; then
+        if bin/rails db:environment:set ; then
             "$bundle" exec rake db:drop
         fi
         "$bundle" exec rake db:setup
index cc78a29dff681d36a648bc2f5b9682f6ceaaba64..fc865af73e9cfd543dd5d97a448e81f89c1887e7 100644 (file)
@@ -19,6 +19,7 @@ import (
 // "It should hold only portable information about the container."
 // and for Singularity TBD
 type ContainerConfig struct {
+       Image        string
        OpenStdin    bool
        StdinOnce    bool
        AttachStdin  bool
@@ -280,6 +281,9 @@ type ThinContainerExecRunner interface {
        GetContainerConfig() (ContainerConfig, error)
        GetHostConfig() (HostConfig, error)
 
+       GetImage() (imageID string)
+       SetImage(imageID string)
+
        ContainerAttach(ctx context.Context, container string, options ContainerAttachOptions) (HijackedResponse, error)
        ContainerCreate(ctx context.Context, config ContainerConfig, hostConfig HostConfig, networkingConfig *NetworkingConfig, containerName string) (ContainerCreateResponse, error)
        ContainerStart(ctx context.Context, container string, options ContainerStartOptions) error
index fb6aaee9996d4e6dd03f371bb685cea2919e5c14..ad10b6f9cfcf89327413537a1a930247c5143476 100644 (file)
@@ -98,8 +98,8 @@ type ContainerRunner struct {
        ContainerExecRunner ThinContainerExecRunner
 
        //Docker          ThinDockerClient
-       ContainerConfig dockercontainer.Config     //FIXME: translate this to the ThinContainerRunner interface
-       HostConfig      dockercontainer.HostConfig //FIXME: translate this to the ThinContainerRunner interface
+       //ContainerConfig dockercontainer.Config     //FIXME: translate this to the ThinContainerRunner interface
+       HostConfig dockercontainer.HostConfig //FIXME: translate this to the ThinContainerRunner interface
        //--------------
 
        // Dispatcher client is initialized with the Dispatcher token.
@@ -311,7 +311,7 @@ func (runner *ContainerRunner) LoadImage() (err error) {
                runner.CrunchLog.Print("Docker image is available")
        }
 
-       runner.ContainerConfig.Image = imageID
+       runner.ContainerExecRunner.SetImage(imageID)
 
        runner.ContainerKeepClient.ClearBlockCache()
 
index ddf40543e7102aa702c576a5a47620c09176bef2..08f3a938dd6a913e96eb8da23713ef00f1d8ccf9 100644 (file)
@@ -457,7 +457,7 @@ func (s *TestSuite) TestLoadImage(c *C) {
 
        // (1) Test loading image from keep
        c.Check(kc.Called, Equals, false)
-       c.Check(cr.ContainerConfig.Image, Equals, "")
+       c.Check(cr.ContainerExecRunner.GetImage(), Equals, "")
 
        err = cr.LoadImage()
 
@@ -467,19 +467,19 @@ func (s *TestSuite) TestLoadImage(c *C) {
        }()
 
        c.Check(kc.Called, Equals, true)
-       c.Check(cr.ContainerConfig.Image, Equals, hwImageID)
+       c.Check(cr.ContainerExecRunner.GetImage(), Equals, hwImageID)
 
        _, _, err = cr.ContainerExecRunner.ImageInspectWithRaw(nil, hwImageID)
        c.Check(err, IsNil)
 
        // (2) Test using image that's already loaded
        kc.Called = false
-       cr.ContainerConfig.Image = ""
+       cr.ContainerExecRunner.SetImage("")
 
        err = cr.LoadImage()
        c.Check(err, IsNil)
        c.Check(kc.Called, Equals, false)
-       c.Check(cr.ContainerConfig.Image, Equals, hwImageID)
+       c.Check(cr.ContainerExecRunner.GetImage(), Equals, hwImageID)
 
 }
 
index 795d06b567d5ac38ff9336ac28038fc0fb0900bf..1019e7df7bff22efff67bb9a340d47fc696c3980 100644 (file)
@@ -211,6 +211,13 @@ func (a *DockerAdapter) GetContainerConfig() (ContainerConfig, error) {
 func (a *DockerAdapter) GetHostConfig() (HostConfig, error) {
        return a.hostConfig, nil
 }
+func (a *DockerAdapter) GetImage() (imageID string) {
+       return a.containerConfig.Image
+}
+
+func (a *DockerAdapter) SetImage(imageID string) {
+       a.containerConfig.Image = imageID
+}
 
 func adapter(docker ThinDockerClient) ThinContainerExecRunner {
        return_object := &DockerAdapter{docker: docker}
index 91ec0ea11418c68db637fd8fb9ae1ba530708740..6b36e68669b5e772871330bd224f2e21009e8877 100644 (file)
@@ -24,6 +24,14 @@ func (c SingularityClient) GetHostConfig() (HostConfig, error) {
        return c.hostConfig, nil
 }
 
+func (c SingularityClient) GetImage() (imageID string) {
+       return c.containerConfig.Image
+}
+
+func (c SingularityClient) SetImage(imageID string) {
+       c.containerConfig.Image = imageID
+}
+
 func (c SingularityClient) ContainerAttach(ctx context.Context, container string, options ContainerAttachOptions) (HijackedResponse, error) {
        fmt.Printf("placeholder for container ContainerAttach %s", container)