Merge lp:~tribaal/charms/trusty/landscape-client/additional-logging into lp:charms/trusty/landscape-client

Proposed by Chris Glass
Status: Merged
Merged at revision: 40
Proposed branch: lp:~tribaal/charms/trusty/landscape-client/additional-logging
Merge into: lp:charms/trusty/landscape-client
Diff against target: 77 lines (+16/-1)
2 files modified
hooks/common.py (+13/-0)
hooks/hooks.py (+3/-1)
To merge this branch: bzr merge lp:~tribaal/charms/trusty/landscape-client/additional-logging
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Adam Collard Approve
Review via email: mp+223598@code.launchpad.net

Description of the change

This branch adds more logging to the landscape-client charm (to help narrow a race condition).

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) wrote :

Minor comments about the messages below

review: Approve
43. By Chris Glass

Addressed review comments

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

Have comments on the messages too. +1 otherwise

review: Approve
Revision history for this message
Chris Glass (tribaal) :
44. By Chris Glass

Addressed review comments

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/common.py'
--- hooks/common.py 2014-06-13 15:43:58 +0000
+++ hooks/common.py 2014-06-23 11:26:19 +0000
@@ -5,6 +5,9 @@
5from pwd import getpwnam5from pwd import getpwnam
6from subprocess import check_output6from subprocess import check_output
77
8from charmhelpers.core.hookenv import (
9 log, local_unit)
10
8from landscape.configuration import (11from landscape.configuration import (
9 setup, register, LandscapeSetupConfiguration, ConfigurationError,12 setup, register, LandscapeSetupConfiguration, ConfigurationError,
10 stop_client_and_disable_init_script)13 stop_client_and_disable_init_script)
@@ -52,6 +55,7 @@
5255
53 def __init__(self):56 def __init__(self):
54 self.config = Configuration()57 self.config = Configuration()
58 self.local_unit = local_unit()
5559
56 def update_client_config(self, service_config, try_to_register=True):60 def update_client_config(self, service_config, try_to_register=True):
57 """Update the client config.61 """Update the client config.
@@ -123,10 +127,18 @@
123 If an error is encountered, the client will be disabled and the hook127 If an error is encountered, the client will be disabled and the hook
124 calling this function will exit with an error code.128 calling this function will exit with an error code.
125 """129 """
130 log("Updating client configuration for %s" % self.local_unit)
126 error_handler = ErrorHandler()131 error_handler = ErrorHandler()
127132
128 sysvconfig = SysVConfig()133 sysvconfig = SysVConfig()
129 configured = sysvconfig.is_configured_to_run()134 configured = sysvconfig.is_configured_to_run()
135 if configured:
136 log("%s: landscape-client is configured to run as per sysvconfig"
137 "" % self.local_unit)
138 else:
139 log("%s: landscape-client is not configured to run as per "
140 "sysvconfig" % self.local_unit)
141
130 config = LandscapeSetupConfiguration()142 config = LandscapeSetupConfiguration()
131 config.load([])143 config.load([])
132 config.silent = True144 config.silent = True
@@ -139,6 +151,7 @@
139 print >> sys.stderr, "Configuration error: %s" % (str(error),)151 print >> sys.stderr, "Configuration error: %s" % (str(error),)
140 error_handler.flag_error(1)152 error_handler.flag_error(1)
141 else:153 else:
154 log("Registering %s" % self.local_unit)
142 register(config, on_error=error_handler.flag_error)155 register(config, on_error=error_handler.flag_error)
143 return error_handler.exit_code156 return error_handler.exit_code
144157
145158
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2014-06-13 15:43:58 +0000
+++ hooks/hooks.py 2014-06-23 11:26:19 +0000
@@ -7,7 +7,7 @@
7import subprocess7import subprocess
88
9from charmhelpers.core.hookenv import (9from charmhelpers.core.hookenv import (
10 Hooks, UnregisteredHookError, log)10 Hooks, UnregisteredHookError, log, local_unit)
11from charmhelpers.fetch import (11from charmhelpers.fetch import (
12 apt_install, _run_apt_command, add_source, apt_update)12 apt_install, _run_apt_command, add_source, apt_update)
13from charmhelpers.core.hookenv import config13from charmhelpers.core.hookenv import config
@@ -70,6 +70,7 @@
70 @param relation_data: data from the context of a relation, it should70 @param relation_data: data from the context of a relation, it should
71 match the data in the config71 match the data in the config
72 """72 """
73 log("In config-changed for %s" % local_unit())
73 if relation_data is None:74 if relation_data is None:
74 relation_data = {}75 relation_data = {}
75 service_config = juju_broker.get_service_config()76 service_config = juju_broker.get_service_config()
@@ -95,6 +96,7 @@
95@hooks.hook("container-relation-joined", "ceph-client-relation-joined")96@hooks.hook("container-relation-joined", "ceph-client-relation-joined")
96def container_relation_joined(juju_broker=JUJU_BROKER,97def container_relation_joined(juju_broker=JUJU_BROKER,
97 landscape_broker=LANDSCAPE_BROKER):98 landscape_broker=LANDSCAPE_BROKER):
99 log("In container-relation-joined for %s" % local_unit())
98 landscape_broker.config.reload()100 landscape_broker.config.reload()
99 relation_conf = juju_broker.get_relation_config()101 relation_conf = juju_broker.get_relation_config()
100 remote_unit_name = juju_broker.environment.get("JUJU_REMOTE_UNIT")102 remote_unit_name = juju_broker.environment.get("JUJU_REMOTE_UNIT")

Subscribers

People subscribed via source and target branches