Fix a bug in validation that was leftover from the previous way of externalizing services.

This commit is contained in:
Brendan Burns 2015-01-26 13:19:27 -08:00
parent 6410f37a32
commit 99583fc8c5
2 changed files with 2 additions and 17 deletions

View File

@ -485,21 +485,6 @@ func ValidateService(service *api.Service, lister ServiceLister, ctx api.Context
allErrs = append(allErrs, ValidateLabels(service.Labels, "labels")...)
allErrs = append(allErrs, ValidateLabels(service.Annotations, "annotations")...)
if service.Spec.CreateExternalLoadBalancer {
services, err := lister.ListServices(ctx)
if err != nil {
allErrs = append(allErrs, errs.NewInternalError(err))
} else {
for i := range services.Items {
if services.Items[i].Name != service.Name &&
services.Items[i].Spec.CreateExternalLoadBalancer &&
services.Items[i].Spec.Port == service.Spec.Port {
allErrs = append(allErrs, errs.NewConflict("service", service.Name, fmt.Errorf("port: %d is already in use", service.Spec.Port)))
break
}
}
}
}
if service.Spec.SessionAffinity == "" {
service.Spec.SessionAffinity = api.AffinityTypeNone
} else if !supportedSessionAffinityType.Has(string(service.Spec.SessionAffinity)) {

View File

@ -953,7 +953,7 @@ func TestValidateService(t *testing.T) {
numErrs: 0,
},
{
name: "invalid port in use",
name: "external port in use",
svc: api.Service{
ObjectMeta: api.ObjectMeta{Name: "abc123", Namespace: api.NamespaceDefault},
Spec: api.ServiceSpec{
@ -970,7 +970,7 @@ func TestValidateService(t *testing.T) {
},
},
},
numErrs: 1,
numErrs: 0,
},
{
name: "same port in use, but not external",