Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #28568 from xiangpengzhao/check_ensureDnsRecords_r…
Browse files Browse the repository at this point in the history
…eturn_value

Automatic merge from submit-queue

Check return value when calling ensureDnsRecords

When [lockedUpdateDNSRecords](https://github.com/xiangpengzhao/kubernetes/blob/check_ensureDnsRecords_return_value/federation/pkg/federation-controller/service/servicecontroller.go#L723) calls `ensureDnsRecords`, it should check the return value. If it returns error, the `ensuredCount ` should not increment.
  • Loading branch information
Kubernetes Submit Queue committed Aug 18, 2016
2 parents 5c29621 + e41f830 commit 2cad8da
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/federation-controller/service/servicecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,18 +724,26 @@ func (s *ServiceController) lockedUpdateDNSRecords(service *cachedService, clust
if !wantsDNSRecords(service.appliedState) {
return nil
}

ensuredCount := 0
unensuredCount := 0
for key := range s.clusterCache.clientMap {
for _, clusterName := range clusterNames {
if key == clusterName {
s.ensureDnsRecords(clusterName, service)
ensuredCount += 1
err := s.ensureDnsRecords(clusterName, service)
if err != nil {
unensuredCount += 1
glog.V(4).Infof("Failed to update DNS records for service %v from cluster %s: %v", service, clusterName, err)
} else {
ensuredCount += 1
}
}
}
}
if ensuredCount < len(clusterNames) {
return fmt.Errorf("Failed to update DNS records for %d of %d clusters for service %v due to missing clients for those clusters",
len(clusterNames)-ensuredCount, len(clusterNames), service)
missedCount := len(clusterNames) - ensuredCount - unensuredCount
if missedCount > 0 || unensuredCount > 0 {
return fmt.Errorf("Failed to update DNS records for %d clusters for service %v due to missing clients [missed count: %d] and/or failing to ensure DNS records [unensured count: %d]",
len(clusterNames), service, missedCount, unensuredCount)
}
return nil
}
Expand Down

0 comments on commit 2cad8da

Please sign in to comment.