Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions pkg/cloudscale_ccm/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"math/rand"
"slices"
"strings"
"time"
Expand Down Expand Up @@ -749,9 +748,7 @@ func reconcileLbState(
break
}

// Wait between 5-7.5 seconds between state fetches
// #nosec G404
wait := time.Duration(5000+rand.Intn(2500)) * time.Millisecond
wait := 500 * time.Millisecond

select {
case <-ctx.Done():
Expand Down
15 changes: 14 additions & 1 deletion pkg/internal/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/cloudscale-ch/cloudscale-go-sdk/v6"
"k8s.io/klog/v2"
)

type Action interface {
Expand Down Expand Up @@ -50,6 +51,18 @@ func (a *CreateLbAction) Label() string {
func (a *CreateLbAction) Run(
ctx context.Context, client *cloudscale.Client) (Control, error) {

existing, err := client.LoadBalancers.List(ctx)
if err == nil {
for _, lb := range existing {
if lb.Name == a.lb.Name {
klog.InfoS("lb already exists, skipping create",
"name", a.lb.Name, "uuid", lb.UUID)

return Refresh, nil
}
}
}

addrs := make([]cloudscale.VIPAddressRequest, 0, len(a.lb.VIPAddresses))
for _, addr := range a.lb.VIPAddresses {
addrs = append(addrs, cloudscale.VIPAddressRequest{
Expand All @@ -58,7 +71,7 @@ func (a *CreateLbAction) Run(
})
}

_, err := client.LoadBalancers.Create(ctx, &cloudscale.LoadBalancerRequest{
_, err = client.LoadBalancers.Create(ctx, &cloudscale.LoadBalancerRequest{
Name: a.lb.Name,
Flavor: a.lb.Flavor.Slug,
VIPAddresses: &addrs,
Expand Down
Loading