-
Notifications
You must be signed in to change notification settings - Fork 1
Add pre-create duplicate check and reduce sleep #58
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
base: fix/duplicate-lb-mutex
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/cloudscale-ch/cloudscale-go-sdk/v6" | ||
| "k8s.io/klog/v2" | ||
| ) | ||
|
|
||
| type Action interface { | ||
|
|
@@ -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 | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+54
to
+65
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the mutex in the other PR works correctly, when would you expected that this case is still relevant?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's more of a safety check. We can also remove it. |
||
| addrs := make([]cloudscale.VIPAddressRequest, 0, len(a.lb.VIPAddresses)) | ||
| for _, addr := range a.lb.VIPAddresses { | ||
| addrs = append(addrs, cloudscale.VIPAddressRequest{ | ||
|
|
@@ -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, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this is too aggressive. Open to discuss and test going form 5-7.5s to lets say 2-4s, but I'd recommend against 500ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that we had more integration test failures with this: I'll revert this change.