mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Richer errors for validation
This commit is contained in:
parent
9255770068
commit
a271771341
@ -1081,7 +1081,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
||||
if service.Spec.Type == api.ServiceTypeLoadBalancer {
|
||||
for i := range service.Spec.Ports {
|
||||
if service.Spec.Ports[i].Protocol != api.ProtocolTCP {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.ports", service.Spec.Ports[i], "cannot create an external load balancer with non-TCP ports"))
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].protocol", i), service.Spec.Ports[i], "cannot create an external load balancer with non-TCP ports"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1089,7 +1089,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
||||
if service.Spec.Type == api.ServiceTypeClusterIP {
|
||||
for i := range service.Spec.Ports {
|
||||
if service.Spec.Ports[i].NodePort != 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.ports", service.Spec.Ports[i], "cannot specify a node port with cluster-visibility services"))
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].nodePort", i), service.Spec.Ports[i], "cannot specify a node port with services of type ClusterIP"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1106,7 +1106,7 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
||||
key.NodePort = port.NodePort
|
||||
_, found := nodePorts[key]
|
||||
if found {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.ports", *port, "duplicate nodePort specified"))
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid(fmt.Sprintf("spec.ports[%d].nodePort", i), *port, "duplicate nodePort specified"))
|
||||
}
|
||||
nodePorts[key] = true
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ func (s *ServiceController) createLoadBalancerIfNeeded(namespacedName types.Name
|
||||
// the cloud provider for what it knows about it.
|
||||
status, exists, err := s.balancer.GetTCPLoadBalancer(s.loadBalancerName(service), s.zone.Region)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting LB for service %s", namespacedName), retryable
|
||||
return fmt.Errorf("Error getting LB for service %s: %v", namespacedName, err), retryable
|
||||
}
|
||||
if exists && api.LoadBalancerStatusEqual(status, &service.Status.LoadBalancer) {
|
||||
glog.Infof("LB already exists with status %s for previously uncached service %s", status, namespacedName)
|
||||
|
Loading…
Reference in New Issue
Block a user