소스 검색

HUE-6716 [metadata] Disable when password cannot be read instead of crashing with a 500

Romain Rigaux 8 년 전
부모
커밋
c29400e
1개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 11 7
      desktop/libs/metadata/src/metadata/conf.py

+ 11 - 7
desktop/libs/metadata/src/metadata/conf.py

@@ -17,6 +17,8 @@
 
 import logging
 
+from subprocess import CalledProcessError
+
 from django.utils.translation import ugettext_lazy as _t
 
 from desktop.conf import AUTH_USERNAME as DEFAULT_AUTH_USERNAME, CLUSTER_ID as DEFAULT_CLUSTER_ID
@@ -152,13 +154,15 @@ def get_navigator_auth_username():
 def get_navigator_auth_password():
   '''Get the password to authenticate with.'''
 
-  if get_navigator_auth_type() == 'ldap':
-    return NAVIGATOR.AUTH_LDAP_PASSWORD.get()
-  elif get_navigator_auth_type() == 'saml':
-    return NAVIGATOR.AUTH_SAML_PASSWORD.get()
-  else:
-    return NAVIGATOR.AUTH_CM_PASSWORD.get()
-
+  try:
+    if get_navigator_auth_type() == 'ldap':
+      return NAVIGATOR.AUTH_LDAP_PASSWORD.get()
+    elif get_navigator_auth_type() == 'saml':
+      return NAVIGATOR.AUTH_SAML_PASSWORD.get()
+    else:
+      return NAVIGATOR.AUTH_CM_PASSWORD.get()
+  except CalledProcessError:
+    LOG.exception('Could not read Navigator password file, need to restart Hue to re-enable it.')
 
 def get_navigator_cm_password():
   '''Get default password from secured file'''