From c7d3582308d564ec82de43ba94560bd7952d2720 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Thu, 21 Feb 2019 11:41:53 -0500 Subject: [PATCH] Mitigate false robot deletion events See b/125308238 Signed-off-by: Fabian Reinartz Change-Id: I252aab3e84cf4985cf9c4b636351f52a4ec56bdb --- src/go/pkg/controller/approllout/controller.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/go/pkg/controller/approllout/controller.go b/src/go/pkg/controller/approllout/controller.go index b3de3a85e..0c20f6ff6 100644 --- a/src/go/pkg/controller/approllout/controller.go +++ b/src/go/pkg/controller/approllout/controller.go @@ -23,6 +23,7 @@ import ( "reflect" "sort" "strings" + "time" apps "github.com/googlecloudrobotics/core/src/go/pkg/apis/apps/v1alpha1" registry "github.com/googlecloudrobotics/core/src/go/pkg/apis/registry/v1alpha1" @@ -111,8 +112,12 @@ func Add(mgr manager.Manager, baseValues chartutil.Values) error { // We just enqueue all AppRollouts again. err = c.Watch( &source.Kind{Type: ®istry.Robot{}}, + // We log robot events for now while b/125308238 persists. + // To mitigate the effects we defer enqueueing in the delete handler + // so the robot ideally reappeared before we reconcile. &handler.Funcs{ CreateFunc: func(e event.CreateEvent, q workqueue.RateLimitingInterface) { + log.Printf("AppRollout controller received create event for Robot %q", e.Meta.GetName()) r.enqueueAll(q) }, UpdateFunc: func(e event.UpdateEvent, q workqueue.RateLimitingInterface) { @@ -125,7 +130,10 @@ func Add(mgr manager.Manager, baseValues chartutil.Values) error { } }, DeleteFunc: func(e event.DeleteEvent, q workqueue.RateLimitingInterface) { - r.enqueueAll(q) + log.Printf("AppRollout controller received delete event for Robot %q", e.Meta.GetName()) + time.AfterFunc(3*time.Second, func() { + r.enqueueAll(q) + }) }, }, )