Skip to content

Commit

Permalink
revert informer resource version parsing
Browse files Browse the repository at this point in the history
was an attempt to get around #219 but didn't work
  • Loading branch information
clux committed Apr 7, 2020
1 parent f7e29a2 commit e3bea99
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions kube/src/runtime/informer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ where

// Clone Arcs for stream handling
let version = self.version.clone();
let origin = self.version.lock().await.clone();
info!("poll start at {}", origin);
let needs_resync = self.needs_resync.clone();

// Start watching from our previous watch point
Expand All @@ -126,23 +124,12 @@ where
let needs_resync = needs_resync.clone();
let version = version.clone();
async move {
let current = version.lock().await.clone();
// Check if we need to update our version based on the incoming events
match &event {
Ok(WatchEvent::Added(o)) | Ok(WatchEvent::Modified(o)) | Ok(WatchEvent::Deleted(o)) => {
// always store the last seen resourceVersion
if let Some(nv) = Meta::resource_ver(o) {
use std::str::FromStr;
let u = if let (Ok(nvu), Ok(cu)) = (u32::from_str(&nv), u32::from_str(&current)) {
// actually parse int because k8s does not keep its contract
// https://github.com/kubernetes-client/python/issues/819
std::cmp::max(nvu, cu).to_string()
} else {
// recommended solution - treat resourceVersion as opaque string
nv.clone()
};
info!("updating informer version to: {} (got {})", u, nv);
*version.lock().await = u;
*version.lock().await = nv.clone();
}
}
Ok(WatchEvent::Error(e)) => {
Expand Down

0 comments on commit e3bea99

Please sign in to comment.