From fe328465b6d0a769243d98b8450c8e56bdffe185 Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Tue, 12 Apr 2022 13:55:45 +0100 Subject: [PATCH] Poll for assemblage updates in the downstream The ProxyAssemblage controller does not have the opportunity to be notified of changes in a downstream cluster (or at least, this would be tricky to arrange, especially at scale), so it won't in general see when its Assemblage counterpart changes status. A dumb but effective way to make sure updates are seen is to simply requeue each ProxyAssemblage to be re-examined after a small interval. This will be OK at moderate scale (I would guess O(100) clusters), since more worker threads can be configured to cope with polling. Larger scales may need a less brute force approach to be figured out. Signed-off-by: Michael Bridgen --- module/controllers/proxyassemblage_controller.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/controllers/proxyassemblage_controller.go b/module/controllers/proxyassemblage_controller.go index 4b26aad..29144c5 100644 --- a/module/controllers/proxyassemblage_controller.go +++ b/module/controllers/proxyassemblage_controller.go @@ -8,6 +8,7 @@ import ( "context" "fmt" "strings" + "time" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/cluster-api/controllers/remote" @@ -20,6 +21,8 @@ import ( fleetv1 "github.com/squaremo/fleeet/module/api/v1alpha1" ) +const proxyPollInterval = 20 * time.Second + // ProxyAssemblageReconciler reconciles a ProxyAssemblage object type ProxyAssemblageReconciler struct { client.Client @@ -84,7 +87,8 @@ func (r *ProxyAssemblageReconciler) Reconcile(ctx context.Context, req ctrl.Requ return ctrl.Result{}, err } - return ctrl.Result{}, nil + // We don't get notified of things happening in the downstream cluster; so, requeue to poll instead. + return ctrl.Result{RequeueAfter: proxyPollInterval}, nil } // SetupWithManager sets up the controller with the Manager.