Эх сурвалжийг харах

[beeswax] Log all caught naked "except:" blocks

Erick Tryzelaar 10 жил өмнө
parent
commit
934adc7

+ 1 - 0
apps/beeswax/src/beeswax/create_table.py

@@ -386,6 +386,7 @@ def _readfields(lines, delimiters):
     try:
       fields_list = _get_rows(lines, delimiter)
     except:
+      LOG.exception('failed to get rows')
       fields_list = [line.split(delimiter) for line in lines if line]
 
     score = score_delim(fields_list)

+ 7 - 2
apps/beeswax/src/beeswax/management/commands/close_queries.py

@@ -15,14 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from django.core.management.base import BaseCommand
-
+import logging
 from datetime import datetime,  timedelta
 
+from django.core.management.base import BaseCommand
+
 from beeswax.models import QueryHistory
 from beeswax.server import dbms
 
 
+LOG = logging.getLogger(__name__)
+
+
 class Command(BaseCommand):
   """
   Close HiveServer2 queries.
@@ -56,6 +60,7 @@ class Command(BaseCommand):
     try:
       beeswax.conf.HIVE_CONF_DIR.set_for_testing(os.environ['HIVE_CONF_DIR'])
     except:
+      LOG.exception('failed to lookup HIVE_CONF_DIR in environment')
       self.stdout.write('Did you export HIVE_CONF_DIR=/etc/hive/conf?\n')
       raise
 

+ 7 - 2
apps/beeswax/src/beeswax/management/commands/close_sessions.py

@@ -15,14 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from django.core.management.base import BaseCommand
-
+import logging
 from datetime import datetime,  timedelta
 
+from django.core.management.base import BaseCommand
+
 from beeswax.models import Session
 from beeswax.server import dbms
 
 
+LOG = logging.getLogger(__name__)
+
+
 class Command(BaseCommand):
   """
   Close HiveServer2 sessions.
@@ -56,6 +60,7 @@ class Command(BaseCommand):
     try:
       beeswax.conf.HIVE_CONF_DIR.set_for_testing(os.environ['HIVE_CONF_DIR'])
     except:
+      LOG.exception('failed to lookup HIVE_CONF_DIR in environment')
       self.stdout.write('Did you export HIVE_CONF_DIR=/etc/hive/conf?\n')
       raise
 

+ 3 - 1
apps/beeswax/src/beeswax/migrations/0001_initial.py

@@ -20,6 +20,8 @@ from south.db import db
 from south.v2 import SchemaMigration
 from django.db import models
 
+LOG = logging.getLogger(__name__)
+
 class Migration(SchemaMigration):
 
     def forwards(self, orm):
@@ -32,7 +34,7 @@ class Migration(SchemaMigration):
             ))
             db.send_create_signal('beeswax', ['MetaInstall'])
         except:
-            logging.warning("Initial db creation being skipped, likely because table already exists.", exc_info=True)
+            LOG.exception("Initial db creation being skipped, likely because table already exists.")
             return
 
         # Adding model 'QueryHistory'

+ 1 - 0
apps/beeswax/src/beeswax/models.py

@@ -343,6 +343,7 @@ class SavedQuery(models.Model):
     try:
       return make_query_context('design', self.id)
     except:
+      LOG.exception('failed to make query context')
       return ""
 
   def get_absolute_url(self):

+ 1 - 0
apps/beeswax/src/beeswax/server/dbms.py

@@ -490,6 +490,7 @@ class HiveServer2Dbms(object):
     try:
       self.cancel_operation(handle)
     except:
+      LOG.exception('failed to cancel operation')
       self.close_operation(handle)
     return None
 

+ 6 - 0
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -84,6 +84,7 @@ class HiveServerTable(Table):
     try:
       return [PartitionKeyCompatible(row['col_name'], row['data_type'], row['comment']) for row in self._get_partition_column()]
     except:
+      LOG.exception('failed to get partition keys')
       return []
 
   @property
@@ -94,6 +95,7 @@ class HiveServerTable(Table):
       if rows:
         return rows[0]['data_type']
     except:
+      LOG.exception('failed to get path location')
       return None
 
   @property
@@ -104,6 +106,7 @@ class HiveServerTable(Table):
       end_cols_index = map(itemgetter('col_name'), rows[col_row_index:]).index('')
       return rows[col_row_index:][:end_cols_index] + self._get_partition_column()
     except:
+      LOG.exception('failed to extract columns')
       return rows
 
   def _get_partition_column(self):
@@ -113,6 +116,7 @@ class HiveServerTable(Table):
       end_cols_index = map(itemgetter('col_name'), rows[col_row_index:]).index('')
       return rows[col_row_index:][:end_cols_index]
     except:
+      LOG.exception('failed to get partition column')
       return []
 
   @property
@@ -285,6 +289,8 @@ class HiveServerTTableSchema:
     try:
       return HiveServerTRowSet(self.columns, self.schema).cols(('col_name', 'data_type', 'comment'))
     except:
+      LOG.exception('failed to get columns')
+
       # Impala API is different
       cols = HiveServerTRowSet(self.columns, self.schema).cols(('name', 'type', 'comment'))
       for col in cols: