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
dst: Update GetProfile
's stream when pod associated to HostPort lookup changes
#11334
Merged
Commits on Sep 27, 2023
-
Complete fix for hostport staleness - pod watcher
Followup to #11328, based off of `alpeb/hostport-fixup-stopgap`. Implements a new pod watcher, instantiated along the other ones in the Destination server. It's generic enough to catch all pod events in the cluster, so it's up to the subscribers to filter out the ones they're interested in, and to set up any metrics. In the Destination server's `subscribeToEndpointProfile` method, we create a new `HostPortAdaptor` that is subscribed to the pod watcher, and forwards the pod and protocol updates to the `endpointProfileTranslator`. Handling of Server subscriptions are now handled by this adaptor, which are recycled whenever the pod changes. A new gauge metric `host_port_subscribers` has been created, tracking the number of subscribers for a given HostIP+port combination. ## Other Changes - Moved the `server.createAddress` method into a static function in `endpoints_watcher.go`, for better reusability. - The "Return profile for host port pods" test introduced in #11328 was extended to track the ensuing events after a pod is deleted and then recreated (:taco: to @adleong for the test). - Given that test consumes multiple events, we had to change the `profileStream` test helper to allow for the `GetProfile` call to block. Callers to `profileStream` now need to manually cancel the returned stream.
Configuration menu - View commit details
-
Copy full SHA for aa1f7f8 - Browse repository at this point
Copy the full SHA aa1f7f8View commit details -
Configuration menu - View commit details
-
Copy full SHA for a6303b5 - Browse repository at this point
Copy the full SHA a6303b5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 352b518 - Browse repository at this point
Copy the full SHA 352b518View commit details -
This change moves most of the logic into the PodWatcher, which now watches over pods and Servers. As suggested, ServerWatcher has been decomissioned. The `CreateAddress()` function has been moved into a function of the PodWatcher, because now we're calling it on every every update given the pod associated to an ip:port might change and we need to regenerate the Address object. That function also takes care of capturing opaque protocol info from associated Servers, which is not new and had some logic that was duped in the now defunct ServerWatcher. `getAnnotatedOpaquePorts()` shared the same fate for similar reasons. Other things to note about PodWatcher: - It publishes a new pair of metrics `ip_port_subscribers` and `ip_port_updates` leveraging the framework in `prometheus.go`. - The complexity in `updatePod()` is due to only send stream updates when there are changes in the pod's readiness, to avoid sending duped messages on every pod lifecycle event. Let me know if that logic isn't clear enough. Finally, endpointProfileTranslator's `endpoint` (*pb.WeightedAddr) not being a static object anymore, its `Update()` function now receives an Address that allows it to rebuild the endpoint on the fly (and so `createEndpoint()` was converted into a method of endpointProfileTranslator.
Configuration menu - View commit details
-
Copy full SHA for 377aa8c - Browse repository at this point
Copy the full SHA 377aa8cView commit details -
Move Address/pod creation to podWatcher, consider all Server updates
Moved the Address/pod object creation logic into the podWatcher, on the `getOrNewPodPublisher()` method, called from `Subscribe()`. The latter receives `service`, `hostname` and `ip`, which can be empty depending on the case. With this change also the auxiliary functions `getIndexedPod()` and `podReceivingTraffic()` were moved into the `watcher` package. Also the Server updates handler now triggers updates for all podPublishers regardless of the Server selectors. The endpointProfileTranslator is now tracking the last message sent, to avoid sending dupe messages. Other changes: - Added fields `defaultOpaquePorts`, `k8sAPI` and `metadataAPI` into the podPublisher struct. - Removed the fields `ip` and `port` from the endpointProfileTranslator, which are not used.
Configuration menu - View commit details
-
Copy full SHA for d3a149d - Browse repository at this point
Copy the full SHA d3a149dView commit details -
Apply suggestions from code review
Co-authored-by: Matei David <matei@buoyant.io>
Configuration menu - View commit details
-
Copy full SHA for 33f5683 - Browse repository at this point
Copy the full SHA 33f5683View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5f0f7e9 - Browse repository at this point
Copy the full SHA 5f0f7e9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c53067 - Browse repository at this point
Copy the full SHA 9c53067View commit details -
Revert "Apply suggestions from code review"
This reverts commit ae0438f.
Configuration menu - View commit details
-
Copy full SHA for 9d932f8 - Browse repository at this point
Copy the full SHA 9d932f8View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.