10218: Avoid running df commands more than necessary. Updated test to check for disk...
[arvados.git] / services / crunch-run / crunchrun.go
index 3450345496ecff1a86e2c88b60ab29673ebbcf74..26c8a7a7eab29e420c69181d3fd19e825fe5a72f 100644 (file)
@@ -533,21 +533,21 @@ func (runner *ContainerRunner) LogNodeInfo() (err error) {
                },
                infoCommand{
                        label: "Disk Space",
-                       cmd:   []string{"df", "-m", "/"},
+                       cmd:   []string{"df", "-m", "/", os.TempDir()},
                },
                infoCommand{
-                       label: "Disk Space",
-                       cmd:   []string{"df", "-m", os.TempDir()},
+                       label: "Disk INodes",
+                       cmd:   []string{"df", "-i", "/", os.TempDir()},
                },
        }
 
        // Run commands with informational output to be logged.
        var out []byte
        for _, command := range commands {
-               out, err = exec.Command(command.cmd[0], command.cmd[1:]...).Output()
+               out, err = exec.Command(command.cmd[0], command.cmd[1:]...).CombinedOutput()
                if err != nil {
-                       return fmt.Errorf("While running command '%s': %v",
-                               command.cmd[0], err)
+                       return fmt.Errorf("While running command %q: %v",
+                               command.cmd, err)
                }
                logger.Println(command.label)
                for _, line := range strings.Split(string(out), "\n") {
@@ -575,6 +575,7 @@ func (runner *ContainerRunner) LogContainerRecord() (err error) {
        if err != nil {
                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 {