18102: Avoid spamming logs in case of version mismatch.
authorTom Clegg <tom@curii.com>
Mon, 6 Sep 2021 19:48:13 +0000 (15:48 -0400)
committerTom Clegg <tom@curii.com>
Tue, 7 Sep 2021 13:14:34 +0000 (09:14 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/dispatchcloud/scheduler/sync.go

index fc683505f93dbae41ff42f31032dd2d145d72169..038b4c8c5f0cb3a04aa08eddc843ac7564d9913f 100644 (file)
@@ -13,6 +13,8 @@ import (
        "github.com/sirupsen/logrus"
 )
 
+var reportedUnexpectedState = false
+
 // sync resolves discrepancies between the queue and the pool:
 //
 // Lingering crunch-run processes for finalized and unlocked/requeued
@@ -82,10 +84,13 @@ func (sch *Scheduler) sync() {
                                go sch.requeue(ent, "priority=0")
                        }
                default:
-                       sch.logger.WithFields(logrus.Fields{
-                               "ContainerUUID": uuid,
-                               "State":         ent.Container.State,
-                       }).Error("BUG: unexpected state")
+                       if !reportedUnexpectedState {
+                               sch.logger.WithFields(logrus.Fields{
+                                       "ContainerUUID": uuid,
+                                       "State":         ent.Container.State,
+                               }).Error("BUG: unexpected state")
+                               reportedUnexpectedState = true
+                       }
                }
        }
        for uuid := range running {