CommitQueueSyncStage: Fix --debug run case.

When run with --debug and no CIDB credentials, the master-paladin config
would fail by using a db connection of None.

Work around that.

BUG=None
TEST=bin/cbuildbot --buildroot ~/tmp/build_master --debug --buildbot
       --branch master --buildnumber 37 master-paladin

Change-Id: I9f4e1ef2157124c268252b1c8e5fc59f85049826
Reviewed-on: https://chromium-review.googlesource.com/310874
Commit-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Paul Hobbs <phobbs@google.com>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/cbuildbot/stages/sync_stages.py b/cbuildbot/stages/sync_stages.py
index dc2df54..0f9015e 100644
--- a/cbuildbot/stages/sync_stages.py
+++ b/cbuildbot/stages/sync_stages.py
@@ -917,11 +917,14 @@
     changes_to_test = []
 
     _, db = self._run.GetCIDBHandle()
-    actions_for_changes = db.GetActionsForChanges(changes)
-    for change in changes:
-      status = clactions.GetCLPreCQStatus(change, actions_for_changes)
-      if status == constants.CL_STATUS_PASSED:
-        changes_to_test.append(change)
+    if db:
+      actions_for_changes = db.GetActionsForChanges(changes)
+      for change in changes:
+        status = clactions.GetCLPreCQStatus(change, actions_for_changes)
+        if status == constants.CL_STATUS_PASSED:
+          changes_to_test.append(change)
+    else:
+      logging.warning("DB not available, unable to filter for PreCQ passed.")
 
     # Allow Commit-Ready=+2 changes to bypass the Pre-CQ, if there are no other
     # changes.