Add hook for formatting Kubernetes Event messages#910
Conversation
4cf984c to
ed9f488
Compare
Whatever we decide we need to be consistent in future. If we add GCP specific code we need to accept code for other clouds, including from third parties who use platforms that we can't test ourselves. |
dc81d08 to
8e4f471
Compare
There was a problem hiding this comment.
I enjoy this feature ❤️ I like that the format_event_hook was easy to configure for basic formatting. It took me a while to understand what was going on with the default formatting, but I think there will alway be room for improvements there.
In general, my main comment is to complete the test suite to regenerate how the sample-events were created through the message.py, since I think that represents the bulk of the work in this PR. The default formatting may undergo further development, but like you say I think we want to add in some basic regression testing and update that if needed in future.
In answer to your questions:
Is Kubespawner making too many assumptions if we bake-in the expectation of Bootstrap?
We know Bootstrap ships with JupyterHub, so I think this is a safe assumption for now. I don't think we need to worry about this for BinderHub?
Could we consider adding a start-time timestamp so that times can simply be given as "minutes since spawn" rather than UTC times?
I think this is a nice-to-have. Most users hopefully shouldn't have to dwell on the spawn progress screen, but if they do, then they will likely screenshot their spawn failure to send to an admin. Keeping the timestamps consistent with server side logs with raw k8s events should be useful for sysadmins for troubleshooting.
Should I rework the built-in formatter to generate HTML at every stage — would it be useful to have e.g. image names/tags, and node names in button-tags?
At this stage, I would prefer not to have the default formatter be too flashy.
Is there motivation to move the default message format into its own configurable, rather than requiring users to create their own hook?
Yes, out of all of these questions I think this would be one to focus on. Most people will probably want to configure an extension to the default formatter.
I am okay with that – I don't think we need to assume full responsibility for testing code on platforms we don't have access to, but we should ensure contributors who would like this functionality to include full test suites for that. I think the scope of changes in this PR are pretty cosmetic, so there doesn't seem to be huge scope for someone to introduce anything too crazy on a third party platform. There is a small question about how to structure this as the corpus of messages to reformat scales, but I think we can cross that bridge when we get to it? |
|
@yuvipanda I've reworked the PR to leave the functional hook that completely bypasses event formatting and remove the default formatter callable. I think the test failure is just a flaky test? I've then added a rule system with no defaults. This was a two-fold decision:
As such, I intend to put the specific implementation of these rules in the z2hj chart instead. I'm happy to revert that decision, but I am not off-the-top-of-my-head aware of a nice way to do it other than defining the default value as a dict and implementing the Footnotes
|
| await spawner.stop() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("rules_as_dict", [True, False]) |
|
I haven't looked at the implementation yet, but thank you for reworking it! I think the rules system should be here, not in z2jh. You can make it extensible by having a default list in here, and then just allowing |
This reverts commit 510c01c.
This makes it even easier to functionally override formatted messages, and brings us in-line with existing hooks
Co-authored-by: Jenny Wong <jnywong.pro@gmail.com>
for more information, see https://pre-commit.ci
TL;DR
Note
No LLMs were used in the authoring of this PR.
2i2c is currently working on a user-story to improve the kubespawner progress messages, as part of an initiative to improve the spawn-progress page.
This PR does several things:
decorate_progress_messagethat overrides the pretty-printing of event messages.kubespawner.eventsmodule for richer built-in formatting of log messages.kubespawner.events.RuleEventFormatterand other types for defining event formatting rules.See the before and after:
Before

After

Goal
The goal is modest: to improve the human readability of spawn messages, and to allow further customisation.
Example Decoration Hook
Basic hook
Use the rules to define custom renderers
Design Details
UI
%Y-%m-%DTHH:MM:SSZto keep fixed widthConstraints
pyproject.toml, meaning nomatch,:=, orremoveprefix.Questions