Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Avoid race conditions on profile creation#71

Merged
tomdee merged 2 commits intoprojectcalico:gofrom
robbrockbank:always-create-profile
Nov 1, 2016
Merged

Avoid race conditions on profile creation#71
tomdee merged 2 commits intoprojectcalico:gofrom
robbrockbank:always-create-profile

Conversation

@robbrockbank
Copy link
Copy Markdown
Contributor

Tom,

Just a suggested fix (I haven't tested it, although compiler looks happy enough). Just always create profile rather than check first then create.

It's one less round trip (hardly worth it perhaps), a minor simplification, but also avoids race conditions where two threads may attempt to create the profile at the same time - which you could actually just fix by checking for the ResourceAlreadyExists error on the create.

@tomdee
Copy link
Copy Markdown
Contributor

tomdee commented Nov 1, 2016

Yep, much nicer code.

But

# github.com/projectcalico/libnetwork-plugin/driver
driver/network_driver.go:153: cannot use profile (type "github.com/projectcalico/libnetwork-plugin/vendor/github.com/projectcalico/libcalico-go/lib/api".Profile) as type *"github.com/projectcalico/libnetwork-plugin/vendor/github.com/projectcalico/libcalico-go/lib/api".Profile in argument to d.client.Profiles().Create
Makefile:43: recipe for target 'build' failed```

@robbrockbank
Copy link
Copy Markdown
Contributor Author

D'oh my bad - I didn't push my fix.. It's pushed now.

@tomdee tomdee merged commit 2da36bd into projectcalico:go Nov 1, 2016
tomdee pushed a commit that referenced this pull request Nov 1, 2016
* Avoid race conditions on profile creation

* Profile should be pointer
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants