Skip to content

Commit

Permalink
fix: delete plugins in parallel to avoid hitting timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-ibra committed Nov 30, 2023
1 parent 3ae7b70 commit 97978e9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/controller/validatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/base64"
"fmt"
"strings"
"sync"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down

0 comments on commit 97978e9

Please sign in to comment.