Fix bug with removing a failed job

A recent change in I96195cb9996b01075e3705b6cd89a9863528898e added
code to re-set build states for changes during a re-enqueue to
ensure that any side effects (such as marking new builds as skipped)
occurred.  However, we have found that if a change has a
non-succeeding build and the job for that build is removed, then
this new code will run and attempt to perform a lookup on the removed
job, fail, and raise an exception that aborts reconfiguration.

Correct this by fully removing builds from their build sets when
the corresponding job is removed so that no further processing
happens on them.

Change-Id: I2d5cc8f4c5b73d6a2b184cd21016943b8c08949d
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index e39e43e..2be98ea 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -679,7 +679,7 @@
                     continue
                 self.log.debug("Re-enqueueing changes for pipeline %s" % name)
                 items_to_remove = []
-                builds_to_remove = []
+                builds_to_cancel = []
                 last_head = None
                 for shared_queue in old_pipeline.queues:
                     for item in shared_queue.queue:
@@ -703,14 +703,15 @@
                             if job:
                                 build.job = job
                             else:
-                                builds_to_remove.append(build)
+                                item.removeBuild(build)
+                                builds_to_cancel.append(build)
                         if not new_pipeline.manager.reEnqueueItem(item,
                                                                   last_head):
                             items_to_remove.append(item)
                 for item in items_to_remove:
                     for build in item.current_build_set.getBuilds():
-                        builds_to_remove.append(build)
-                for build in builds_to_remove:
+                        builds_to_cancel.append(build)
+                for build in builds_to_cancel:
                     self.log.warning(
                         "Canceling build %s during reconfiguration" % (build,))
                     try: