Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clustermesh: parallelize connections #2702

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions clustermesh/clustermesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"sort"
"strconv"
"strings"
"sync"
"text/tabwriter"
"time"

Expand Down Expand Up @@ -1652,27 +1653,37 @@ func (k *K8sClusterMesh) ConnectWithHelm(ctx context.Context) error {
ReuseValues: true,
}

var wg sync.WaitGroup
wg.Add(2)
// Enable clustermesh using a Helm Upgrade command against our target cluster
k.Log("ℹ️ Configuring Cilium in cluster '%s' to connect to cluster '%s'",
localClient.ClusterName(), remoteClient.ClusterName())
_, err = helm.Upgrade(ctx, localClient.HelmActionConfig, upgradeParams)
if err != nil {
return err
}
go HelmUpgrade(ctx, &wg, &err, localClient, upgradeParams)

// Enable clustermesh using a Helm Upgrade command against the remote cluster
k.Log("ℹ️ Configuring Cilium in cluster '%s' to connect to cluster '%s'",
remoteClient.ClusterName(), localClient.ClusterName())
upgradeParams.Values = remoteHelmValues
_, err = helm.Upgrade(ctx, remoteClient.HelmActionConfig, upgradeParams)
go HelmUpgrade(ctx, &wg, &err, remoteClient, upgradeParams)

if err != nil {
return err
}

wg.Wait()

k.Log("✅ Connected cluster %s and %s!", localClient.ClusterName(), remoteClient.ClusterName())
return nil
}

func HelmUpgrade(ctx context.Context, wg *sync.WaitGroup, err *error, client *k8s.Client, upgradeParams helm.UpgradeParameters) {
defer wg.Done()
_, e := helm.Upgrade(ctx, client.HelmActionConfig, upgradeParams)
if e != nil {
*err = errors.New(e.Error())
}
}

func (k *K8sClusterMesh) DisconnectWithHelm(ctx context.Context) error {
localRelease, err := getRelease(k.client.(*k8s.Client), k.params)
if err != nil {
Expand Down
Loading