Merge pull request #13855 from jiangyaoguo/fix-reason-reporting-in-controller

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2015-09-14 12:32:03 -07:00
commit 653e5defa5
3 changed files with 18 additions and 14 deletions

View File

@ -515,7 +515,8 @@ func (nc *NodeController) tryUpdateNodeStatus(node *api.Node) (time.Duration, ap
node.Status.Conditions = append(node.Status.Conditions, api.NodeCondition{ node.Status.Conditions = append(node.Status.Conditions, api.NodeCondition{
Type: api.NodeReady, Type: api.NodeReady,
Status: api.ConditionUnknown, Status: api.ConditionUnknown,
Reason: fmt.Sprintf("Kubelet never posted node status."), Reason: "NodeStatusNeverUpdated",
Message: fmt.Sprintf("Kubelet never posted node status."),
LastHeartbeatTime: node.CreationTimestamp, LastHeartbeatTime: node.CreationTimestamp,
LastTransitionTime: nc.now(), LastTransitionTime: nc.now(),
}) })
@ -524,7 +525,8 @@ func (nc *NodeController) tryUpdateNodeStatus(node *api.Node) (time.Duration, ap
node.Name, nc.now().Time.Sub(savedNodeStatus.probeTimestamp.Time), lastReadyCondition) node.Name, nc.now().Time.Sub(savedNodeStatus.probeTimestamp.Time), lastReadyCondition)
if lastReadyCondition.Status != api.ConditionUnknown { if lastReadyCondition.Status != api.ConditionUnknown {
readyCondition.Status = api.ConditionUnknown readyCondition.Status = api.ConditionUnknown
readyCondition.Reason = fmt.Sprintf("Kubelet stopped posting node status.") readyCondition.Reason = "NodeStatusUnknown"
readyCondition.Message = fmt.Sprintf("Kubelet stopped posting node status.")
// LastProbeTime is the last time we heard from kubelet. // LastProbeTime is the last time we heard from kubelet.
readyCondition.LastHeartbeatTime = lastReadyCondition.LastHeartbeatTime readyCondition.LastHeartbeatTime = lastReadyCondition.LastHeartbeatTime
readyCondition.LastTransitionTime = nc.now() readyCondition.LastTransitionTime = nc.now()

View File

@ -400,7 +400,8 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
{ {
Type: api.NodeReady, Type: api.NodeReady,
Status: api.ConditionUnknown, Status: api.ConditionUnknown,
Reason: fmt.Sprintf("Kubelet never posted node status."), Reason: "NodeStatusNeverUpdated",
Message: fmt.Sprintf("Kubelet never posted node status."),
LastHeartbeatTime: util.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), LastHeartbeatTime: util.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
LastTransitionTime: fakeNow, LastTransitionTime: fakeNow,
}, },
@ -486,7 +487,8 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
{ {
Type: api.NodeReady, Type: api.NodeReady,
Status: api.ConditionUnknown, Status: api.ConditionUnknown,
Reason: fmt.Sprintf("Kubelet stopped posting node status."), Reason: "NodeStatusStopUpdated",
Message: fmt.Sprintf("Kubelet stopped posting node status."),
LastHeartbeatTime: util.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC), LastHeartbeatTime: util.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
LastTransitionTime: util.Time{Time: util.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC).Add(time.Hour)}, LastTransitionTime: util.Time{Time: util.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC).Add(time.Hour)},
}, },

View File

