[Android compile server] Fixes

* Only respond to OBJECT_FINALIZE (new object) events.
* Swap checks for if mirror is running and if checkouts are all busy, otherwise it is confusing.

Bug: skia:9302
Change-Id: I51b063967c739428ce7b09cb4961bdb072f35704
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/233461
Reviewed-by: Ravi Mistry <rmistry@google.com>
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
diff --git a/android_compile/go/android_compile_be/main.go b/android_compile/go/android_compile_be/main.go
index 420a06e..1bc0b98 100644
--- a/android_compile/go/android_compile_be/main.go
+++ b/android_compile/go/android_compile_be/main.go
@@ -225,6 +225,11 @@
 					return
 				}
 
+				if m.Attributes["eventType"] != "OBJECT_FINALIZE" {
+					// We only care about new files, i.e. OBJECT_FINALIZE events.
+					m.Ack()
+					return
+				}
 				// The overwroteGeneration attribute only appears in OBJECT_FINALIZE
 				// events in the case of an overwrite.
 				// Source: https://cloud.google.com/storage/docs/pubsub-notifications
@@ -251,19 +256,19 @@
 				}
 
 				// Is this instance ready to pickup new tasks? Checks for the following to decide:
-				// * Are all checkouts busy?
 				// * Is mirror sync going on?
+				// * Are all checkouts busy?
 				// If either of these cases are true then the message is Nack'ed. Hopefully another instance
 				// handles it, else this instance will pick it up when free.
-				if len(AvailableCheckoutsChan) == 0 {
-					sklog.Debugf("All %d checkouts are busy. Nack'ing %s .", *numCheckouts, message.Name)
+				if getMirrorUpdateRunning() {
+					sklog.Debugf("Mirror is being updated right now. Nack'ing %s.", message.Name)
 					if err := ac_util.AddUnownedCompileTask(&task); err != nil {
 						sklog.Error(err)
 					}
 					m.Nack()
 					return
-				} else if getMirrorUpdateRunning() {
-					sklog.Debugf("Mirror is being updated right now. Nack'ing %s.", message.Name)
+				} else if len(AvailableCheckoutsChan) == 0 {
+					sklog.Debugf("All %d checkouts are busy. Nack'ing %s .", *numCheckouts, message.Name)
 					if err := ac_util.AddUnownedCompileTask(&task); err != nil {
 						sklog.Error(err)
 					}