Skip to content

Commit

Permalink
Return error if ports are specified in dsnrr mode
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
  • Loading branch information
marcosnils committed Jul 22, 2016
1 parent b3d7a48 commit 8356e99
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manager/controlapi/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func validateEndpointSpec(epSpec *api.EndpointSpec) error {
return nil
}

if len(epSpec.Ports) > 0 && epSpec.Mode == api.ResolutionModeDNSRoundRobin {
return grpc.Errorf(codes.InvalidArgument, "EndpointSpec: ports can't be used with dnsrr mode")
}

portSet := make(map[api.PortConfig]struct{})
for _, port := range epSpec.Ports {
if _, ok := portSet[*port]; ok {
Expand Down
12 changes: 12 additions & 0 deletions manager/controlapi/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,18 @@ func TestRemoveService(t *testing.T) {
assert.NotNil(t, r)
}

func TestValidateEndpointSpec(t *testing.T) {
err := validateEndpointSpec(&api.EndpointSpec{
Mode: api.ResolutionModeDNSRoundRobin,
Ports: []*api.PortConfig{
{
Name: "http", TargetPort: 80,
},
},
})
assert.Error(t, err)
}

func TestServiceEndpointSpecUpdate(t *testing.T) {
ts := newTestServer(t)
spec := &api.ServiceSpec{
Expand Down

0 comments on commit 8356e99

Please sign in to comment.