Skip to content

Handle Swarm-style prefixed container names - #851

Merged
aanand merged 3 commits into
docker:masterfrom
aanand:swarm-names
Jan 20, 2015
Merged

aanand merged 3 commits into
docker:masterfrom
aanand:swarm-names

Conversation

@aanand

@aanand aanand commented Jan 16, 2015

Copy link
Copy Markdown

Related to #814.

Swarm prefixes all container names with an extra path component, breaking our name-finding logic when trying to get the "given" name of a container from the output of /containers/json.

The fix: instead of looking for a name with exactly one path component, we pick the shortest one (counting path components of course, not characters) out of the Names array.

ping @aluzzardi @vieux - what do you two think of this? Can we do something less hacky?

@aluzzardi

Copy link
Copy Markdown

@aanand The current state of names in Swarm is hackish. The only reason we do that is because we cannot add a new column. I don't know if adding a workaround to the hack is the way to go.

Maybe we could embed the node as a label (moby/moby#9882) and keep the names verbatim?

@thaJeztah

Copy link
Copy Markdown
Member

I'd be +1 on using labels; fig/compose and swarm could both add namespaced labels, e.g. com.docker.swarm.node=foo and com.docker.compose.project=my-project

@aanand

aanand commented Jan 19, 2015

Copy link
Copy Markdown
Author

I would love for it to be done with labels, but that would mean blocking on a Docker release. Since it looks very unlikely that labels will make it into the same release that goes out alongside Swarm and Compose, and we want the two to work together on day one (at least in a rudimentary fashion), we're going to need some kind of solution that works now.

@thaJeztah

Copy link
Copy Markdown
Member

Yes, having to wait for Docker to implement it upstream is a blocker. It think implementing the "hacky" way now is the best way to go for the time being. As long as it's clearly mentioned that this is a "technical preview" (or something) and this will change in future (otherwise supporting old installations would become a nightmare).

@aanand

aanand commented Jan 19, 2015

Copy link
Copy Markdown
Author

Well, the existing behaviour (look for a name with a single path component) is already a hack; this is just a slightly different and more permissive hack. Either way, we're going to deprecate it once there's a better way to tag a container with the project and service.

My only worry is whether it's fully backwards-compatible, but I think that it is: a container's "primary" name (e.g. /host_1/myapp_db_1) will always be the shortest, since its other names can only be created by linking it to other containers, which will result in them being prefixed (e.g. /host_1/myapp_web_1/db).

@thaJeztah

Copy link
Copy Markdown
Member

@aanand Have you checked if everything works correctly against this PR: moby/moby#10105 ?

@aanand

aanand commented Jan 19, 2015

Copy link
Copy Markdown
Author

I've been paying attention to that one: it shouldn't be a problem, because the new behaviour will be that only the primary name is returned. I haven't explicitly tested it yet, though.

@thaJeztah

Copy link
Copy Markdown
Member

Ok, thanks, just confirming in case you missed it in the vast amount of PRs and issues.

@aanand aanand changed the title WIP: Handle Swarm-style prefixed container names Handle Swarm-style prefixed container names Jan 20, 2015
@aanand aanand added this to the 1.1.0 milestone Jan 20, 2015
@aanand aanand mentioned this pull request Jan 20, 2015
@dnephin

dnephin commented Jan 20, 2015

Copy link
Copy Markdown

LGTM

aanand added a commit that referenced this pull request Jan 20, 2015
Handle Swarm-style prefixed container names
@aanand
aanand merged commit 7be8b4c into docker:master Jan 20, 2015
@aanand
aanand deleted the swarm-names branch January 20, 2015 20:51
yuval-k pushed a commit to yuval-k/compose that referenced this pull request Apr 10, 2015
Handle Swarm-style prefixed container names
Signed-off-by: Yuval Kohavi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants