浏览代码

HUE-1367 [core] Dump config can be slow

Removed the ajax check config on each page for the Hue admin.
This is consuming too much resources nowadays and the start
page is replacing it.
Romain Rigaux 12 年之前
父节点
当前提交
709ab08

+ 10 - 2
apps/about/src/about/templates/admin_wizard.mako

@@ -63,10 +63,13 @@ ${ commonheader(_('Quick Start'), "quickstart", user, "100px") | n,unicode }
           <div class="steps">
           <div id="step1" class="stepDetails">
             <div class="card card-tab">
-              <h2 class="card-heading simple">${ _('Check your current configuration') }</h2>
+              <h2 class="card-heading simple">${ _('Checking current configuration') }</h2>
 
               <div class="card-body">
-              ${ check_config | n,smart_unicode }
+                <div id="check-config-section">
+                  <!--[if !IE]><!--><i class="icon-spinner icon-spin" style="font-size: 60px;"></i><!--<![endif]-->
+                  <!--[if IE]><img src="/hbase/static/art/loader.gif" /><![endif]-->
+                </div>
               </div>
             </div>
 
@@ -231,6 +234,11 @@ ${ commonheader(_('Quick Start'), "quickstart", user, "100px") | n,unicode }
 <script type="text/javascript" charset="utf-8">
 $(document).ready(function(){
 
+  $.get("${ url('desktop.views.check_config') }", function(response) {
+    $("#check-config-section").html(response);
+  })
+  .fail(function() { $.jHueNotify.error('${ _("Check config failed: ")}'); });
+
   $("[rel='popover']").popover();
 
   $(".installBtn").click(function() {

+ 0 - 2
apps/about/src/about/views.py

@@ -26,7 +26,6 @@ from django.utils.translation import ugettext as _
 
 from desktop.lib.django_util import render
 from desktop.models import Settings
-from desktop.views import check_config
 from desktop import appmanager
 
 from hadoop.core_site import get_trash_interval
@@ -40,7 +39,6 @@ def admin_wizard(request):
 
   return render('admin_wizard.mako', request, {
       'version': settings.HUE_DESKTOP_VERSION,
-      'check_config': check_config(request).content,
       'apps': dict([(app.name, app) for app in apps]),
       'app_names': app_names,
       'tours_and_tutorials': tours_and_tutorials,

+ 2 - 2
desktop/core/src/desktop/templates/check_config.mako

@@ -17,8 +17,8 @@
 from desktop.lib.conf import BoundConfig
 from django.utils.translation import ugettext as _
 %>
-
     ${_('Configuration files located in')} <code>${conf_dir}</code>
+
     <br/><br/>
     % if error_list:
       <div class="alert alert-warn">${_('Potential misconfiguration detected. Fix and restart Hue.')}</div>
@@ -47,4 +47,4 @@ from django.utils.translation import ugettext as _
     </table>
     % else:
       <h5>${_('All OK. Configuration check passed.')}</h5>
-    % endif
+    % endif

+ 1 - 4
desktop/core/src/desktop/templates/common_header.mako

@@ -135,12 +135,9 @@ from django.utils.translation import ugettext as _
       }).change(function(){
         $(this).closest("form").submit();
       });
-      % if user.is_superuser:
-        $("#checkConfig").load("/debug/check_config_ajax");
-      % endif
+
       $(".navbar .nav-tooltip").tooltip({
         delay:0,
-
         placement:'bottom'});
     });
   </script>

+ 1 - 0
desktop/core/src/desktop/templates/config_alert_dock.mako

@@ -16,6 +16,7 @@
 <%!
 from django.utils.translation import ugettext as _
 %>
+
 % if error_list:
   <a href="${url('about:index')}" title="${_('Misconfiguration detected')}" alt="${_('Misconfiguration detected')}">
     <i class="icon-warning-sign" style="color:#B94A48"></i>

+ 3 - 7
desktop/core/src/desktop/tests.py

@@ -40,7 +40,7 @@ from desktop.lib.conf import validate_path
 from desktop.lib.django_util import TruncatingModel
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.test_utils import grant_access
-from desktop.views import check_config_ajax
+from desktop.views import check_config
 
 
 def setup_test_environment():
@@ -440,10 +440,6 @@ def test_config_check():
     resp = cli.get('/debug/check_config')
     del os.environ["HUE_CONF_DIR"]
     assert_true('/tmp/test_hue_conf_dir' in resp.content, resp)
-
-    # Alert present in the status bar
-    resp = cli.get('/about', follow=True)
-    assert_true('misconfiguration' in resp.content, resp.content)
   finally:
     for old_conf in reset:
       old_conf()
@@ -487,5 +483,5 @@ def test_ui_customizations():
 @attr('requires_hadoop')
 def test_check_config_ajax():
   c = make_logged_in_client()
-  response = c.get(reverse(check_config_ajax))
-  assert_true("Misconfiguration" in response.content, response.content)
+  response = c.get(reverse(check_config))
+  assert_true("misconfiguration" in response.content, response.content)

+ 6 - 5
desktop/core/src/desktop/views.py

@@ -382,9 +382,12 @@ def check_config(request):
     return HttpResponse(_("You must be a superuser."))
 
   conf_dir = os.path.realpath(os.getenv("HUE_CONF_DIR", get_desktop_root("conf")))
-  return render('check_config.mako', request, dict(
-                    error_list=_get_config_errors(request, cache=False),
-                    conf_dir=conf_dir))
+  return render('check_config.mako', request, {
+                  'error_list': _get_config_errors(request, cache=False),
+                  'conf_dir': conf_dir
+              },
+              force_template=True)
+
 
 def check_config_ajax(request):
   """Alert administrators about configuration problems."""
@@ -399,5 +402,3 @@ def check_config_ajax(request):
                 request,
                 dict(error_list=error_list),
                 force_template=True)
-
-register_status_bar_view(check_config_ajax)