Merge lp:~ack/landscape-client/ceph-message-to-ceph-usage into lp:~landscape/landscape-client/trunk

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: 786
Merged at revision: 766
Proposed branch: lp:~ack/landscape-client/ceph-message-to-ceph-usage
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~ack/landscape-client/swift-usage
Diff against target: 159 lines (+32/-32)
3 files modified
landscape/message_schemas.py (+7/-9)
landscape/monitor/cephusage.py (+7/-6)
landscape/monitor/tests/test_cephusage.py (+18/-17)
To merge this branch: bzr merge lp:~ack/landscape-client/ceph-message-to-ceph-usage
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
Free Ekanayaka (community) Approve
Review via email: mp+220293@code.launchpad.net

Commit message

This reverts the message name change for ceph-usage
It preserves backwards compatibility by always sending an empty "ceph-usages" field in the message.

Description of the change

This reverts the message name change for ceph-usage
It preserves backwards compatibility by always sending an empty "ceph-usages" field in the message.

To post a comment you must log in.
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Looks good, +1!

[1]

+ "ceph-usages": List(Tuple(Int(), Int(), Int(), Int()))})

I believe this could be just:

    "ceph-usages": List(None)})

review: Approve
785. By Alberto Donato

Merged swift-usage into ceph-message-to-ceph-usage.

Revision history for this message
Adam Collard (adam-collard) wrote :

Looks good. +1

review: Approve
786. By Alberto Donato

