Skip to content

Conversation

@aburnett
Copy link

If a container exposed multiple ports and a SERVICE_NAME was specified the backend would end up with both exposed ports under the same service.

docker run -p 443 -p 80 -e SERVICE_NAME=webserver nginx

would result in

/webserver/1233456:node01:80
/webserver/1233456:node01:443

With this patch we now get

/webserver-80/1233456:node01:80
/webserver-443/1233456:node01:443

@cgswong
Copy link

cgswong commented Jul 22, 2015

Hmmm. I actually prefer the current behavior since I can get to my service via the a single directory, then get the specific ports via keys and values.

@progrium
Copy link
Contributor

@cgswong but they're different ports and therefore different services. esp when working with clients that use discovery to connect, you don't want to get a list of addresses/ports that speak different protocols.

@aburnett am i correct in the workaround to this being to specify specific service names for each port? SERVICE_80_NAME and SERVICE_443_NAME?

@cgswong
Copy link

cgswong commented Jul 22, 2015

By default in registrator:master for etcd each directory gets named as /services/[service]-[port] for each exposed port unless there's only one exposed port in which case it is named /services/[service]. For example, my Kibana service exposes port 5601 and is named /services/kibana whereas my Elasticsearch service exposes two ports so it gets two directories, i.e. /services/elasticsearch-9200 and /services/elasticsearch-9300.

If I want to call my cluster service on port 9300 something specific I can do -e SERVICE_9300_NAME=es-9300 which results in /services/es-9300. If I want to have a single directory for all my Elasticsearch services (which I prefer) I do -e SERVICE_NAME=elasticsearch which results in /services/elasticsearch. I can still see all my ports and IP under this directory as the keys are still in the form [hostname]:[container_name]:[port] with the values as [ip]:[port], it just centralizes things for me using the single directory entry.

@progrium
Copy link
Contributor

You're saying that the default behavior using SERVICE_NAME is different than not specifying SERVICE_NAME, and I don't think that should be the case. Not only because of the reason I mentioned before, but just for predictability and consistency.

I think if you really want to centralize them, you should go out of your way to name them the same, eg SERVICE_9300_NAME=elasticsearch and SERVICE_9200_NAME=elasticsearch. The default behavior should be more "correct" and mixing protocols is not correct.

@aburnett
Copy link
Author

Correct, the different behavior between the two scenarios was what I found confusing and prompted the patch.

@progrium
Copy link
Contributor

progrium commented Sep 4, 2015

So this is the right thing, but it will break expectations for some people. Can you add an entry to the CHANGELOG file? Also if you can update the relevant docs if necessary that would be super awesome.

@progrium progrium added this to the v7 milestone Sep 4, 2015
@aburnett
Copy link
Author

aburnett commented Sep 8, 2015

Updated.

@progrium
Copy link
Contributor

progrium commented Sep 8, 2015

Thanks!

progrium added a commit that referenced this pull request Sep 8, 2015
@progrium progrium merged commit 4c4cb7b into gliderlabs:master Sep 8, 2015
@ptklechat
Copy link

The command below:

docker run -d --name nginx.0 -p 4443:443 -p 8000:80 -e "SERVICE_443_NAME=https" -e "SERVICE_80_NAME=http" progrium/nginx

should register the services "http" and "https" in Consul (according to the doc). Instead (since this commit in master I suppose), i see the services with names "http-80" and "https-443". Looks like -<PORT> is always appended in case of multiple services...

@JohnyDays
Copy link
Contributor

I have experienced the same behaviour as @ptklechat

@aburnett
Copy link
Author

Seems worth a revert for now perhaps?

@progrium
Copy link
Contributor

I would much prefer to take a fix. Even if it is a PR to revert.

@aburnett
Copy link
Author

@JohnyDays I don't think so, SERVICE_NAME and SERVICE_80_NAME will both cause the metadata to contain 'name' I believe.

@JohnyDays
Copy link
Contributor

In this scope it is already only the port's metadata metadata := serviceMetaData(container.Config, port.ExposedPort) right?

@JohnyDays
Copy link
Contributor

Tried it out in my fork, it did the job. The full change was if isgroup && metadata["name"] == ""

@progrium
Copy link
Contributor

If you can submit a PR, please ask others to try it first to get some confirmations. Thanks for looking into it.

@aburnett
Copy link
Author

@JohnyDays I tried that, but that gets us back to square one where only specifying a SERVICE_NAME creates a single service containing both ports.

@JohnyDays
Copy link
Contributor

It didn't do that for me, but the fork i tried it on is a bit different (not much though)

@JohnyDays
Copy link
Contributor

Can you checkout the changes I just made in #245?

@gtmtech
Copy link

gtmtech commented Dec 17, 2015

This has disappeared into a hole.. What do we have to do to get it moving again? Frustrated that I need one of the features from master which isnt in v6, but I cant take it because of this which completely wrecks the ability for me to control my service names. There's been a few PRs about this, what need to happen for this to be either reverted, or sorted so that we still have the option to name services what we want to? Happy to help out, what do you need @progrium ?

@mattatcha mattatcha mentioned this pull request Mar 5, 2016
Merged
This was referenced Jun 25, 2018
Closed
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.

6 participants