autotest: clean up various uses of logging.exception

Many existing callers use logging.exception incorrectly, resulting in
exceptions being printed twice. Fix a bunch of them in server/
directory.

BUG=None
TEST=None

Change-Id: I03fc7ece34abbeca8bd8c328ac7cbb33c84bdc33
Reviewed-on: https://chromium-review.googlesource.com/497611
Commit-Ready: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/server/autoserv b/server/autoserv
index 85e5b89..bdc47a9 100755
--- a/server/autoserv
+++ b/server/autoserv
@@ -762,11 +762,11 @@
         except SystemExit as e:
             exit_code = e.code
             if exit_code:
-                logging.exception(e)
-        except Exception as e:
+                logging.exception('Uncaught SystemExit with code %s', exit_code)
+        except Exception:
             # If we don't know what happened, we'll classify it as
             # an 'abort' and return 1.
-            logging.exception(e)
+            logging.exception('Uncaught Exception, exit_code = 1.')
             exit_code = 1
     finally:
         if pid_file_manager:
diff --git a/server/control_segments/cleanup b/server/control_segments/cleanup
index 6305a62..745b5e0 100644
--- a/server/control_segments/cleanup
+++ b/server/control_segments/cleanup
@@ -42,8 +42,8 @@
             host.cleanup()
             provision.run_special_task_actions(job, host, labels_list,
                                                provision.Cleanup)
-    except Exception as e:
-        logging.exception(e)
+    except Exception:
+        logging.exception('Cleanup failed due to Exception.')
         job.record('END FAIL', None, 'cleanup')
         # See the provision control segment for the explanation of why we're
         # doing this.
diff --git a/server/control_segments/provision b/server/control_segments/provision
index 580134b..b637df0 100644
--- a/server/control_segments/provision
+++ b/server/control_segments/provision
@@ -58,8 +58,8 @@
         start_time = datetime.datetime.now()
         try:
             host.update_labels()
-        except Exception as e:
-            logging.exception('Exception while updating labels: %s', e)
+        except Exception:
+            logging.exception('Exception while updating labels.')
             label_update_success = False
 
         end_time = datetime.datetime.now()
@@ -71,8 +71,8 @@
                             if not utils.machine_is_testbed(machine)
                             else host.get_platform())}
         _LABEL_UPDATE_DURATION_METRIC.add(duration, fields=fields)
-    except Exception as e:
-        logging.exception(e)
+    except Exception:
+        logging.exception('Provision failed due to Exception.')
         job.record('END FAIL', None, 'provision')
         # Raising a blank exception is done here because any message we can
         # give here would be less useful than whatever the failing test left as
diff --git a/server/control_segments/repair b/server/control_segments/repair
index 75b8500..2615649 100644
--- a/server/control_segments/repair
+++ b/server/control_segments/repair
@@ -33,8 +33,8 @@
         logging.debug('Repair with labels list %s', labels_list)
         provision.run_special_task_actions(job, target, labels_list,
                                            provision.Repair)
-    except Exception as e:
-        logging.exception(e)
+    except Exception:
+        logging.exception('Repair failed due to Exception.')
         job.record('END FAIL', None, 'repair')
         # See the provision control segment for the explanation of why we're
         # doing this.
diff --git a/server/control_segments/reset b/server/control_segments/reset
index 3935c75..74eed4a 100644
--- a/server/control_segments/reset
+++ b/server/control_segments/reset
@@ -33,8 +33,8 @@
             target.verify()
             provision.run_special_task_actions(job, target, labels_list,
                                                provision.Verify)
-    except Exception as e:
-        logging.exception(e)
+    except Exception:
+        logging.exception('Reset failed due to Exception.')
         job.record('END FAIL', None, 'reset')
         # See the provision control segment for the explanation of why we're
         # doing this.
diff --git a/server/control_segments/verify b/server/control_segments/verify
index 0af7e1b..8e3834f 100644
--- a/server/control_segments/verify
+++ b/server/control_segments/verify
@@ -27,8 +27,8 @@
             target.verify()
             provision.run_special_task_actions(job, target, labels_list,
                                                provision.Verify)
-    except Exception as e:
-        logging.exception(e)
+    except Exception:
+        logging.exception('Verify failed due to Exception.')
         job.record('END FAIL', None, 'verify')
         # See the provision control segment for the explanation of why we're
         # doing this.
diff --git a/server/hosts/base_label.py b/server/hosts/base_label.py
index b63bc73..54d0e28 100644
--- a/server/hosts/base_label.py
+++ b/server/hosts/base_label.py
@@ -220,9 +220,9 @@
             logging.info('checking label %s', label.__class__.__name__)
             try:
                 labels.extend(label.get(host))
-            except Exception as e:
-                logging.exception('error getting label %s: %s',
-                                  label.__class__.__name__, e)
+            except Exception:
+                logging.exception('error getting label %s.',
+                                  label.__class__.__name__)
         return labels
 
 
diff --git a/server/hosts/remote.py b/server/hosts/remote.py
index af77a8d..0d4994f 100644
--- a/server/hosts/remote.py
+++ b/server/hosts/remote.py
@@ -336,10 +336,9 @@
         for label_function in self._LABEL_FUNCTIONS:
             try:
                 label = label_function(self)
-            except Exception as e:
-                logging.error('Label function %s failed; ignoring it.',
-                              label_function.__name__)
-                logging.exception(e)
+            except Exception:
+                logging.exception('Label function %s failed; ignoring it.',
+                                  label_function.__name__)
                 label = None
             if label:
                 if type(label) is str:
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index cb680ba..98658da 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -428,7 +428,7 @@
         except Exception as e:
             # Sometimes creating the job will raise an exception. We'll log it
             # but we don't want to fail because of it.
-            logging.exception('Scheduling reboot job failed: %s', e)
+            logging.exception('Scheduling reboot job failed due to Exception.')
             metadata = {'dut': dut,
                         'servo_host': self.hostname,
                         'error': str(e),