Stop using "default" as default service namespace (#61)

Previously the destinations service would look for services in the
"default" namespace if the service name didn't have at least two
labels. However, the "default" namespace is almost always the wrong
namespace. The only reasonable default namespace is the namespace of
the client service, which isn't given to the destinations service.
Therefore it shouldn't try to default the namespace.

Accordingly, stop defaulting the namespace to "default".

Validated by manually testing the emojivoto service before and after
the proxy implemented namespace defaulting itself.
This commit is contained in:
Brian Smith 2017-12-20 10:44:24 -10:00 committed by GitHub
parent a8e75115ab
commit 2729fa02bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -85,12 +85,16 @@ func (s *server) Get(dest *common.Destination, stream pb.Destination_GetServer)
} }
// service.namespace.svc.cluster.local // service.namespace.svc.cluster.local
domains := strings.Split(host, ".") domains := strings.Split(host, ".")
service := domains[0]
namespace := "default" if len(domains) < 2 {
if len(domains) > 1 { err := fmt.Errorf("not a service: %s", host)
namespace = domains[1] log.Error(err)
return err
} }
service := domains[0]
namespace := domains[1]
id := namespace + "/" + service id := namespace + "/" + service
listener := endpointListener{stream: stream} listener := endpointListener{stream: stream}