-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check return value when calling ensureDnsRecords #28568
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my last commit, the way calculating missedCount is wrong. It cannot increment in the for loop. Fixed in this commit. @quinton-hoole According to your in-code comments in last commit, I add the V4 log info when s.ensureDnsRecords returns error (call
IMO, the condition For example, if it prints: I'm not sure if I describe clearly. Any more discuss is welcome. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, the comments posted 10 days ago are listed here. We can ignore them here. |
||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error 2 lines below is not correct now. We need to keep track of number of missing cluster clients and number of failed ensureDNsRecords and return an error accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable. The numbers may be counted by below?
key != clusterName
when s.ensureDnsRecords return non nil
?If so, we can define two new variables:
missedCount
,unensuredCount
(instead currentensuredCount
)