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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

insufficient uniqueness of auto-generated service names #40581

Open
mlin opened this issue Feb 26, 2020 · 2 comments
Open

insufficient uniqueness of auto-generated service names #40581

mlin opened this issue Feb 26, 2020 · 2 comments
Labels
kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Comments

@mlin
Copy link

mlin commented Feb 26, 2020

First, delighted to see the Mirantis blog post on continuing support for swarm mode! 馃帀馃嵕 @dperny

Here service.go uses the namesgenerator package to create a random service name if the caller did not specify one:

// ServiceSpecToGRPC converts a ServiceSpec to a grpc ServiceSpec.
func ServiceSpecToGRPC(s types.ServiceSpec) (swarmapi.ServiceSpec, error) {
name := s.Name
if name == "" {
name = namesgenerator.GetRandomName(0)
}

Based on the two word lists namesgenerator uses, it's only capable of generating <105 distinct names (and this has been trending downwards over time, as words get struck from the list for potentially causing offense). This implies that collisions are expected in most sets of just a few hundred random service names (math), causing intermittent failures in service creation. This has happened to me in an application creating many short-lived services, similar to the new Swarm Jobs feature, which I'd speculate might also be affected by this.

Elsewhere namesgenerator is used in a retry loop -- something similar seems to be needed for service names creation as well. Or, namesgenerator could be changed to add more entropy.

@dperny
Copy link
Contributor

dperny commented Feb 26, 2020

I've actually been aware of this problem for some time. I remember someone getting mad at me for calling it a "birthday problem" because those words have a strong negative connotation in the field of security, but that's essentially what it is.

The difficulty with a retry loop is that each retry iteration would involve making a separate API call to Swarm. It's not all that disruptive, but under the current model, the place where names are generated (your snippet) is quite distant from the place where services are created.

For now, I've no intention of spending time working on this problem, so I'd recommend coming up with a naming scheme for your services, instead of leaving them anonymous and having a name generated.

@mlin
Copy link
Author

mlin commented Feb 26, 2020

OK, that's fair; hopefully leaving this github issue here will help somebody else seeing the intermittent "rpc error: code = Unknown desc = name conflicts with an existing object". It's the sort of problem that tends to only show up in production.

@thaJeztah thaJeztah added the kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. label Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.
Projects
None yet
Development

No branches or pull requests

3 participants