Merge lp:~therve/landscape-client/package-reporter-result into lp:~landscape/landscape-client/trunk

Proposed by Thomas Herve
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 330
Merged at revision: 329
Proposed branch: lp:~therve/landscape-client/package-reporter-result
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 111 lines (+39/-18)
3 files modified
landscape/message_schemas.py (+4/-4)
landscape/package/reporter.py (+7/-11)
landscape/package/tests/test_reporter.py (+28/-3)
To merge this branch: bzr merge lp:~therve/landscape-client/package-reporter-result
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Sidnei da Silva (community) Approve
Review via email: mp+60474@code.launchpad.net

Description of the change

The branch makes the client reports *all* results from smart update, allowing
to correctly know when the client is correctly working or not.

To post a comment you must log in.
Revision history for this message
Sidnei da Silva (sidnei) wrote :

LGTM. +1!

review: Approve
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Great, +1!

[1]

+ "out": out,

The output could be biggish, not sure that we really want to include it in the message, also it's not clear what use the server would make of it. Maybe it could be skipped initially (till we find a use case)? IIRC adding a field to a message shouldn't be painful. This is not blocking if you think that the extra payload is negligible.

review: Approve
331. By Thomas Herve

Remove output from the package reporter result

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Verified in staging, with a staging client.

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 2011-04-29 16:23:16 +0000
+++ landscape/message_schemas.py 2011-05-12 10:22:26 +0000
@@ -297,9 +297,9 @@
297 "request-id": Int(),297 "request-id": Int(),
298 })298 })
299299
300PACKAGE_REPORTER_ERROR = Message("package-reporter-error", {300PACKAGE_REPORTER_RESULT = Message("package-reporter-result", {
301 "error-code": Int(),301 "code": Int(),
302 "error-text": utf8})302 "err": utf8})
303303
304ADD_PACKAGES = Message("add-packages", {304ADD_PACKAGES = Message("add-packages", {
305 "packages": List(KeyDict({"name": utf8,305 "packages": List(KeyDict({"name": utf8,
@@ -390,7 +390,7 @@
390 REGISTER, REGISTER_CLOUD_VM, TEMPERATURE, PROCESSOR_INFO,390 REGISTER, REGISTER_CLOUD_VM, TEMPERATURE, PROCESSOR_INFO,
391 USERS, PACKAGES, PACKAGE_LOCKS,391 USERS, PACKAGES, PACKAGE_LOCKS,
392 CHANGE_PACKAGES_RESULT, UNKNOWN_PACKAGE_HASHES,392 CHANGE_PACKAGES_RESULT, UNKNOWN_PACKAGE_HASHES,
393 ADD_PACKAGES, PACKAGE_REPORTER_ERROR, TEXT_MESSAGE, TEST,393 ADD_PACKAGES, PACKAGE_REPORTER_RESULT, TEXT_MESSAGE, TEST,
394 CUSTOM_GRAPH, REBOOT_REQUIRED, APT_PREFERENCES, EUCALYPTUS_INFO,394 CUSTOM_GRAPH, REBOOT_REQUIRED, APT_PREFERENCES, EUCALYPTUS_INFO,
395 EUCALYPTUS_INFO_ERROR, NETWORK_DEVICE, NETWORK_ACTIVITY,395 EUCALYPTUS_INFO_ERROR, NETWORK_DEVICE, NETWORK_ACTIVITY,
396 REBOOT_REQUIRED_INFO]:396 REBOOT_REQUIRED_INFO]:
397397
=== modified file 'landscape/package/reporter.py'
--- landscape/package/reporter.py 2011-04-29 16:23:16 +0000
+++ landscape/package/reporter.py 2011-05-12 10:22:26 +0000
@@ -201,26 +201,22 @@
201 logging.debug("'%s' exited with status %d (out='%s', err='%s'" % (201 logging.debug("'%s' exited with status %d (out='%s', err='%s'" % (
202 self.smart_update_filename, code, out, err))202 self.smart_update_filename, code, out, err))
203 touch_file(self._config.smart_update_stamp_filename)203 touch_file(self._config.smart_update_stamp_filename)
204 if smart_failed:204 deferred = self._broker.call_if_accepted(
205 deferred = self._broker.call_if_accepted(205 "package-reporter-result", self.send_result, code, err)
206 "package-reporter-error", self.send_error, code, err)
207 else:
208 deferred = succeed(None)
209 deferred.addCallback(lambda ignore: (out, err, code))206 deferred.addCallback(lambda ignore: (out, err, code))
210 return deferred207 return deferred
211208
212 result.addCallback(callback)209 result.addCallback(callback)
213 return result210 return result
214211
215 def send_error(self, code, err):212 def send_result(self, code, err):
216 """213 """
217 If an error happened in smart update, reports it to the server in a214 Report the package reporter result to the server in a message.
218 message.
219 """215 """
220 message = {216 message = {
221 "type": "package-reporter-error",217 "type": "package-reporter-result",
222 "error-code": code,218 "code": code,
223 "error-text": err}219 "err": err}
224 return self._broker.send_message(message, True)220 return self._broker.send_message(message, True)
225221
226 def handle_task(self, task):222 def handle_task(self, task):
227223
=== modified file 'landscape/package/tests/test_reporter.py'
--- landscape/package/tests/test_reporter.py 2011-04-29 16:23:16 +0000
+++ landscape/package/tests/test_reporter.py 2011-05-12 10:22:26 +0000
@@ -668,7 +668,7 @@
668 server reporting the error, to be able to fix the problem centrally.668 server reporting the error, to be able to fix the problem centrally.
669 """669 """
670 message_store = self.broker_service.message_store670 message_store = self.broker_service.message_store
671 message_store.set_accepted_types(["package-reporter-error"])671 message_store.set_accepted_types(["package-reporter-result"])
672 self.reporter.smart_update_filename = self.makeFile(672 self.reporter.smart_update_filename = self.makeFile(
673 "#!/bin/sh\necho -n error >&2\necho -n output\nexit 2")673 "#!/bin/sh\necho -n error >&2\necho -n output\nexit 2")
674 os.chmod(self.reporter.smart_update_filename, 0755)674 os.chmod(self.reporter.smart_update_filename, 0755)
@@ -679,8 +679,33 @@
679679
680 def callback(ignore):680 def callback(ignore):
681 self.assertMessages(message_store.get_pending_messages(),681 self.assertMessages(message_store.get_pending_messages(),
682 [{"type": "package-reporter-error",682 [{"type": "package-reporter-result",
683 "error-code": 2, "error-text": "error"}])683 "code": 2, "err": u"error"}])
684 result.addCallback(callback)
685 result.chainDeferred(deferred)
686
687 reactor.callWhenRunning(do_test)
688 return deferred
689
690 def test_run_smart_update_report_success(self):
691 """
692 L{PackageReporter.run_smart_update} also reports success to be able to
693 know the proper state of the client.
694 """
695 message_store = self.broker_service.message_store
696 message_store.set_accepted_types(["package-reporter-result"])
697 self.reporter.smart_update_filename = self.makeFile(
698 "#!/bin/sh\necho -n error >&2\necho -n output\nexit 0")
699 os.chmod(self.reporter.smart_update_filename, 0755)
700 deferred = Deferred()
701
702 def do_test():
703 result = self.reporter.run_smart_update()
704
705 def callback(ignore):
706 self.assertMessages(message_store.get_pending_messages(),
707 [{"type": "package-reporter-result",
708 "code": 0, "err": u"error"}])
684 result.addCallback(callback)709 result.addCallback(callback)
685 result.chainDeferred(deferred)710 result.chainDeferred(deferred)
686711

Subscribers

People subscribed via source and target branches

to all changes: