Endpoint controller logs errors during normal cluster behavior

pull/6/head
derekwaynecarr 2016-08-12 11:39:56 -04:00
parent 9fe15e7376
commit 038c754b7f
1 changed files with 12 additions and 2 deletions

View File

@ -487,7 +487,9 @@ func (e *EndpointController) syncService(key string) {
} else { } else {
newEndpoints.Annotations[endpoints.PodHostnamesAnnotation] = serializedPodHostNames newEndpoints.Annotations[endpoints.PodHostnamesAnnotation] = serializedPodHostNames
} }
if len(currentEndpoints.ResourceVersion) == 0 {
createEndpoints := len(currentEndpoints.ResourceVersion) == 0
if createEndpoints {
// No previous endpoints, create them // No previous endpoints, create them
_, err = e.client.Endpoints(service.Namespace).Create(newEndpoints) _, err = e.client.Endpoints(service.Namespace).Create(newEndpoints)
} else { } else {
@ -495,7 +497,15 @@ func (e *EndpointController) syncService(key string) {
_, err = e.client.Endpoints(service.Namespace).Update(newEndpoints) _, err = e.client.Endpoints(service.Namespace).Update(newEndpoints)
} }
if err != nil { if err != nil {
glog.Errorf("Error updating endpoints: %v", err) if createEndpoints && errors.IsForbidden(err) {
// A request is forbidden primarily for two reasons:
// 1. namespace is terminating, endpoint creation is not allowed by default.
// 2. policy is misconfigured, in which case no service would function anywhere.
// Given the frequency of 1, we log at a lower level.
glog.V(5).Infof("Forbidden from creating endpoints: %v", err)
} else {
utilruntime.HandleError(err)
}
e.queue.Add(key) // Retry e.queue.Add(key) // Retry
} }
} }