← Back to team overview

bigdata-dev team mailing list archive

[Merge] lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk

 

Cory Johns has proposed merging lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk.

Requested reviews:
  Juju Big Data Development (bigdata-dev)

For more details, see:
https://code.launchpad.net/~bigdata-dev/charms/trusty/apache-hadoop-plugin/status/+merge/262924

Added extended status support.

Example status (tabular) outputs:

http://pastebin.ubuntu.com/11769979/ (in progress)
http://pastebin.ubuntu.com/11770196/ (complete)

Example status-history outputs:

http://pastebin.ubuntu.com/11770192/ (hdfs-master)
http://pastebin.ubuntu.com/11770195/ (compute-slave)
-- 
Your team Juju Big Data Development is requested to review the proposed merge of lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/status into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk.
=== modified file 'hooks/callbacks.py'
--- hooks/callbacks.py	2015-05-12 21:52:43 +0000
+++ hooks/callbacks.py	2015-06-24 22:19:54 +0000
@@ -15,3 +15,46 @@
 Add any additional tasks / setup here.  If a callback is used by mutliple
 charms, consider refactoring it up to the jujubigdata library.
 """
+
+from charmhelpers.core import hookenv
+from charmhelpers.core import unitdata
+from jujubigdata.relations import NameNode, ResourceManager
+
+
+def update_blocked_status():
+    if unitdata.kv().get('charm.active', False):
+        return
+    rels = (
+        ('Yarn', 'ResourceManager', ResourceManager()),
+        ('HDFS', 'NameNode', NameNode()),
+    )
+    missing_rel = [rel for rel, res, impl in rels if not impl.connected_units()]
+    missing_hosts = [rel for rel, res, impl in rels if not impl.am_i_registered()]
+    not_ready = [(rel, res) for rel, res, impl in rels if not impl.is_ready()]
+    if missing_rel:
+        hookenv.status_set('blocked', 'Waiting for relation to %s master%s' % (
+            ' and '.join(missing_rel),
+            's' if len(missing_rel) > 1 else '',
+        )),
+    elif missing_hosts:
+        hookenv.status_set('waiting', 'Waiting for /etc/hosts registration on %s' % (
+            ' and '.join(missing_hosts),
+        ))
+    elif not_ready:
+        unready_rels, unready_ress = zip(*not_ready)
+        hookenv.status_set('waiting', 'Waiting for %s to provide %s' % (
+            ' and '.join(unready_rels),
+            ' and '.join(unready_ress),
+        ))
+
+
+def update_working_status():
+    if unitdata.kv().get('charm.active', False):
+        hookenv.status_set('maintenance', 'Updating configuration')
+        return
+    hookenv.status_set('maintenance', 'Setting up Hadoop libraries')
+
+
+def update_active_status():
+    unitdata.kv().set('charm.active', True)
+    hookenv.status_set('active', 'Ready')

=== modified file 'hooks/common.py'
--- hooks/common.py	2015-06-19 17:25:57 +0000
+++ hooks/common.py	2015-06-24 22:19:54 +0000
@@ -15,29 +15,39 @@
 """
 
 import jujuresources
+from charmhelpers.core import hookenv
+from charmhelpers.core import unitdata
+from charmhelpers.core import charmframework
 
 
 def bootstrap_resources():
     """
     Install required resources defined in resources.yaml
     """
+    if unitdata.kv().get('charm.bootstrapped', False):
+        return True
+    hookenv.status_set('maintenance', 'Installing base resources')
     mirror_url = jujuresources.config_get('resources_mirror')
     if not jujuresources.fetch(mirror_url=mirror_url):
-        jujuresources.juju_log('Resources unavailable; manual intervention required', 'ERROR')
+        missing = jujuresources.invalid()
+        hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
+            's' if len(missing) > 1 else '',
+            ', '.join(missing),
+        ))
         return False
-    jujuresources.install(['pathlib', 'pyaml', 'six', 'charmhelpers', 'jujubigdata', 'charm-benchmark'])
+    jujuresources.install(['pathlib', 'jujubigdata', 'charm-benchmark'])
+    unitdata.kv().set('charm.bootstrapped', True)
     return True
 
 
 def manage():
     if not bootstrap_resources():
-        # defer until resources are available, since charmhelpers, and thus
-        # the framework, are required (will require manual intervention)
+        # defer until resources are available, since jujubigdata, and thus the
+        # classes needed for the requires blocks, (will be) managed by jujuresources
         return
 
-    from charmhelpers.core import charmframework
     import jujubigdata
