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

feat(kubernetes_logs source): Use resource_version of 0 to use cache #9974

Merged
merged 3 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/kubernetes/reflector.rs
Expand Up @@ -359,15 +359,15 @@ mod tests {
drop(reflector);
}

// Test the properties of the normal execution flow.
// Test the properties of the normal execution flow.
#[tokio::test]
async fn flow_test() {
trace_init();

let invocations = vec![
(
vec![],
None,
Some("0".to_owned()),
ExpInvRes::Stream(vec![
ExpStmRes::Item(WatchEvent::Added(make_pod("uid0", "10"))),
ExpStmRes::Item(WatchEvent::Added(make_pod("uid1", "15"))),
Expand Down Expand Up @@ -419,7 +419,7 @@ mod tests {
let invocations = vec![
(
vec![],
None,
Some("0".to_owned()),
ExpInvRes::Stream(vec![
ExpStmRes::Item(WatchEvent::Added(make_pod("uid0", "10"))),
ExpStmRes::Item(WatchEvent::Added(make_pod("uid1", "15"))),
Expand Down Expand Up @@ -460,7 +460,7 @@ mod tests {
let invocations = vec![
(
vec![],
None,
Some("0".to_owned()),
ExpInvRes::Stream(vec![
ExpStmRes::Item(WatchEvent::Added(make_pod("uid0", "10"))),
ExpStmRes::Item(WatchEvent::Added(make_pod("uid1", "15"))),
Expand Down Expand Up @@ -499,7 +499,7 @@ mod tests {
let invocations = vec![
(
vec![],
None,
Some("0".to_owned()),
ExpInvRes::Stream(vec![
ExpStmRes::Item(WatchEvent::Added(make_pod("uid0", "10"))),
ExpStmRes::Item(WatchEvent::Added(make_pod("uid1", "15"))),
Expand Down Expand Up @@ -543,7 +543,7 @@ mod tests {
let invocations = vec![
(
vec![],
None,
Some("0".to_owned()),
ExpInvRes::Stream(vec![
ExpStmRes::Item(WatchEvent::Added(make_pod("uid0", "10"))),
ExpStmRes::Item(WatchEvent::Added(make_pod("uid1", "15"))),
Expand Down Expand Up @@ -584,7 +584,7 @@ mod tests {
let invocations = vec![
(
vec![],
None,
Some("0".to_owned()),
ExpInvRes::Stream(vec![
ExpStmRes::Item(WatchEvent::Added(make_pod("uid0", "10"))),
ExpStmRes::Item(WatchEvent::Added(make_pod("uid1", "15"))),
Expand Down Expand Up @@ -681,7 +681,7 @@ mod tests {
field_selector: Some("fields".to_owned()),
label_selector: Some("labels".to_owned()),
pretty: None,
resource_version: None,
resource_version: Some("0".to_owned()),
timeout_seconds: Some(290),
}
);
Expand Down Expand Up @@ -1083,8 +1083,13 @@ mod tests {

// Prepare reflector.
let pause_between_requests = Duration::from_secs(60 * 60); // 1 hour
let mut reflector =
Reflector::new(watcher, state_writer, None, None, pause_between_requests);
let mut reflector = Reflector::new(
watcher,
state_writer,
None,
Some("0".to_owned()),
pause_between_requests,
);

// Run test logic.
let logic = tokio::spawn(async move {
Expand Down
4 changes: 2 additions & 2 deletions src/kubernetes/resource_version.rs
Expand Up @@ -9,8 +9,8 @@ pub struct State(Option<String>);

impl State {
/// Create a new resource version [`State`].
pub const fn new() -> Self {
Self(None)
pub fn new() -> Self {
Self(Some("0".to_owned()))
}

/// Update the resource version from a candidate obtained earlier.
Expand Down