[health checking] prep for outlier detection ejecting via health watch#33340
Conversation
…_ejection_via_health_watch
…r_detection_ejection_via_health_watch
…_ejection_via_health_watch
eugeneo
left a comment
There was a problem hiding this comment.
Minor questions/comments.
| auto it = | ||
| health_checkers_.emplace(*health_check_service_name, nullptr).first; | ||
| auto& health_checker = it->second; | ||
| if (health_checker == nullptr) { |
There was a problem hiding this comment.
Not sure I understand this code. Isn't this value always nullptr? Shouldn't MakeOrphanable... from line 372 replace nullptr on line 369?
There was a problem hiding this comment.
There are two possible outcomes from the emplace() call on line 369:
- The entry already existed in the map. In this case, no new entry is added (and the
nullptrvalue passed toemplace()is not actually stored anywhere), and the iterator will point to the preexisting entry in the map. - The entry did not already exist in the map. In this case,
emplace()will add the entry, and the iterator will point to the newly added entry, whose value isnullptr.
If health_checker is null here, that means we're in case 2, and we need to construct the new object.
The reason we don't call MakeOrphanable() before calling emplace() is that we don't want to actually allocate the object if the entry already exists in the map, because in that case, the newly allocated object would just wind up getting immediately destroyed, so we'd do unnecessary work.
| non_health_watchers_.erase(watcher); | ||
| } else { | ||
| auto it = health_checkers_.find(*health_check_service_name); | ||
| if (it == health_checkers_.end()) return; |
There was a problem hiding this comment.
I find these several lines confusing, with multiple conditions and temp variable.
| if (it == health_checkers_.end()) return; | |
| if (it != health_checkers_.end() && it->second->RemoveWatcherLocked(watcher)) { | |
| health_checkers_.erase(it); | |
| } |
There was a problem hiding this comment.
I think the temp variable actually makes the code more readable. Without it, someone reading this code needs to go look at the comment on the RemoveWatcherLocked() method to see that it returns true when this was the last watcher in the HealthChecker.
…state (#33427) More work on the dualstack backend design: - Now that all petiole policies have been changed to delegate to pick_first, outlier detection no longer needs to eject via the subchannel's raw connectivity state; it can now eject only via the health state. See #33340. - This also removes the now-unnecessary hack to explicitly disable outlier detection in pick_first. See #33336.
grpc#33340) Currently, the outlier_detection policy reports ejection by intercepting a subchannel's raw connectivity state watch. In the dualstack backend design, we will instead want to report ejection via the health watch. This PR is a first step toward that goal. Specific changes in this PR: - Add `type()` method to `InternalSubchannelDataWatcherInterface`, to make it possible for LB policies to intercept data watchers. - Use that mechanism in the outlier_detection policy to report ejection both via raw connectivity state watches and via health watches. The hack to prevent outlier_detection from working with pick_first from grpc#33336 has been changed to affect only the raw connectivity watch, not the health watch. - Change health check client to fall back to reporting the raw connectivity state if client-side health checking is not enabled. This will allow pick_first to unconditionally start a health watch when it is running under a petiole policy, which will be a no-op if neither health checking nor outlier detection are configured. Once we are done changing all of the petiole policies to delegate to pick_first, we will remove the code that allows outlier_detection to work via the raw connectivity state, so it will work only via the health watch.
…state (grpc#33427) More work on the dualstack backend design: - Now that all petiole policies have been changed to delegate to pick_first, outlier detection no longer needs to eject via the subchannel's raw connectivity state; it can now eject only via the health state. See grpc#33340. - This also removes the now-unnecessary hack to explicitly disable outlier detection in pick_first. See grpc#33336.
Currently, the outlier_detection policy reports ejection by intercepting a subchannel's raw connectivity state watch. In the dualstack backend design, we will instead want to report ejection via the health watch. This PR is a first step toward that goal.
Specific changes in this PR:
type()method toInternalSubchannelDataWatcherInterface, to make it possible for LB policies to intercept data watchers.Once we are done changing all of the petiole policies to delegate to pick_first, we will remove the code that allows outlier_detection to work via the raw connectivity state, so it will work only via the health watch.