-    import callbacks  # noqa  (ignore when linting)
+    import callbacks
 
     # list of keys required to be in the dist.yaml
     client_reqs = ['vendor', 'hadoop_version', 'packages', 'groups', 'users',
@@ -57,37 +67,28 @@
             ],
             'callbacks': [
                 hadoop.install,
+                callbacks.update_blocked_status,
             ],
         },
         {
-            'name': 'plugin-hdfs',
+            'name': 'plugin',
             'provides': [
                 jujubigdata.relations.HadoopPlugin(),
             ],
             'requires': [
                 hadoop.is_installed,
+                yarn_relation,
                 hdfs_relation,
             ],
             'callbacks': [
+                callbacks.update_working_status,
+                yarn_relation.register_provided_hosts,
                 hdfs_relation.register_provided_hosts,
                 jujubigdata.utils.manage_etc_hosts,
-                hdfs.configure_client,
-            ],
-            'cleanup': [],
-        },
-        {
-            'name': 'plugin-yarn',
-            'provides': [
-            ],
-            'requires': [
-                hadoop.is_installed,
-                yarn_relation,
-            ],
-            'callbacks': [
-                yarn_relation.register_provided_hosts,
-                jujubigdata.utils.manage_etc_hosts,
                 yarn.install_demo,
                 yarn.configure_client,
+                hdfs.configure_client,
+                callbacks.update_active_status,
             ],
             'cleanup': [],
         },

=== modified file 'hooks/setup.py'
--- hooks/setup.py	2015-03-03 21:29:00 +0000
+++ hooks/setup.py	2015-06-24 22:19:54 +0000
@@ -12,24 +12,22 @@
 import subprocess
 from glob import glob
 
+
 def pre_install():
     """
     Do any setup required before the install hook.
     """
     install_pip()
-    install_jujuresources()
+    install_bundled_resources()
 
 
 def install_pip():
     subprocess.check_call(['apt-get', 'install', '-yq', 'python-pip', 'bzr'])
 
 
-def install_jujuresources():
-    """
-    Install the bundled jujuresources library, if not present.
-    """
-    try:
-        import jujuresources  # noqa
-    except ImportError:
-        jr_archive = glob('resources/jujuresources-*.tar.gz')[0]
-        subprocess.check_call(['pip', 'install', jr_archive])
+def install_bundled_resources():
+    """
+    Install the bundled resources libraries.
+    """
+    archives = glob('resources/*')
+    subprocess.check_call(['pip', 'install'] + archives)

=== modified file 'resources.yaml'
--- resources.yaml	2015-06-19 17:25:57 +0000
+++ resources.yaml	2015-06-24 22:19:54 +0000
@@ -3,18 +3,10 @@
 resources:
   pathlib:
     pypi: path.py>=7.0
-  pyaml:
-    pypi: pyaml
-  six:
-    pypi: six
   jujubigdata:
-    pypi: jujubigdata>=2.0.0,<3.0.0
+    pypi: jujubigdata>=2.0.2,<3.0.0
   charm-benchmark:
     pypi: charm-benchmark>=1.0.1,<2.0.0
-  charmhelpers:
-    pypi: http://bazaar.launchpad.net/~bigdata-dev/bigdata-data/trunk/download/kevin.monroe%40canonical.com-20150610215108-gq4ud2rriy1sp1h6/charmhelpers0.3.1.ta-20150610215050-vxrqhizdsrqwnmcm-1/charmhelpers-0.3.1.tar.gz
-    hash: 061fe7204289b96fab5d3ca02883040ea3026526ebf0ad38e21457527a18d139
-    hash_type: sha256
   java-installer:
     # This points to a script which manages installing Java.
     # If replaced with an alternate implementation, it must output *only* two

=== added file 'resources/PyYAML-3.11.tar.gz'
Binary files resources/PyYAML-3.11.tar.gz	1970-01-01 00:00:00 +0000 and resources/PyYAML-3.11.tar.gz	2015-06-24 22:19:54 +0000 differ
=== added file 'resources/charmhelpers-0.3.1.tar.gz'
Binary files resources/charmhelpers-0.3.1.tar.gz	1970-01-01 00:00:00 +0000 and resources/charmhelpers-0.3.1.tar.gz	2015-06-24 22:19:54 +0000 differ
=== removed file 'resources/jujuresources-0.2.5.tar.gz'
Binary files resources/jujuresources-0.2.5.tar.gz	2015-03-03 19:56:49 +0000 and resources/jujuresources-0.2.5.tar.gz	1970-01-01 00:00:00 +0000 differ
=== added file 'resources/jujuresources-0.2.8.tar.gz'
Binary files resources/jujuresources-0.2.8.tar.gz	1970-01-01 00:00:00 +0000 and resources/jujuresources-0.2.8.tar.gz	2015-06-24 22:19:54 +0000 differ
=== added file 'resources/pyaml-15.5.7.tar.gz'
Binary files resources/pyaml-15.5.7.tar.gz	1970-01-01 00:00:00 +0000 and resources/pyaml-15.5.7.tar.gz	2015-06-24 22:19:54 +0000 differ
=== added file 'resources/six-1.9.0-py2.py3-none-any.whl'
Binary files resources/six-1.9.0-py2.py3-none-any.whl	1970-01-01 00:00:00 +0000 and resources/six-1.9.0-py2.py3-none-any.whl	2015-06-24 22:19:54 +0000 differ

Follow ups