Skip to content
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

Add support for LogParams::since_time #1342

Merged
merged 4 commits into from
Nov 20, 2023
Merged

Add support for LogParams::since_time #1342

merged 4 commits into from
Nov 20, 2023

Conversation

clux
Copy link
Member

@clux clux commented Nov 12, 2023

Adds a missing sinceTime parameter equivalent from PodLogOptions for #1339

Think this is missing because of kubernetes/kubernetes#108498

Tested using

RUST_LOG=debug cargo run --example log_stream -- coredns-77ccd57875-k46v4 --since-time="2023-11-12T12:23:53Z"

on k3d.

Time Type

Am currently using k8s_openapi::apimachinery::pkg::apis::meta::v1::Time for the time wrapper but that's only a newtype over DateTime<Utc> (via chrono).

This is a little awkward because the newtype implements serialize but we need it as a raw value for a query param (and passing it through serde_json::to_string did not feel useful), so in the end I am doing the same thing k8s-openapi is doing in its own serialize and calling chrono's to_rfc... fn.

On a positive point, this does mean the LogParams type matches the type found on ObjectMeta (for creation_timestamp and deletion_timestamp), but this isn't actually very useful for the end user (as can be seen in the example with basically needing both types and converting between them).

It could be simpler to expose DateTime<Utc> as the api time, but that means the type is locked down. Maybe we leave it and maybe push a PR to k8s-openapi for convenience impls on Time instead later to make it slightly more ergonomic?

Also happy to remove the Time wrapper from LogParams and just put DateTime<Utc> in there. Not sure which is best.

Tested using

```sh
RUST_LOG=debug cargo run --example log_stream -- coredns-77ccd57875-k46v4 --since-time="2023-11-12T12:23:53Z"
```

on k3d.

Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
@clux clux added the changelog-add changelog added category for prs label Nov 12, 2023
Copy link

codecov bot commented Nov 12, 2023

Codecov Report

Merging #1342 (b4775c5) into main (0abd2bd) will decrease coverage by 0.0%.
The diff coverage is 100.0%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1342     +/-   ##
=======================================
- Coverage   72.1%   72.1%   -0.0%     
=======================================
  Files         75      75             
  Lines       6377    6387     +10     
=======================================
+ Hits        4597    4604      +7     
- Misses      1780    1783      +3     
Files Coverage Δ
kube-core/src/subresource.rs 78.5% <100.0%> (+1.8%) ⬆️

... and 2 files with indirect coverage changes

@clux clux marked this pull request as ready for review November 12, 2023 13:05
@clux clux requested review from Dav1dde and nightkr November 12, 2023 13:05
@clux
Copy link
Member Author

clux commented Nov 12, 2023

Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: clux <sszynrae@gmail.com>
@clux
Copy link
Member Author

clux commented Nov 17, 2023

felt a bit uneasy about the Time wrapping which (from a user POV) is completely pointless (since they need chrono to create the timestamps anyway). have removed the Time wrapping.

@clux clux added this to the 0.88.0 milestone Nov 17, 2023
@Dav1dde
Copy link
Member

Dav1dde commented Nov 17, 2023

felt a bit uneasy about the Time wrapping which (from a user POV) is completely pointless (since they need chrono to create the timestamps anyway). have removed the Time wrapping.

Surprised this works, chrono is an optional dependency here:

https://github.com/kube-rs/kube/blob/main/kube-core/Cargo.toml#L35

Am I missing something?

@clux
Copy link
Member Author

clux commented Nov 17, 2023

i'm kind of cheating and piggybacking on k8s-openapi::chrono atm in kube_core

@clux
Copy link
Member Author

clux commented Nov 17, 2023

k8s-openapi always depends on it in a minimal fashion so i feel that is ok...

but we could also make it mandatory on our end with those features to make it explicit

@clux clux merged commit 89adbf2 into main Nov 20, 2023
18 checks passed
@clux clux deleted the log-since-time branch November 20, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants