[ARVADOS] updated: 4cf16efd4dc5097b59e900d84eef3bf98d80b16f

git at public.curoverse.com git at public.curoverse.com
Thu Sep 18 12:11:48 EDT 2014


Summary of changes:
 services/api/app/models/node.rb                          | 16 +++++-----------
 .../db/migrate/20140918153541_add_properties_to_node.rb  |  9 +++++++++
 services/api/db/structure.sql                            |  5 ++++-
 .../test/functional/arvados/v1/nodes_controller_test.rb  |  7 ++++---
 services/api/test/unit/node_test.rb                      |  8 ++++----
 5 files changed, 26 insertions(+), 19 deletions(-)
 create mode 100644 services/api/db/migrate/20140918153541_add_properties_to_node.rb

       via  4cf16efd4dc5097b59e900d84eef3bf98d80b16f (commit)
      from  2749cf271f44f3783a3c2c9c309e0508da7d9446 (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 4cf16efd4dc5097b59e900d84eef3bf98d80b16f
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Sep 18 12:11:43 2014 -0400

    3605: Add properties column to node.  Put public-facing node information (cpu
    cores, RAM, scratch space) into properties field.  Info field is back to being
    admin-only.

diff --git a/services/api/app/models/node.rb b/services/api/app/models/node.rb
index 960142e..5311146 100644
--- a/services/api/app/models/node.rb
+++ b/services/api/app/models/node.rb
@@ -3,6 +3,7 @@ class Node < ArvadosModel
   include KindAndEtag
   include CommonApiTemplate
   serialize :info, Hash
+  serialize :properties, Hash
   before_validation :ensure_ping_secret
   after_update :dnsmasq_update
 
@@ -20,21 +21,14 @@ class Node < ArvadosModel
     t.add :slot_number
     t.add :status
     t.add :crunch_worker_state
-    t.add :info
+    t.add :properties
   end
   api_accessible :superuser, :extend => :user do |t|
     t.add :first_ping_at
+    t.add :info
     t.add lambda { |x| @@nameservers }, :as => :nameservers
   end
 
-  def info
-    if current_user.andand.current_user.is_admin
-      super
-    else
-      super.select { |k| not k.to_s.include? "secret" }
-    end
-  end
-
   def domain
     super || @@domain
   end
@@ -121,9 +115,9 @@ class Node < ArvadosModel
     # Record other basic stats
     ['total_cpu_cores', 'total_ram_mb', 'total_scratch_mb'].each do |key|
       if value = (o[key] or o[key.to_sym])
-        self.info[key] = value
+        self.properties[key] = value
       else
-        self.info.delete(key)
+        self.properties.delete(key)
       end
     end
 
diff --git a/services/api/db/migrate/20140918153541_add_properties_to_node.rb b/services/api/db/migrate/20140918153541_add_properties_to_node.rb
new file mode 100644
index 0000000..85f41ee
--- /dev/null
+++ b/services/api/db/migrate/20140918153541_add_properties_to_node.rb
@@ -0,0 +1,9 @@
+class AddPropertiesToNode < ActiveRecord::Migration
+  def up
+    add_column :nodes, :properties, :text
+  end
+
+  def down
+    remove_column :nodes, :properties
+  end
+end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index bd86826..b19d412 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -636,7 +636,8 @@ CREATE TABLE nodes (
     first_ping_at timestamp without time zone,
     last_ping_at timestamp without time zone,
     info text,
-    updated_at timestamp without time zone NOT NULL
+    updated_at timestamp without time zone NOT NULL,
+    properties text
 );
 
 
@@ -2012,3 +2013,5 @@ INSERT INTO schema_migrations (version) VALUES ('20140818125735');
 INSERT INTO schema_migrations (version) VALUES ('20140826180337');
 
 INSERT INTO schema_migrations (version) VALUES ('20140828141043');
+
+INSERT INTO schema_migrations (version) VALUES ('20140918153541');
diff --git a/services/api/test/functional/arvados/v1/nodes_controller_test.rb b/services/api/test/functional/arvados/v1/nodes_controller_test.rb
index 28a1830..3143a2e 100644
--- a/services/api/test/functional/arvados/v1/nodes_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/nodes_controller_test.rb
@@ -87,9 +87,10 @@ class Arvados::V1::NodesControllerTest < ActionController::TestCase
     }
     assert_response :success
     info = JSON.parse(@response.body)['info']
+    properties = JSON.parse(@response.body)['properties']
     assert_equal(node.info['ping_secret'], info['ping_secret'])
-    assert_equal(32, info['total_cpu_cores'].to_i)
-    assert_equal(1024, info['total_ram_mb'].to_i)
-    assert_equal(2048, info['total_scratch_mb'].to_i)
+    assert_equal(32, properties['total_cpu_cores'].to_i)
+    assert_equal(1024, properties['total_ram_mb'].to_i)
+    assert_equal(2048, properties['total_scratch_mb'].to_i)
   end
 end
diff --git a/services/api/test/unit/node_test.rb b/services/api/test/unit/node_test.rb
index 5a9a057..1c5a8e6 100644
--- a/services/api/test/unit/node_test.rb
+++ b/services/api/test/unit/node_test.rb
@@ -11,13 +11,13 @@ class NodeTest < ActiveSupport::TestCase
 
   test "pinging a node can add and update stats" do
     node = ping_node(:idle, {total_cpu_cores: '12', total_ram_mb: '512'})
-    assert_equal(12, node.info['total_cpu_cores'].to_i)
-    assert_equal(512, node.info['total_ram_mb'].to_i)
+    assert_equal(12, node.properties['total_cpu_cores'].to_i)
+    assert_equal(512, node.properties['total_ram_mb'].to_i)
   end
 
   test "stats disappear if not in a ping" do
     node = ping_node(:idle, {total_ram_mb: '256'})
-    refute_includes(node.info, 'total_cpu_cores')
-    assert_equal(256, node.info['total_ram_mb'].to_i)
+    refute_includes(node.properties, 'total_cpu_cores')
+    assert_equal(256, node.properties['total_ram_mb'].to_i)
   end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list