[ARVADOS] created: 1.1.2-48-ge128fc5

Git user git at public.curoverse.com
Wed Jan 10 02:57:40 EST 2018


        at  e128fc5885c553c9e9b55f2529d0ea6937e5a6b7 (commit)


commit e128fc5885c553c9e9b55f2529d0ea6937e5a6b7
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Wed Jan 10 02:48:35 2018 -0500

    12933: Include node properties in crunch2 logs.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/sdk/go/arvados/node.go b/sdk/go/arvados/node.go
new file mode 100644
index 0000000..cc844fe
--- /dev/null
+++ b/sdk/go/arvados/node.go
@@ -0,0 +1,44 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package arvados
+
+import "time"
+
+// Node is an arvados#node resource.
+type Node struct {
+	UUID       string         `json:"uuid"`
+	Domain     string         `json:"domain"`
+	Hostname   string         `json:"hostname"`
+	IPAddress  string         `json:"ip_address"`
+	LastPingAt *time.Time     `json:"last_ping_at,omitempty"`
+	SlotNumber int            `json:"slot_number"`
+	Status     string         `json:"status"`
+	JobUUID    string         `json:"job_uuid,omitempty"`
+	Properties NodeProperties `json:"properties"`
+}
+
+type NodeProperties struct {
+	CloudNode      NodePropertiesCloudNode `json:"cloud_node"`
+	TotalCPUCores  int                     `json:"total_cpu_cores,omitempty"`
+	TotalScratchMB int64                   `json:"total_scratch_mb,omitempty"`
+	TotalRAMMB     int64                   `json:"total_ram_mb,omitempty"`
+}
+
+type NodePropertiesCloudNode struct {
+	Size  string  `json:"size,omitempty"`
+	Price float64 `json:"price"`
+}
+
+func (c Node) resourceName() string {
+	return "node"
+}
+
+// NodeList is an arvados#nodeList resource.
+type NodeList struct {
+	Items          []Node `json:"items"`
+	ItemsAvailable int    `json:"items_available"`
+	Offset         int    `json:"offset"`
+	Limit          int    `json:"limit"`
+}
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index e5e0ea0..b97727f 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -660,11 +660,30 @@ type infoCommand struct {
 	cmd   []string
 }
 
-// LogNodeInfo gathers node information and store it on the log for debugging
-// purposes.
+// LogNodeInfo gathers node information and logs it for debugging and
+// accounting purposes.
 func (runner *ContainerRunner) LogNodeInfo() (err error) {
 	w := runner.NewLogWriter("node-info")
 
+	hostname := os.Getenv("SLURMD_NODENAME")
+	if hostname == "" {
+		hostname, _ = os.Hostname()
+	}
+	var nodes arvados.NodeList
+	err = runner.ArvClient.Call("GET", "nodes", "", "", map[string]interface{}{
+		"filters": [][]string{{"hostname", "=", hostname}},
+	}, &nodes)
+	if err != nil {
+		return fmt.Errorf("Error retrieving node list: %s", err)
+	}
+	if len(nodes.Items) < 1 {
+		fmt.Fprintf(w, "Node record not available for hostname %s\n", hostname)
+	} else {
+		fmt.Fprintf(w, "Node properties for node %s with hostname %q\n", nodes.Items[0].UUID, hostname)
+		json.NewEncoder(w).Encode(nodes.Items[0].Properties)
+	}
+	fmt.Fprintln(w, "")
+
 	commands := []infoCommand{
 		{
 			label: "Host Information",
diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index ab7417e..d21b55e 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -236,6 +236,14 @@ func (client *ArvTestClient) Call(method, resourceType, uuid, action string, par
 			"uuid": "`+fakeAuthUUID+`",
 			"api_token": "`+fakeAuthToken+`"
 			}`), output)
+	case method == "GET" && resourceType == "nodes" && uuid == "" && action == "":
+		return json.Unmarshal([]byte(`{
+			"kind": "arvados#nodeList",
+			"items": [{
+				"uuid": "zzzzz-7ekkf-2z3mc76g2q73aio",
+				"hostname": "compute2",
+				"properties": {"total_cpu_cores": 16}
+			}]}`), output)
 	default:
 		return fmt.Errorf("Not found")
 	}
@@ -768,6 +776,7 @@ func (s *TestSuite) TestCrunchstat(c *C) {
 }
 
 func (s *TestSuite) TestNodeInfoLog(c *C) {
+	os.Setenv("SLURMD_NODENAME", "compute2")
 	api, _, _ := FullRunHelper(c, `{
 		"command": ["sleep", "1"],
 		"container_image": "d4ab34d3d4f8a72f5c4973051ae69fab+122",
@@ -787,11 +796,13 @@ func (s *TestSuite) TestNodeInfoLog(c *C) {
 	c.Check(api.CalledWith("container.state", "Complete"), NotNil)
 
 	c.Assert(api.Logs["node-info"], NotNil)
-	c.Check(api.Logs["node-info"].String(), Matches, `(?ms).*Host Information.*`)
-	c.Check(api.Logs["node-info"].String(), Matches, `(?ms).*CPU Information.*`)
-	c.Check(api.Logs["node-info"].String(), Matches, `(?ms).*Memory Information.*`)
-	c.Check(api.Logs["node-info"].String(), Matches, `(?ms).*Disk Space.*`)
-	c.Check(api.Logs["node-info"].String(), Matches, `(?ms).*Disk INodes.*`)
+	inf := api.Logs["node-info"].String()
+	c.Check(inf, Matches, `(?ms).*Node properties.*zzzzz-7ekkf-2z3mc76g2q73aio.*"total_cpu_cores":16.*`)
+	c.Check(inf, Matches, `(?ms).*Host Information.*`)
+	c.Check(inf, Matches, `(?ms).*CPU Information.*`)
+	c.Check(inf, Matches, `(?ms).*Memory Information.*`)
+	c.Check(inf, Matches, `(?ms).*Disk Space.*`)
+	c.Check(inf, Matches, `(?ms).*Disk INodes.*`)
 }
 
 func (s *TestSuite) TestContainerRecordLog(c *C) {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list