[ARVADOS] created: 4076bfd8a058ad48e6f034dadb1d4876cefbf96a
Git user
git at public.curoverse.com
Mon Sep 25 22:59:53 EDT 2017
at 4076bfd8a058ad48e6f034dadb1d4876cefbf96a (commit)
commit 4076bfd8a058ad48e6f034dadb1d4876cefbf96a
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Mon Sep 25 22:43:10 2017 -0400
12287: Preserve JSON number types/formats in log file.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index f002cf3..27bfa88 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -650,14 +650,11 @@ func (runner *ContainerRunner) LogContainerRecord() (err error) {
return fmt.Errorf("While retrieving container record from the API server: %v", err)
}
defer reader.Close()
- // Read the API server response as []byte
- json_bytes, err := ioutil.ReadAll(reader)
- if err != nil {
- return fmt.Errorf("While reading container record API server response: %v", err)
- }
- // Decode the JSON []byte
+
+ dec := json.NewDecoder(reader)
+ dec.UseNumber()
var cr map[string]interface{}
- if err = json.Unmarshal(json_bytes, &cr); err != nil {
+ if err = dec.Decode(&cr); err != nil {
return fmt.Errorf("While decoding the container record JSON response: %v", err)
}
// Re-encode it using indentation to improve readability
commit 0807cfc8cd397510f84c0e4d2c4f9ecfc9fc67c4
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Fri Sep 22 14:58:34 2017 -0400
12287: Preserve JSON number types/formats in container records.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 6ee861b..f002cf3 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -1304,9 +1304,8 @@ func (runner *ContainerRunner) Run() (err error) {
runner.CrunchLog.Close()
}()
- err = runner.ArvClient.Get("containers", runner.Container.UUID, nil, &runner.Container)
+ err = runner.fetchContainerRecord()
if err != nil {
- err = fmt.Errorf("While getting container record: %v", err)
return
}
@@ -1369,6 +1368,24 @@ func (runner *ContainerRunner) Run() (err error) {
return
}
+// 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)
+ if err != nil {
+ return fmt.Errorf("error fetching container record: %v", err)
+ }
+ defer reader.Close()
+
+ dec := json.NewDecoder(reader)
+ dec.UseNumber()
+ err = dec.Decode(&runner.Container)
+ if err != nil {
+ return fmt.Errorf("error decoding container record: %v", err)
+ }
+ return nil
+}
+
// NewContainerRunner creates a new container runner.
func NewContainerRunner(api IArvadosClient,
kc IKeepClient,
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index 9fdc689..37b9ae2 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -220,17 +220,22 @@ func (client *ArvTestClient) Call(method, resourceType, uuid, action string, par
func (client *ArvTestClient) CallRaw(method, resourceType, uuid, action string,
parameters arvadosclient.Dict) (reader io.ReadCloser, err error) {
- j := []byte(`{
- "command": ["sleep", "1"],
- "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
- "cwd": ".",
- "environment": {},
- "mounts": {"/tmp": {"kind": "tmp"} },
- "output_path": "/tmp",
- "priority": 1,
- "runtime_constraints": {}
- }`)
- return ioutil.NopCloser(bytes.NewReader(j)), nil
+ var j []byte
+ if method == "GET" && resourceType == "containers" && action == "" {
+ j, err = json.Marshal(client.Container)
+ } else {
+ j = []byte(`{
+ "command": ["sleep", "1"],
+ "container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
+ "cwd": ".",
+ "environment": {},
+ "mounts": {"/tmp": {"kind": "tmp"}, "/json": {"kind": "json", "content": {"number": 123456789123456789}}},
+ "output_path": "/tmp",
+ "priority": 1,
+ "runtime_constraints": {}
+ }`)
+ }
+ return ioutil.NopCloser(bytes.NewReader(j)), err
}
func (client *ArvTestClient) Get(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) error {
@@ -1101,7 +1106,7 @@ func (s *TestSuite) TestSetupMounts(c *C) {
}{
{in: "foo", out: `"foo"`},
{in: nil, out: `null`},
- {in: map[string]int{"foo": 123}, out: `{"foo":123}`},
+ {in: map[string]int64{"foo": 123456789123456789}, out: `{"foo":123456789123456789}`},
} {
i = 0
cr.ArvMountPoint = ""
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list