bigdata-dev team mailing list archive
-
bigdata-dev team
-
Mailing list archive
-
Message #00471
[Merge] lp:~merlijn-sebrechts/charms/trusty/apache-flume-kafka/trunk into lp:~bigdata-dev/charms/trusty/apache-flume-kafka/trunk
Merlijn Sebrechts has proposed merging lp:~merlijn-sebrechts/charms/trusty/apache-flume-kafka/trunk into lp:~bigdata-dev/charms/trusty/apache-flume-kafka/trunk.
Requested reviews:
Kevin W Monroe (kwmonroe)
For more details, see:
https://code.launchpad.net/~merlijn-sebrechts/charms/trusty/apache-flume-kafka/trunk/+merge/283296
Fix for lxc containers on manual provider and port to upstart jobs
--
Your team Juju Big Data Development is subscribed to branch lp:~bigdata-dev/charms/trusty/apache-flume-kafka/trunk.
=== modified file 'hooks/callbacks.py'
--- hooks/callbacks.py 2015-09-30 03:24:44 +0000
+++ hooks/callbacks.py 2016-01-20 14:06:33 +0000
@@ -1,16 +1,20 @@
-import os
import re
-import signal
-from subprocess import Popen, check_output
+from subprocess import check_output
import jujuresources
-from charmhelpers.core import hookenv
+from charmhelpers.core import hookenv, templating
from charmhelpers.core import host
from charmhelpers.core import unitdata
from jujubigdata import utils
from jujubigdata.relations import FlumeAgent, Kafka
+# This should be in charmhelpers.core.host
+def hostname():
+ """ Returns fqdn for host """
+ return check_output(['hostname']).rstrip()
+
+
# Extended status support
# We call update_blocked_status from the "requires" section of our service
# block, so be sure to return True. Otherwise, we'll block the "requires"
@@ -123,6 +127,16 @@
utils.re_edit_in_place(flume_log4j, {
r'^flume.log.dir.*': 'flume.log.dir={}'.format(self.dist_config.path('flume_logs')),
})
+ # fix for lxc containers and some corner cases in manual provider
+ utils.update_etc_hosts({hookenv.unit_private_ip():hostname()})
+ templating.render(
+ 'upstart.conf',
+ '/etc/init/flume.conf',
+ context={
+ 'flume': self.dist_config.path('flume'),
+ 'flume_conf': self.dist_config.path('flume_conf')
+ },
+ )
def configure_flume(self):
flume_bin = self.dist_config.path('flume') / 'bin'
@@ -137,38 +151,15 @@
env['FLUME_HOME'] = self.dist_config.path('flume')
env['JAVA_HOME'] = java_home
- def run_bg(self, user, command, *args):
- """
- Run a command as the given user in the background.
-
- :param str user: User to run flume agent
- :param str command: Command to run
- :param list args: Additional args to pass to the command
- """
- parts = [command] + list(args)
- quoted = ' '.join("'%s'" % p for p in parts)
- e = utils.read_etc_env()
- Popen(['su', user, '-c', quoted], env=e)
-
def restart(self):
- # check for a java process with our flume dir in the classpath
- if utils.jps(r'-cp .*{}'.format(self.dist_config.path('flume'))):
- self.stop()
+ self.stop()
self.start()
def start(self):
- self.run_bg(
- 'flume',
- self.dist_config.path('flume') / 'bin/flume-ng',
- 'agent',
- '-c', self.dist_config.path('flume_conf'),
- '-f', self.dist_config.path('flume_conf') / 'flume.conf',
- '-n', 'a1')
+ host.service_start('flume')
def stop(self):
- flume_pids = utils.jps(r'-cp .*{}'.format(self.dist_config.path('flume')))
- for pid in flume_pids:
- os.kill(int(pid), signal.SIGKILL)
+ host.service_stop('flume')
def cleanup(self):
self.dist_config.remove_users()