From 97978e91ba5df4eee8a381ea91578106e231e990 Mon Sep 17 00:00:00 2001 From: Ahmad Ibrahim Date: Thu, 30 Nov 2023 14:12:05 -0800 Subject: [PATCH] fix: delete plugins in parallel to avoid hitting timeouts --- internal/controller/validatorconfig_controller.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/controller/validatorconfig_controller.go b/internal/controller/validatorconfig_controller.go index c1390cf6..e68c5f72 100644 --- a/internal/controller/validatorconfig_controller.go +++ b/internal/controller/validatorconfig_controller.go @@ -22,6 +22,7 @@ import ( "encoding/base64" "fmt" "strings" + "sync" "time" "github.com/go-logr/logr" @@ -273,6 +274,7 @@ func getPluginHashKey(pluginName string) string { // deletePlugins deletes each validator plugin's Helm release func (r *ValidatorConfigReconciler) deletePlugins(ctx context.Context, vc *v1alpha1.ValidatorConfig) error { + var wg sync.WaitGroup for _, p := range vc.Spec.Plugins { release, err := r.HelmSecretsClient.Get(ctx, p.Chart.Name, vc.Namespace) if err != nil { @@ -284,8 +286,15 @@ func (r *ValidatorConfigReconciler) deletePlugins(ctx context.Context, vc *v1alp if release.Secret.Labels == nil || release.Secret.Labels["owner"] != "helm" { return nil } - r.deletePlugin(vc, p.Chart.Name) + + wg.Add(1) + go func(name string) { + defer wg.Done() + r.deletePlugin(vc, name) + }(p.Chart.Name) } + + wg.Wait() return nil }