Address Free's #1.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'landscape/message_schemas.py'
--- landscape/message_schemas.py 2014-05-21 09:02:25 +0000
+++ landscape/message_schemas.py 2014-05-21 09:02:25 +0000
@@ -123,13 +123,11 @@
123 })123 })
124124
125CEPH_USAGE = Message("ceph-usage", {125CEPH_USAGE = Message("ceph-usage", {
126 "ceph-usages": List(Tuple(Int(), Float())),126 "ring-id": Unicode(),
127 "ring-id": Unicode(),127 # Usage data points in the form (timestamp, size, avail, used)
128 })128 "data-points": List(Tuple(Int(), Int(), Int(), Int())),
129129 # Unused now, for backwards compatibility
130CEPH = Message("ceph", {130 "ceph-usages": List(None)})
131 "ring-id": Unicode(),
132 "usages": List(Tuple(Int(), Int(), Int(), Int()))})
133131
134SWIFT_DEVICE_INFO = Message("swift-device-info", {132SWIFT_DEVICE_INFO = Message("swift-device-info", {
135 "swift-device-info": List(133 "swift-device-info": List(
@@ -473,6 +471,6 @@
473 CUSTOM_GRAPH, REBOOT_REQUIRED, APT_PREFERENCES, EUCALYPTUS_INFO,471 CUSTOM_GRAPH, REBOOT_REQUIRED, APT_PREFERENCES, EUCALYPTUS_INFO,
474 EUCALYPTUS_INFO_ERROR, NETWORK_DEVICE, NETWORK_ACTIVITY,472 EUCALYPTUS_INFO_ERROR, NETWORK_DEVICE, NETWORK_ACTIVITY,
475 REBOOT_REQUIRED_INFO, UPDATE_MANAGER_INFO, CPU_USAGE,473 REBOOT_REQUIRED_INFO, UPDATE_MANAGER_INFO, CPU_USAGE,
476 CEPH_USAGE, CEPH, SWIFT_DEVICE_INFO, KEYSTONE_TOKEN,474 CEPH_USAGE, SWIFT_USAGE, SWIFT_DEVICE_INFO, KEYSTONE_TOKEN,
477 CHANGE_HA_SERVICE, JUJU_INFO, CLOUD_METADATA, SWIFT_USAGE]:475 CHANGE_HA_SERVICE, JUJU_INFO, CLOUD_METADATA]:
478 message_schemas[schema.type] = schema476 message_schemas[schema.type] = schema
479477
=== modified file 'landscape/monitor/cephusage.py'
--- landscape/monitor/cephusage.py 2014-05-19 07:45:24 +0000
+++ landscape/monitor/cephusage.py 2014-05-21 09:02:25 +0000
@@ -70,25 +70,26 @@
70 self.registry.reactor.call_every(70 self.registry.reactor.call_every(
71 self._monitor_interval, self._monitor.log)71 self._monitor_interval, self._monitor.log)
72 self.registry.reactor.call_on("stop", self._monitor.log, priority=2000)72 self.registry.reactor.call_on("stop", self._monitor.log, priority=2000)
73 self.call_on_accepted("ceph", self.send_message, True)73 self.call_on_accepted("ceph-usage", self.send_message, True)
7474
75 def create_message(self):75 def create_message(self):
76 ceph_points = self._ceph_usage_points76 ceph_points = self._ceph_usage_points
77 ring_id = self._ceph_ring_id77 ring_id = self._ceph_ring_id
78 self._ceph_usage_points = []78 self._ceph_usage_points = []
79 return {"type": "ceph",79 return {"type": "ceph-usage",
80 "ring-id": ring_id,80 "ring-id": ring_id,
81 "usages": ceph_points}81 "ceph-usages": [], # For backwards-compatibility
82 "data-points": ceph_points}
8283
83 def send_message(self, urgent=False):84 def send_message(self, urgent=False):
84 message = self.create_message()85 message = self.create_message()
85 if message["ring-id"] and message["usages"]:86 if message["ring-id"] and message["data-points"]:
86 self.registry.broker.send_message(87 self.registry.broker.send_message(
87 message, self._session_id, urgent=urgent)88 message, self._session_id, urgent=urgent)
8889
89 def exchange(self, urgent=False):90 def exchange(self, urgent=False):
90 self.registry.broker.call_if_accepted(91 self.registry.broker.call_if_accepted(
91 "ceph", self.send_message, urgent)92 "ceph-usage", self.send_message, urgent)
9293
93 def run(self):94 def run(self):
94 if not self._should_run():95 if not self._should_run():
@@ -140,7 +141,7 @@
140141
141 step_values = []142 step_values = []
142 for name, key in names_map:143 for name, key in names_map:
143 value = cluster_stats[key] * 1024 # Report usages in bytes144 value = cluster_stats[key] * 1024 # Report usage in bytes
144 step_value = self._accumulate(timestamp, value, "usage.%s" % name)145 step_value = self._accumulate(timestamp, value, "usage.%s" % name)
145 step_values.append(step_value)146 step_values.append(step_value)
146147
147148
=== modified file 'landscape/monitor/tests/test_cephusage.py'
--- landscape/monitor/tests/test_cephusage.py 2014-05-19 07:45:24 +0000
+++ landscape/monitor/tests/test_cephusage.py 2014-05-21 09:02:25 +0000
@@ -14,11 +14,11 @@
1414
15 def test_never_exchange_empty_messages(self):15 def test_never_exchange_empty_messages(self):
16 """16 """
17 The plugin will create a message with an empty C{usages} list when no17 The plugin will create a message with an empty C{data-points} list
18 previous data is available. If an empty message is created during18 when no previous data is available. If an empty message is created
19 exchange, it should not be queued.19 during exchange, it should not be queued.
20 """20 """
21 self.mstore.set_accepted_types(["ceph"])21 self.mstore.set_accepted_types(["ceph-usage"])
22 self.monitor.add(self.plugin)22 self.monitor.add(self.plugin)
2323
24 self.monitor.exchange()24 self.monitor.exchange()
@@ -30,7 +30,7 @@
30 is called.30 is called.
31 """31 """
32 ring_id = "whatever"32 ring_id = "whatever"
33 self.mstore.set_accepted_types(["ceph"])33 self.mstore.set_accepted_types(["ceph-usage"])
3434
35 point = (60, 100000, 80000, 20000)35 point = (60, 100000, 80000, 20000)
36 self.plugin._ceph_usage_points = [point]36 self.plugin._ceph_usage_points = [point]
@@ -40,9 +40,10 @@
40 self.monitor.exchange()40 self.monitor.exchange()
41 self.assertMessages(41 self.assertMessages(
42 self.mstore.get_pending_messages(),42 self.mstore.get_pending_messages(),
43 [{"type": "ceph",43 [{"type": "ceph-usage",
44 "ring-id": ring_id,44 "ring-id": ring_id,
45 "usages": [point]}])45 "ceph-usages": [],
46 "data-points": [point]}])
4647
47 def test_create_message(self):48 def test_create_message(self):
48 """49 """
@@ -54,22 +55,22 @@
54 message = self.plugin.create_message()55 message = self.plugin.create_message()
5556
56 self.assertIn("type", message)57 self.assertIn("type", message)
57 self.assertEqual(message["type"], "ceph")58 self.assertEqual(message["type"], "ceph-usage")
58 self.assertIn("usages", message)59 self.assertIn("data-points", message)
59 self.assertEqual(ring_id, message["ring-id"])60 self.assertEqual(ring_id, message["ring-id"])
60 ceph_usages = message["usages"]61 data_points = message["data-points"]
61 self.assertEqual(len(ceph_usages), 0)62 self.assertEqual(len(data_points), 0)
6263
63 point = (60, 100000, 80000, 20000)64 point = (60, 100000, 80000, 20000)
64 self.plugin._ceph_usage_points = [point]65 self.plugin._ceph_usage_points = [point]
65 message = self.plugin.create_message()66 message = self.plugin.create_message()
66 self.assertIn("type", message)67 self.assertIn("type", message)
67 self.assertEqual(message["type"], "ceph")68 self.assertEqual(message["type"], "ceph-usage")
68 self.assertIn("usages", message)69 self.assertIn("data-points", message)
69 self.assertEqual(ring_id, message["ring-id"])70 self.assertEqual(ring_id, message["ring-id"])
70 ceph_usages = message["usages"]71 data_points = message["data-points"]
71 self.assertEqual(len(ceph_usages), 1)72 self.assertEqual(len(data_points), 1)
72 self.assertEqual([point], ceph_usages)73 self.assertEqual([point], data_points)
7374
74 def test_no_message_if_not_accepted(self):75 def test_no_message_if_not_accepted(self):
75 """76 """
@@ -88,7 +89,7 @@
88 self.reactor.advance(monitor_interval * 2)89 self.reactor.advance(monitor_interval * 2)
89 self.monitor.exchange()90 self.monitor.exchange()
9091
91 self.mstore.set_accepted_types(["ceph"])92 self.mstore.set_accepted_types(["ceph-usage"])
92 self.assertMessages(list(self.mstore.get_pending_messages()), [])93 self.assertMessages(list(self.mstore.get_pending_messages()), [])
9394
94 def test_wb_should_run_inactive(self):95 def test_wb_should_run_inactive(self):

Subscribers

People subscribed via source and target branches

to all changes: