-
Notifications
You must be signed in to change notification settings - Fork 9
Conversation
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.
This is really cool! I have a couple of stylistic comments/questions. Also, +1 to @abrookins comment on using dequeue
.
prefect_kubernetes/utilities.py
Outdated
cache = FIFOCache(maxsize=self.max_cache_size) | ||
yield from self._stream(cache, func, *args, **kwargs) | ||
|
||
def log_stream(self, func: Callable, *args, **kwargs): |
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.
This function looks like it's a very thin wrapper around _stream
and doesn't inherently have any knowledge of logs. Would we be able to remove this method and make _stream
'public' instead?
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.
I think that it'll be a good experience to have stream
publicly available for a more general use case. I removed log_stream
and updated the stream
docstring to note it's behaviors on log stream client methods.
Co-authored-by: Alexander Streed <[email protected]>
Co-authored-by: Alexander Streed <[email protected]>
Co-authored-by: Alexander Streed <[email protected]>
Co-authored-by: Alexander Streed <[email protected]>
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.
Very cool implementation!
Co-authored-by: Alexander Streed <[email protected]>
Co-authored-by: Alexander Streed <[email protected]>
Co-authored-by: Alexander Streed <[email protected]>
This reverts commit f2e4d88.
This reverts commit f2e4d88.
This PR introduces a new
ResilientWatcher
utility to swap in forkubernetes.watch.Watch
objects. This new class will "resiliently" watch streams produced by Kubernetes client functions. If an exception we want to retry is raised during the stream, the new utility will sleep for 1 second before restarting the stream from the begining. All other exceptions are raised and halt the stream.The behavior of restarting the stream from the beginning means its possible to produce duplicate objects while streaming. This PR helps to address that by adding a cache (specifically for streaming API objects) that can track which data has been produced by a stream and filter redundant data out. This is the functionality of the
api_objects_stream
method - it tracks Kubenetes object IDs in an internal cache. There is another methodlog_stream
which is intended to be used for client functions that return a stream of logs. Since there is no way to reliably deduplicate logs, logs will be repeated on restarted streams.Closes #96 and #106
Example
Screenshots
Checklist
pre-commit
checks.pre-commit install && pre-commit run --all
locally for formatting and linting.mkdocs serve
view documentation locally.