@ -245,7 +245,7 @@ func (s *ServiceController) processDelta(delta *cache.Delta) (error, bool) {
message += " (will not retry): " message += " (will not retry): "
} }
message += err.Error() message += err.Error()
s.eventRecorder.Event(service, "creating loadbalancer failed", message) s.eventRecorder.Event(service, "CreatingLoadBalancerFailed", message)
return err, retry return err, retry
} }
// Always update the cache upon success. // Always update the cache upon success.
@ -255,14 +255,14 @@ func (s *ServiceController) processDelta(delta *cache.Delta) (error, bool) {
cachedService.appliedState = service cachedService.appliedState = service
s.cache.set(namespacedName.String(), cachedService) s.cache.set(namespacedName.String(), cachedService)
case cache.Deleted: case cache.Deleted:
s.eventRecorder.Event(service, "deleting loadbalancer", "deleting loadbalancer") s.eventRecorder.Event(service, "DeletingLoadBalancer", "deleting loadbalancer")
err := s.balancer.EnsureTCPLoadBalancerDeleted(s.loadBalancerName(service), s.zone.Region) err := s.balancer.EnsureTCPLoadBalancerDeleted(s.loadBalancerName(service), s.zone.Region)
if err != nil { if err != nil {
message := "error deleting load balancer (will retry): " + err.Error() message := "error deleting load balancer (will retry): " + err.Error()
s.eventRecorder.Event(service, "deleting loadbalancer failed", message) s.eventRecorder.Event(service, "DeletingLoadBalancerFailed", message)
return err, retryable return err, retryable
} }
s.eventRecorder.Event(service, "deleted loadbalancer", "deleted loadbalancer") s.eventRecorder.Event(service, "DeletedLoadBalancer", "deleted loadbalancer")
s.cache.delete(namespacedName.String()) s.cache.delete(namespacedName.String())
default: default:
glog.Errorf("Unexpected delta type: %v", delta.Type) glog.Errorf("Unexpected delta type: %v", delta.Type)
@ -305,11 +305,11 @@ func (s *ServiceController) createLoadBalancerIfNeeded(namespacedName types.Name
if needDelete { if needDelete {
glog.Infof("Deleting existing load balancer for service %s that no longer needs a load balancer.", namespacedName) glog.Infof("Deleting existing load balancer for service %s that no longer needs a load balancer.", namespacedName)
s.eventRecorder.Event(service, "deleting loadbalancer", "deleting loadbalancer") s.eventRecorder.Event(service, "DeletingLoadBalancer", "deleting loadbalancer")
if err := s.balancer.EnsureTCPLoadBalancerDeleted(s.loadBalancerName(service), s.zone.Region); err != nil { if err := s.balancer.EnsureTCPLoadBalancerDeleted(s.loadBalancerName(service), s.zone.Region); err != nil {
return err, retryable return err, retryable
} }
s.eventRecorder.Event(service, "deleted loadbalancer", "deleted loadbalancer") s.eventRecorder.Event(service, "DeletedLoadBalancer", "deleted loadbalancer")
} }
service.Status.LoadBalancer = api.LoadBalancerStatus{} service.Status.LoadBalancer = api.LoadBalancerStatus{}
@ -319,12 +319,12 @@ func (s *ServiceController) createLoadBalancerIfNeeded(namespacedName types.Name
// TODO: We could do a dry-run here if wanted to avoid the spurious cloud-calls & events when we restart // TODO: We could do a dry-run here if wanted to avoid the spurious cloud-calls & events when we restart
// The load balancer doesn't exist yet, so create it. // The load balancer doesn't exist yet, so create it.
s.eventRecorder.Event(service, "creating loadbalancer", "creating loadbalancer") s.eventRecorder.Event(service, "CreatingLoadBalancer", "creating loadbalancer")
err := s.createExternalLoadBalancer(service) err := s.createExternalLoadBalancer(service)
if err != nil { if err != nil {
return fmt.Errorf("failed to create external load balancer for service %s: %v", namespacedName, err), retryable return fmt.Errorf("failed to create external load balancer for service %s: %v", namespacedName, err), retryable
} }
s.eventRecorder.Event(service, "created loadbalancer", "created loadbalancer") s.eventRecorder.Event(service, "CreatedLoadBalancer", "created loadbalancer")
} }
// Write the state if changed // Write the state if changed
@ -659,7 +659,7 @@ func (s *ServiceController) lockedUpdateLoadBalancerHosts(service *api.Service,
name := cloudprovider.GetLoadBalancerName(service) name := cloudprovider.GetLoadBalancerName(service)
err := s.balancer.UpdateTCPLoadBalancer(name, s.zone.Region, hosts) err := s.balancer.UpdateTCPLoadBalancer(name, s.zone.Region, hosts)
if err == nil { if err == nil {
s.eventRecorder.Event(service, "updated loadbalancer", "updated loadbalancer with new hosts") s.eventRecorder.Event(service, "UpdatedLoadBalancer", "updated loadbalancer with new hosts")
return nil return nil
} }
@ -671,7 +671,7 @@ func (s *ServiceController) lockedUpdateLoadBalancerHosts(service *api.Service,
} }
message := "error updating loadbalancer with new hosts: " + err.Error() message := "error updating loadbalancer with new hosts: " + err.Error()
s.eventRecorder.Event(service, "updating loadbalancer failed", message) s.eventRecorder.Event(service, "LoadBalancerUpdateFailed", message)
return err return err
} }