[ARVADOS] created: 1.2.0-323-gb4f1614a5

Git user git at public.curoverse.com
Thu Nov 8 21:36:00 EST 2018


        at  b4f1614a50e00e7a0de718fce693b4ed4ea3a2bb (commit)


commit b4f1614a50e00e7a0de718fce693b4ed4ea3a2bb
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Thu Nov 8 21:32:17 2018 -0500

    14198: Use container token for reading input/creating output
    
    Refactor a bit to make it obvious which token is being used when
    communicating with the API server.  Operations that could involve
    federated collections (reading the Docker image, reading inputs,
    copying remote blocks to local) must use the container token.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 1deb74031..33eb5d02d 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -93,39 +93,42 @@ type PsProcess interface {
 // ContainerRunner is the main stateful struct used for a single execution of a
 // container.
 type ContainerRunner struct {
-	Docker          ThinDockerClient
-	client          *arvados.Client
-	ArvClient       IArvadosClient
-	Kc              IKeepClient
-	Container       arvados.Container
-	ContainerConfig dockercontainer.Config
-	HostConfig      dockercontainer.HostConfig
-	token           string
-	ContainerID     string
-	ExitCode        *int
-	NewLogWriter    NewLogWriter
-	loggingDone     chan bool
-	CrunchLog       *ThrottledLogger
-	Stdout          io.WriteCloser
-	Stderr          io.WriteCloser
-	logUUID         string
-	logMtx          sync.Mutex
-	LogCollection   arvados.CollectionFileSystem
-	LogsPDH         *string
-	RunArvMount     RunArvMount
-	MkTempDir       MkTempDir
-	ArvMount        *exec.Cmd
-	ArvMountPoint   string
-	HostOutputDir   string
-	Binds           []string
-	Volumes         map[string]struct{}
-	OutputPDH       *string
-	SigChan         chan os.Signal
-	ArvMountExit    chan error
-	SecretMounts    map[string]arvados.Mount
-	MkArvClient     func(token string) (IArvadosClient, IKeepClient, error)
-	finalState      string
-	parentTemp      string
+	Docker               ThinDockerClient
+	dispatcherClient     *arvados.Client
+	containerClient      *arvados.Client
+	DispatcherArvClient  IArvadosClient
+	DispatcherKeepClient IKeepClient
+	ContainerArvClient   IArvadosClient
+	ContainerKeepClient  IKeepClient
+	Container            arvados.Container
+	ContainerConfig      dockercontainer.Config
+	HostConfig           dockercontainer.HostConfig
+	token                string
+	ContainerID          string
+	ExitCode             *int
+	NewLogWriter         NewLogWriter
+	loggingDone          chan bool
+	CrunchLog            *ThrottledLogger
+	Stdout               io.WriteCloser
+	Stderr               io.WriteCloser
+	logUUID              string
+	logMtx               sync.Mutex
+	LogCollection        arvados.CollectionFileSystem
+	LogsPDH              *string
+	RunArvMount          RunArvMount
+	MkTempDir            MkTempDir
+	ArvMount             *exec.Cmd
+	ArvMountPoint        string
+	HostOutputDir        string
+	Binds                []string
+	Volumes              map[string]struct{}
+	OutputPDH            *string
+	SigChan              chan os.Signal
+	ArvMountExit         chan error
+	SecretMounts         map[string]arvados.Mount
+	MkArvClient          func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error)
+	finalState           string
+	parentTemp           string
 
 	ListProcesses func() ([]PsProcess, error)
 
@@ -238,17 +241,8 @@ func (runner *ContainerRunner) LoadImage() (err error) {
 
 	runner.CrunchLog.Printf("Fetching Docker image from collection '%s'", runner.Container.ContainerImage)
 
-	tok, err := runner.ContainerToken()
-	if err != nil {
-		return fmt.Errorf("While getting container token (LoadImage): %v", err)
-	}
-	arvClient, kc, err := runner.MkArvClient(tok)
-	if err != nil {
-		return fmt.Errorf("While creating arv client (LoadImage): %v", err)
-	}
-
 	var collection arvados.Collection
-	err = arvClient.Get("collections", runner.Container.ContainerImage, nil, &collection)
+	err = runner.ContainerArvClient.Get("collections", runner.Container.ContainerImage, nil, &collection)
 	if err != nil {
 		return fmt.Errorf("While getting container image collection: %v", err)
 	}
@@ -269,7 +263,7 @@ func (runner *ContainerRunner) LoadImage() (err error) {
 		runner.CrunchLog.Print("Loading Docker image from keep")
 
 		var readCloser io.ReadCloser
-		readCloser, err = kc.ManifestFileReader(manifest, img)
+		readCloser, err = runner.ContainerKeepClient.ManifestFileReader(manifest, img)
 		if err != nil {
 			return fmt.Errorf("While creating ManifestFileReader for container image: %v", err)
 		}
@@ -291,7 +285,7 @@ func (runner *ContainerRunner) LoadImage() (err error) {
 
 	runner.ContainerConfig.Image = imageID
 
-	kc.ClearBlockCache()
+	runner.ContainerKeepClient.ClearBlockCache()
 
 	return nil
 }
@@ -592,7 +586,7 @@ func (runner *ContainerRunner) SetupMounts() (err error) {
 			if err != nil {
 				return fmt.Errorf("creating temp dir: %v", err)
 			}
-			err = gitMount(mnt).extractTree(runner.ArvClient, tmpdir, token)
+			err = gitMount(mnt).extractTree(runner.ContainerArvClient, tmpdir, token)
 			if err != nil {
 				return err
 			}
@@ -859,13 +853,13 @@ func (runner *ContainerRunner) logAPIResponse(label, path string, params map[str
 		return false, err
 	}
 	w := &ArvLogWriter{
-		ArvClient:     runner.ArvClient,
+		ArvClient:     runner.DispatcherArvClient,
 		UUID:          runner.Container.UUID,
 		loggingStream: label,
 		writeCloser:   writer,
 	}
 
-	reader, err := runner.ArvClient.CallRaw("GET", path, "", "", arvadosclient.Dict(params))
+	reader, err := runner.DispatcherArvClient.CallRaw("GET", path, "", "", arvadosclient.Dict(params))
 	if err != nil {
 		return false, fmt.Errorf("error getting %s record: %v", label, err)
 	}
@@ -915,12 +909,14 @@ func (runner *ContainerRunner) AttachStreams() (err error) {
 			if collId == "" {
 				collId = stdinMnt.PortableDataHash
 			}
-			err = runner.ArvClient.Get("collections", collId, nil, &stdinColl)
+			err = runner.ContainerArvClient.Get("collections", collId, nil, &stdinColl)
 			if err != nil {
-				return fmt.Errorf("While getting stding collection: %v", err)
+				return fmt.Errorf("While getting stdin collection: %v", err)
 			}
 
-			stdinRdr, err = runner.Kc.ManifestFileReader(manifest.Manifest{Text: stdinColl.ManifestText}, stdinMnt.Path)
+			stdinRdr, err = runner.ContainerKeepClient.ManifestFileReader(
+				manifest.Manifest{Text: stdinColl.ManifestText},
+				stdinMnt.Path)
 			if os.IsNotExist(err) {
 				return fmt.Errorf("stdin collection path not found: %v", stdinMnt.Path)
 			} else if err != nil {
@@ -1259,7 +1255,7 @@ func (runner *ContainerRunner) updateLogs() {
 		}
 
 		var updated arvados.Container
-		err = runner.ArvClient.Update("containers", runner.Container.UUID, arvadosclient.Dict{
+		err = runner.DispatcherArvClient.Update("containers", runner.Container.UUID, arvadosclient.Dict{
 			"container": arvadosclient.Dict{"log": saved.PortableDataHash},
 		}, &updated)
 		if err != nil {
@@ -1277,7 +1273,7 @@ func (runner *ContainerRunner) CaptureOutput() error {
 	if wantAPI := runner.Container.RuntimeConstraints.API; wantAPI != nil && *wantAPI {
 		// Output may have been set directly by the container, so
 		// refresh the container record to check.
-		err := runner.ArvClient.Get("containers", runner.Container.UUID,
+		err := runner.DispatcherArvClient.Get("containers", runner.Container.UUID,
 			nil, &runner.Container)
 		if err != nil {
 			return err
@@ -1290,9 +1286,9 @@ func (runner *ContainerRunner) CaptureOutput() error {
 	}
 
 	txt, err := (&copier{
-		client:        runner.client,
-		arvClient:     runner.ArvClient,
-		keepClient:    runner.Kc,
+		client:        runner.containerClient,
+		arvClient:     runner.ContainerArvClient,
+		keepClient:    runner.ContainerKeepClient,
 		hostOutputDir: runner.HostOutputDir,
 		ctrOutputDir:  runner.Container.OutputPath,
 		binds:         runner.Binds,
@@ -1305,7 +1301,7 @@ func (runner *ContainerRunner) CaptureOutput() error {
 	}
 	if n := len(regexp.MustCompile(` [0-9a-f]+\+\S*\+R`).FindAllStringIndex(txt, -1)); n > 0 {
 		runner.CrunchLog.Printf("Copying %d data blocks from remote input collections...", n)
-		fs, err := (&arvados.Collection{ManifestText: txt}).FileSystem(runner.client, runner.Kc)
+		fs, err := (&arvados.Collection{ManifestText: txt}).FileSystem(runner.containerClient, runner.ContainerKeepClient)
 		if err != nil {
 			return err
 		}
@@ -1315,7 +1311,7 @@ func (runner *ContainerRunner) CaptureOutput() error {
 		}
 	}
 	var resp arvados.Collection
-	err = runner.ArvClient.Create("collections", arvadosclient.Dict{
+	err = runner.ContainerArvClient.Create("collections", arvadosclient.Dict{
 		"ensure_unique_name": true,
 		"collection": arvadosclient.Dict{
 			"is_trashed":    true,
@@ -1403,7 +1399,7 @@ func (runner *ContainerRunner) CommitLogs() error {
 		// other further errors (such as failing to write the log to Keep!)
 		// while shutting down
 		runner.CrunchLog = NewThrottledLogger(&ArvLogWriter{
-			ArvClient:     runner.ArvClient,
+			ArvClient:     runner.DispatcherArvClient,
 			UUID:          runner.Container.UUID,
 			loggingStream: "crunch-run",
 			writeCloser:   nil,
@@ -1455,9 +1451,9 @@ func (runner *ContainerRunner) saveLogCollection(final bool) (response arvados.C
 	reqBody := arvadosclient.Dict{"collection": updates}
 	if runner.logUUID == "" {
 		reqBody["ensure_unique_name"] = true
-		err = runner.ArvClient.Create("collections", reqBody, &response)
+		err = runner.DispatcherArvClient.Create("collections", reqBody, &response)
 	} else {
-		err = runner.ArvClient.Update("collections", runner.logUUID, reqBody, &response)
+		err = runner.DispatcherArvClient.Update("collections", runner.logUUID, reqBody, &response)
 	}
 	if err != nil {
 		return
@@ -1473,7 +1469,7 @@ func (runner *ContainerRunner) UpdateContainerRunning() error {
 	if runner.cCancelled {
 		return ErrCancelled
 	}
-	return runner.ArvClient.Update("containers", runner.Container.UUID,
+	return runner.DispatcherArvClient.Update("containers", runner.Container.UUID,
 		arvadosclient.Dict{"container": arvadosclient.Dict{"state": "Running"}}, nil)
 }
 
@@ -1485,7 +1481,7 @@ func (runner *ContainerRunner) ContainerToken() (string, error) {
 	}
 
 	var auth arvados.APIClientAuthorization
-	err := runner.ArvClient.Call("GET", "containers", runner.Container.UUID, "auth", nil, &auth)
+	err := runner.DispatcherArvClient.Call("GET", "containers", runner.Container.UUID, "auth", nil, &auth)
 	if err != nil {
 		return "", err
 	}
@@ -1509,7 +1505,7 @@ func (runner *ContainerRunner) UpdateContainerFinal() error {
 			update["output"] = *runner.OutputPDH
 		}
 	}
-	return runner.ArvClient.Update("containers", runner.Container.UUID, arvadosclient.Dict{"container": update}, nil)
+	return runner.DispatcherArvClient.Update("containers", runner.Container.UUID, arvadosclient.Dict{"container": update}, nil)
 }
 
 // IsCancelled returns the value of Cancelled, with goroutine safety.
@@ -1526,7 +1522,7 @@ func (runner *ContainerRunner) NewArvLogWriter(name string) (io.WriteCloser, err
 		return nil, err
 	}
 	return &ArvLogWriter{
-		ArvClient:     runner.ArvClient,
+		ArvClient:     runner.DispatcherArvClient,
 		UUID:          runner.Container.UUID,
 		loggingStream: name,
 		writeCloser:   writer,
@@ -1678,7 +1674,7 @@ func (runner *ContainerRunner) Run() (err error) {
 // Fetch the current container record (uuid = runner.Container.UUID)
 // into runner.Container.
 func (runner *ContainerRunner) fetchContainerRecord() error {
-	reader, err := runner.ArvClient.CallRaw("GET", "containers", runner.Container.UUID, "", nil)
+	reader, err := runner.DispatcherArvClient.CallRaw("GET", "containers", runner.Container.UUID, "", nil)
 	if err != nil {
 		return fmt.Errorf("error fetching container record: %v", err)
 	}
@@ -1700,12 +1696,13 @@ func (runner *ContainerRunner) fetchContainerRecord() error {
 		return fmt.Errorf("error getting container token: %v", err)
 	}
 
-	containerClient, _, err := runner.MkArvClient(containerToken)
+	runner.ContainerArvClient, runner.ContainerKeepClient,
+		runner.containerClient, err = runner.MkArvClient(containerToken)
 	if err != nil {
 		return fmt.Errorf("error creating container API client: %v", err)
 	}
 
-	err = containerClient.Call("GET", "containers", runner.Container.UUID, "secret_mounts", nil, &sm)
+	err = runner.ContainerArvClient.Call("GET", "containers", runner.Container.UUID, "secret_mounts", nil, &sm)
 	if err != nil {
 		if apierr, ok := err.(arvadosclient.APIServerError); !ok || apierr.HttpStatusCode != 404 {
 			return fmt.Errorf("error fetching secret_mounts: %v", err)
@@ -1719,12 +1716,17 @@ func (runner *ContainerRunner) fetchContainerRecord() error {
 }
 
 // NewContainerRunner creates a new container runner.
-func NewContainerRunner(client *arvados.Client, api IArvadosClient, kc IKeepClient, docker ThinDockerClient, containerUUID string) (*ContainerRunner, error) {
+func NewContainerRunner(dispatcherClient *arvados.Client,
+	dispatcherArvClient IArvadosClient,
+	dispatcherKeepClient IKeepClient,
+	docker ThinDockerClient,
+	containerUUID string) (*ContainerRunner, error) {
+
 	cr := &ContainerRunner{
-		client:    client,
-		ArvClient: api,
-		Kc:        kc,
-		Docker:    docker,
+		dispatcherClient:     dispatcherClient,
+		DispatcherArvClient:  dispatcherArvClient,
+		DispatcherKeepClient: dispatcherKeepClient,
+		Docker:               docker,
 	}
 	cr.NewLogWriter = cr.NewArvLogWriter
 	cr.RunArvMount = cr.ArvMountCmd
@@ -1740,20 +1742,22 @@ func NewContainerRunner(client *arvados.Client, api IArvadosClient, kc IKeepClie
 		}
 		return ps, nil
 	}
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
+	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
 		cl, err := arvadosclient.MakeArvadosClient()
 		if err != nil {
-			return nil, nil, err
+			return nil, nil, nil, err
 		}
 		cl.ApiToken = token
 		kc, err := keepclient.MakeKeepClient(cl)
 		if err != nil {
-			return nil, nil, err
+			return nil, nil, nil, err
 		}
-		return cl, kc, nil
+		c2 := arvados.NewClientFromEnv()
+		c2.AuthToken = token
+		return cl, kc, c2, nil
 	}
 	var err error
-	cr.LogCollection, err = (&arvados.Collection{}).FileSystem(cr.client, cr.Kc)
+	cr.LogCollection, err = (&arvados.Collection{}).FileSystem(cr.dispatcherClient, cr.DispatcherKeepClient)
 	if err != nil {
 		return nil, err
 	}
@@ -1765,7 +1769,7 @@ func NewContainerRunner(client *arvados.Client, api IArvadosClient, kc IKeepClie
 	cr.CrunchLog = NewThrottledLogger(w)
 	cr.CrunchLog.Immediate = log.New(os.Stderr, containerUUID+" ", 0)
 
-	loadLogThrottleParams(api)
+	loadLogThrottleParams(dispatcherArvClient)
 	go cr.updateLogs()
 
 	return cr, nil
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index 0df048cc8..7b324ce9a 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -442,14 +442,14 @@ func (client *KeepTestClient) ManifestFileReader(m manifest.Manifest, filename s
 }
 
 func (s *TestSuite) TestLoadImage(c *C) {
-	kc := &KeepTestClient{}
-	defer kc.Close()
-	cr, err := NewContainerRunner(s.client, &ArvTestClient{}, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
+	cr, err := NewContainerRunner(s.client, &ArvTestClient{},
+		&KeepTestClient{}, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 	c.Assert(err, IsNil)
 
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{}, kc, nil
-	}
+	kc := &KeepTestClient{}
+	defer kc.Close()
+	cr.ContainerArvClient = &ArvTestClient{}
+	cr.ContainerKeepClient = kc
 
 	_, err = cr.Docker.ImageRemove(nil, hwImageId, dockertypes.ImageRemoveOptions{})
 	c.Check(err, IsNil)
@@ -566,10 +566,10 @@ func (s *TestSuite) TestLoadImageArvError(c *C) {
 	cr, err := NewContainerRunner(s.client, &ArvErrorTestClient{}, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 	c.Assert(err, IsNil)
 
+	cr.ContainerArvClient = &ArvErrorTestClient{}
+	cr.ContainerKeepClient = &KeepTestClient{}
+
 	cr.Container.ContainerImage = hwPDH
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvErrorTestClient{}, &KeepTestClient{}, nil
-	}
 
 	err = cr.LoadImage()
 	c.Check(err.Error(), Equals, "While getting container image collection: ArvError")
@@ -580,10 +580,11 @@ func (s *TestSuite) TestLoadImageKeepError(c *C) {
 	kc := &KeepErrorTestClient{}
 	cr, err := NewContainerRunner(s.client, &ArvTestClient{}, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 	c.Assert(err, IsNil)
+
+	cr.ContainerArvClient = &ArvTestClient{}
+	cr.ContainerKeepClient = &KeepErrorTestClient{}
+
 	cr.Container.ContainerImage = hwPDH
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{}, kc, nil
-	}
 
 	err = cr.LoadImage()
 	c.Assert(err, NotNil)
@@ -596,9 +597,9 @@ func (s *TestSuite) TestLoadImageCollectionError(c *C) {
 	cr, err := NewContainerRunner(s.client, &ArvTestClient{}, kc, nil, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 	c.Assert(err, IsNil)
 	cr.Container.ContainerImage = otherPDH
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{}, kc, nil
-	}
+
+	cr.ContainerArvClient = &ArvTestClient{}
+	cr.ContainerKeepClient = &KeepReadErrorTestClient{}
 
 	err = cr.LoadImage()
 	c.Check(err.Error(), Equals, "First file in the container image collection does not end in .tar")
@@ -610,9 +611,8 @@ func (s *TestSuite) TestLoadImageKeepReadError(c *C) {
 	cr, err := NewContainerRunner(s.client, &ArvTestClient{}, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 	c.Assert(err, IsNil)
 	cr.Container.ContainerImage = hwPDH
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{}, kc, nil
-	}
+	cr.ContainerArvClient = &ArvTestClient{}
+	cr.ContainerKeepClient = &KeepReadErrorTestClient{}
 
 	err = cr.LoadImage()
 	c.Check(err, NotNil)
@@ -660,9 +660,8 @@ func (s *TestSuite) TestRunContainer(c *C) {
 	cr, err := NewContainerRunner(s.client, &ArvTestClient{}, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 	c.Assert(err, IsNil)
 
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{}, kc, nil
-	}
+	cr.ContainerArvClient = &ArvTestClient{}
+	cr.ContainerKeepClient = &KeepTestClient{}
 
 	var logs TestLogs
 	cr.NewLogWriter = logs.NewTestLoggingWriter
@@ -807,8 +806,8 @@ func (s *TestSuite) fullRunHelper(c *C, record string, extraMounts []string, exi
 		}
 		return d, err
 	}
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{secretMounts: secretMounts}, &KeepTestClient{}, nil
+	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
+		return &ArvTestClient{secretMounts: secretMounts}, &KeepTestClient{}, nil, nil
 	}
 
 	if extraMounts != nil && len(extraMounts) > 0 {
@@ -1104,8 +1103,8 @@ func (s *TestSuite) testStopContainer(c *C, setup func(cr *ContainerRunner)) {
 	cr, err := NewContainerRunner(s.client, api, kc, s.docker, "zzzzz-zzzzz-zzzzzzzzzzzzzzz")
 	c.Assert(err, IsNil)
 	cr.RunArvMount = func([]string, string) (*exec.Cmd, error) { return nil, nil }
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{}, &KeepTestClient{}, nil
+	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
+		return &ArvTestClient{}, &KeepTestClient{}, nil, nil
 	}
 	setup(cr)
 
@@ -1177,6 +1176,8 @@ func (s *TestSuite) TestSetupMounts(c *C) {
 	c.Assert(err, IsNil)
 	am := &ArvMountCmdLine{}
 	cr.RunArvMount = am.ArvMountTest
+	cr.ContainerArvClient = &ArvTestClient{}
+	cr.ContainerKeepClient = &KeepTestClient{}
 
 	realTemp, err := ioutil.TempDir("", "crunchrun_test1-")
 	c.Assert(err, IsNil)
@@ -1562,14 +1563,14 @@ func (s *TestSuite) TestStdout(c *C) {
 		"runtime_constraints": {}
 	}`
 
-	api, _, _ := s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
+	api, cr, _ := s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
 		t.logWriter.Write(dockerLog(1, t.env[0][7:]+"\n"))
 		t.logWriter.Close()
 	})
 
 	c.Check(api.CalledWith("container.exit_code", 0), NotNil)
 	c.Check(api.CalledWith("container.state", "Complete"), NotNil)
-	c.Check(api.CalledWith("collection.manifest_text", "./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out\n"), NotNil)
+	c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", "./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out\n"), NotNil)
 }
 
 // Used by the TestStdoutWithWrongPath*()
@@ -1588,8 +1589,8 @@ func (s *TestSuite) stdoutErrorRunHelper(c *C, record string, fn func(t *TestDoc
 	c.Assert(err, IsNil)
 	am := &ArvMountCmdLine{}
 	cr.RunArvMount = am.ArvMountTest
-	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, error) {
-		return &ArvTestClient{}, &KeepTestClient{}, nil
+	cr.MkArvClient = func(token string) (IArvadosClient, IKeepClient, *arvados.Client, error) {
+		return &ArvTestClient{}, &KeepTestClient{}, nil, nil
 	}
 
 	err = cr.Run()
@@ -1692,14 +1693,14 @@ func (s *TestSuite) TestStdoutWithExcludeFromOutputMountPointUnderOutputDir(c *C
 
 	extraMounts := []string{"a3e8f74c6f101eae01fa08bfb4e49b3a+54"}
 
-	api, _, _ := s.fullRunHelper(c, helperRecord, extraMounts, 0, func(t *TestDockerClient) {
+	api, cr, _ := s.fullRunHelper(c, helperRecord, extraMounts, 0, func(t *TestDockerClient) {
 		t.logWriter.Write(dockerLog(1, t.env[0][7:]+"\n"))
 		t.logWriter.Close()
 	})
 
 	c.Check(api.CalledWith("container.exit_code", 0), NotNil)
 	c.Check(api.CalledWith("container.state", "Complete"), NotNil)
-	c.Check(api.CalledWith("collection.manifest_text", "./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out\n"), NotNil)
+	c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", "./a/b 307372fa8fd5c146b22ae7a45b49bc31+6 0:6:c.out\n"), NotNil)
 }
 
 func (s *TestSuite) TestStdoutWithMultipleMountPointsUnderOutputDir(c *C) {
@@ -1899,7 +1900,7 @@ func (s *TestSuite) TestStdinJsonMountPoint(c *C) {
 }
 
 func (s *TestSuite) TestStderrMount(c *C) {
-	api, _, _ := s.fullRunHelper(c, `{
+	api, cr, _ := s.fullRunHelper(c, `{
     "command": ["/bin/sh", "-c", "echo hello;exit 1"],
     "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
     "cwd": ".",
@@ -1921,7 +1922,7 @@ func (s *TestSuite) TestStderrMount(c *C) {
 	c.Check(final["container"].(arvadosclient.Dict)["exit_code"], Equals, 1)
 	c.Check(final["container"].(arvadosclient.Dict)["log"], NotNil)
 
-	c.Check(api.CalledWith("collection.manifest_text", "./a b1946ac92492d2347c6235b4d2611184+6 0:6:out.txt\n./b 38af5c54926b620264ab1501150cf189+5 0:5:err.txt\n"), NotNil)
+	c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", "./a b1946ac92492d2347c6235b4d2611184+6 0:6:out.txt\n./b 38af5c54926b620264ab1501150cf189+5 0:5:err.txt\n"), NotNil)
 }
 
 func (s *TestSuite) TestNumberRoundTrip(c *C) {
@@ -2100,7 +2101,7 @@ func (s *TestSuite) TestSecretTextMountPoint(c *C) {
 		"runtime_constraints": {}
 	}`
 
-	api, _, _ := s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
+	api, cr, _ := s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
 		content, err := ioutil.ReadFile(t.realTemp + "/tmp2/secret.conf")
 		c.Check(err, IsNil)
 		c.Check(content, DeepEquals, []byte("mypassword"))
@@ -2109,8 +2110,8 @@ func (s *TestSuite) TestSecretTextMountPoint(c *C) {
 
 	c.Check(api.CalledWith("container.exit_code", 0), NotNil)
 	c.Check(api.CalledWith("container.state", "Complete"), NotNil)
-	c.Check(api.CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), NotNil)
-	c.Check(api.CalledWith("collection.manifest_text", ""), IsNil)
+	c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), NotNil)
+	c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ""), IsNil)
 
 	// under secret mounts, not captured in output
 	helperRecord = `{
@@ -2128,7 +2129,7 @@ func (s *TestSuite) TestSecretTextMountPoint(c *C) {
 		"runtime_constraints": {}
 	}`
 
-	api, _, _ = s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
+	api, cr, _ = s.fullRunHelper(c, helperRecord, nil, 0, func(t *TestDockerClient) {
 		content, err := ioutil.ReadFile(t.realTemp + "/tmp2/secret.conf")
 		c.Check(err, IsNil)
 		c.Check(content, DeepEquals, []byte("mypassword"))
@@ -2137,8 +2138,8 @@ func (s *TestSuite) TestSecretTextMountPoint(c *C) {
 
 	c.Check(api.CalledWith("container.exit_code", 0), NotNil)
 	c.Check(api.CalledWith("container.state", "Complete"), NotNil)
-	c.Check(api.CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), IsNil)
-	c.Check(api.CalledWith("collection.manifest_text", ""), NotNil)
+	c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ". 34819d7beeabb9260a5c854bc85b3e44+10 0:10:secret.conf\n"), IsNil)
+	c.Check(cr.ContainerArvClient.(*ArvTestClient).CalledWith("collection.manifest_text", ""), NotNil)
 }
 
 type FakeProcess struct {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list