[ARVADOS] updated: ea1d4703fbfb94f2632005bc570e65873c802b66

git at public.curoverse.com git at public.curoverse.com
Sun Feb 14 00:26:40 EST 2016


Summary of changes:
 services/crunch-run/crunchrun.go | 30 ++++++++++++++++++------------
 services/crunch-run/logging.go   |  7 ++++---
 2 files changed, 22 insertions(+), 15 deletions(-)

       via  ea1d4703fbfb94f2632005bc570e65873c802b66 (commit)
      from  070fdce365074a76d4da2e118574fd1d4f3515c5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit ea1d4703fbfb94f2632005bc570e65873c802b66
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Sun Feb 14 00:26:05 2016 -0500

    8015: Fix create and update API calls to use correct nested dict.

diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index d197fa9..9c52f18 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -398,7 +398,9 @@ func (runner *ContainerRunner) CaptureOutput() error {
 
 	var response CollectionRecord
 	err = runner.ArvClient.Create("collections",
-		arvadosclient.Dict{"manifest_text": manifestText},
+		arvadosclient.Dict{
+			"collection": arvadosclient.Dict{
+				"manifest_text": manifestText}},
 		&response)
 	if err != nil {
 		return fmt.Errorf("While creating output collection: %v", err)
@@ -429,8 +431,10 @@ func (runner *ContainerRunner) CommitLogs() error {
 
 	var response CollectionRecord
 	err = runner.ArvClient.Create("collections",
-		arvadosclient.Dict{"name": "logs for " + runner.ContainerRecord.UUID,
-			"manifest_text": mt},
+		arvadosclient.Dict{
+			"collection": arvadosclient.Dict{
+				"name":          "logs for " + runner.ContainerRecord.UUID,
+				"manifest_text": mt}},
 		&response)
 	if err != nil {
 		return fmt.Errorf("While creating log collection: %v", err)
@@ -444,8 +448,8 @@ func (runner *ContainerRunner) CommitLogs() error {
 
 // UpdateContainerRecordRunning updates the container state to "Running"
 func (runner *ContainerRunner) UpdateContainerRecordRunning() error {
-	update := arvadosclient.Dict{"state": "Running"}
-	return runner.ArvClient.Update("containers", runner.ContainerRecord.UUID, update, nil)
+	return runner.ArvClient.Update("containers", runner.ContainerRecord.UUID,
+		arvadosclient.Dict{"container": arvadosclient.Dict{"state": "Running"}}, nil)
 }
 
 // UpdateContainerRecordComplete updates the container record state on API
@@ -464,7 +468,7 @@ func (runner *ContainerRunner) UpdateContainerRecordComplete() error {
 
 	update["state"] = runner.finalState
 
-	return runner.ArvClient.Update("containers", runner.ContainerRecord.UUID, update, nil)
+	return runner.ArvClient.Update("containers", runner.ContainerRecord.UUID, arvadosclient.Dict{"container": update}, nil)
 }
 
 // NewArvLogWriter creates an ArvLogWriter
@@ -473,8 +477,8 @@ func (runner *ContainerRunner) NewArvLogWriter(name string) io.WriteCloser {
 }
 
 // Run the full container lifecycle.
-func (runner *ContainerRunner) Run(containerUUID string) (err error) {
-	runner.CrunchLog.Printf("Executing container '%s'", containerUUID)
+func (runner *ContainerRunner) Run() (err error) {
+	runner.CrunchLog.Printf("Executing container '%s'", runner.ContainerRecord.UUID)
 
 	var runerr, waiterr error
 
@@ -522,7 +526,7 @@ func (runner *ContainerRunner) Run(containerUUID string) (err error) {
 		}
 	}()
 
-	err = runner.ArvClient.Get("containers", containerUUID, nil, &runner.ContainerRecord)
+	err = runner.ArvClient.Get("containers", runner.ContainerRecord.UUID, nil, &runner.ContainerRecord)
 	if err != nil {
 		return fmt.Errorf("While getting container record: %v", err)
 	}
@@ -575,11 +579,13 @@ func (runner *ContainerRunner) Run(containerUUID string) (err error) {
 // NewContainerRunner creates a new container runner.
 func NewContainerRunner(api IArvadosClient,
 	kc IKeepClient,
-	docker ThinDockerClient) *ContainerRunner {
+	docker ThinDockerClient,
+	containerUUID string) *ContainerRunner {
 
 	cr := &ContainerRunner{ArvClient: api, Kc: kc, Docker: docker}
 	cr.NewLogWriter = cr.NewArvLogWriter
 	cr.LogCollection = &CollectionWriter{kc, nil, sync.Mutex{}}
+	cr.ContainerRecord.UUID = containerUUID
 	cr.CrunchLog = NewThrottledLogger(cr.NewLogWriter("crunch-run"))
 	return cr
 }
@@ -606,9 +612,9 @@ func main() {
 		log.Fatal(err)
 	}
 
-	cr := NewContainerRunner(api, kc, docker)
+	cr := NewContainerRunner(api, kc, docker, flag.Arg(0))
 
-	err = cr.Run(flag.Arg(0))
+	err = cr.Run()
 	if err != nil {
 		log.Fatal(err)
 	}
diff --git a/services/crunch-run/logging.go b/services/crunch-run/logging.go
index 9d97384..09b328a 100644
--- a/services/crunch-run/logging.go
+++ b/services/crunch-run/logging.go
@@ -180,9 +180,10 @@ func (arvlog *ArvLogWriter) Write(p []byte) (n int, err error) {
 	}
 
 	// write to API
-	lr := arvadosclient.Dict{"object_uuid": arvlog.UUID,
-		"event_type": arvlog.loggingStream,
-		"properties": map[string]string{"text": string(p)}}
+	lr := arvadosclient.Dict{"log": arvadosclient.Dict{
+		"object_uuid": arvlog.UUID,
+		"event_type":  arvlog.loggingStream,
+		"properties":  map[string]string{"text": string(p)}}}
 	err2 := arvlog.ArvClient.Create("logs", lr, nil)
 
 	if err1 != nil || err2 != nil {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list