Skip to content
This repository was archived by the owner on Sep 26, 2018. It is now read-only.

Use service server IPs from Sidecar#11

Merged
mihaitodor merged 8 commits intomasterfrom
use-sidecar-host-ips
May 23, 2017
Merged

Use service server IPs from Sidecar#11
mihaitodor merged 8 commits intomasterfrom
use-sidecar-host-ips

Conversation

@mihaitodor
Copy link
Copy Markdown

@mihaitodor mihaitodor commented May 12, 2017

This is a follow-up to the conversation from here.

We want to fetch the IP addresses from Sidecar, if possible.

Also, we want to support having multiple ports exposed for the same service on the same host. This changeset appends _<port> to the service name when multiple ports are provided instead of exposing only the first port.

TODO:

  • do we want to not add the server at all if the hostname can't be resolved to an IP or should we just let Traefik deal with that?

@mihaitodor mihaitodor force-pushed the use-sidecar-host-ips branch from 4ebe5a8 to 1062fec Compare May 19, 2017 14:30
@mihaitodor
Copy link
Copy Markdown
Author

@relistan @bparli Please have a look and let me know what you think.

@bparli
Copy link
Copy Markdown

bparli commented May 19, 2017

do we want to not add the server at all if the hostname can't be resolved to an IP or should we just let Traefik deal with that?

I'd gone back and forth on this before, but lean towards not adding it now. I think you'd argued this previously too @mihaitodor; if we can't resolve the address at this stage, the rest of the program likely won't be able to either.

@mihaitodor
Copy link
Copy Markdown
Author

OK @bparli, I updated the code.

@relistan May I go ahead and merge this changeset?

Copy link
Copy Markdown

@relistan relistan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, some comments below.

Comment thread provider/sidecar.go Outdated
URL: "http://" + ipAddr[0].String() + ":" + strconv.FormatInt(svc.Ports[i].Port, 10),
for _, port := range svc.Ports {
name := svc.Hostname
if len(svc.Ports) > 1 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just make them consistent and always use the port.

Comment thread provider/sidecar.go Outdated
}

host := port.IP
if host == "" {
Copy link
Copy Markdown

@relistan relistan May 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't do this in Sidecar and should, but let's be careful here to make sure we got a properly formed IP address by doing an net.ParseIP here to make sure it's a valid IP as well. We will just use the string, but the parse will tell us it's legit.

Comment thread provider/sidecar_test.go Outdated
Hostname: "another-aws-host",
Status: 0,
Ports: []service.Port{
service.Port{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt -s on this file and it will probably remove these inner service.Port names.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch @relistan! So, it turns out that the standard goimports doesn't support the -s flag that gofmt provides. I ended up installing this 3rd party goimports to have this flag and keep using the goimports hook on save.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's one annoyance of goimports. 💯 I'll take a look at the fork.

Comment thread provider/sidecar_test.go
@@ -101,13 +132,21 @@ func TestSidecar(t *testing.T) {

backs := prov.makeBackends(states)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like way too much stuff to be checking in a single test. The comments explaining all the checks are the giveaway. Even if you have to repeat the same loading of the data multiple times in separate tests, this should be broken into tests that are validating the same functionality. Just share the setup between the Convey blocks and give the So clauses a wrapper that explains what they're doing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I'm starting to like goconvey :)

@mihaitodor
Copy link
Copy Markdown
Author

@relistan I think I covered everything. Please let me know if it's good to go now.

@relistan
Copy link
Copy Markdown

:shipit: !

@mihaitodor mihaitodor merged commit 3583069 into master May 23, 2017
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.

3 participants