[ARVADOS] updated: a5ec4164873e4972aaaf943e48603daa61a044b7

git at public.curoverse.com git at public.curoverse.com
Thu Oct 16 11:06:38 EDT 2014


Summary of changes:
 services/crunchstat/crunchstat.go | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

       via  a5ec4164873e4972aaaf943e48603daa61a044b7 (commit)
      from  75b8b796ee88196ca1b99dcfed0533565c52dce7 (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 a5ec4164873e4972aaaf943e48603daa61a044b7
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Oct 16 11:05:45 2014 -0400

    3826: Roll up Open() attempts into a slice and a loop.

diff --git a/services/crunchstat/crunchstat.go b/services/crunchstat/crunchstat.go
index 6b35570..855e115 100644
--- a/services/crunchstat/crunchstat.go
+++ b/services/crunchstat/crunchstat.go
@@ -78,24 +78,21 @@ var reportedStatFile = map[string]string{}
 // cgroup root for the given statgroup. (This will avoid falling back
 // to host-level stats during container setup and teardown.)
 func OpenStatFile(stderr chan<- string, cgroup Cgroup, statgroup string, stat string) (*os.File, error) {
+	var paths = []string{}
+	paths = append(paths, fmt.Sprintf("%s/%s/%s/%s/%s", cgroup.root, statgroup, cgroup.parent, cgroup.cid, stat))
+	paths = append(paths, fmt.Sprintf("%s/%s/%s/%s", cgroup.root, cgroup.parent, cgroup.cid, stat))
+	paths = append(paths, fmt.Sprintf("%s/%s/%s", cgroup.root, statgroup, stat))
+	paths = append(paths, fmt.Sprintf("%s/%s", cgroup.root, stat))
 	var path string
-	path = fmt.Sprintf("%s/%s/%s/%s/%s", cgroup.root, statgroup, cgroup.parent, cgroup.cid, stat)
-	file, err := os.Open(path)
-	if err != nil {
-		path = fmt.Sprintf("%s/%s/%s/%s", cgroup.root, cgroup.parent, cgroup.cid, stat)
-		file, err = os.Open(path)
-	}
-	if err != nil {
-		path = fmt.Sprintf("%s/%s/%s", cgroup.root, statgroup, stat)
+	var file *os.File
+	var err error
+	for _, path = range paths {
 		file, err = os.Open(path)
-	}
-	if err != nil {
-		path = fmt.Sprintf("%s/%s", cgroup.root, stat)
-		file, err = os.Open(path)
-	}
-	if err != nil {
-		file = nil
-		path = ""
+		if err == nil {
+			break
+		} else {
+			path = ""
+		}
 	}
 	if pathWas, ok := reportedStatFile[stat]; !ok || pathWas != path {
 		// Log whenever we start using a new/different cgroup

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list