kube-rs / kube

Rust Kubernetes client and controller runtime
https://kube.rs
Apache License 2.0
2.91k stars 304 forks source link

Stream produced by "watch_object" no longer emits when an object isn't in the initial list #1576

Closed markdingram closed 2 weeks ago

markdingram commented 2 weeks ago

Current and expected behavior

A test began failing after a Kube-RS upgrade from 0.91 to 0.93 - rough sketch:

let _ = api.delete(&obj).await;

// never returns now as there is no object at the point of awaiting
await_condition(self.api.clone(), obj.name_unchecked(), conditions::is_deleted).await;

Looking at the earlier implementation an Ok(None) event would be passed up to check when no objects were returned. - https://github.com/kube-rs/kube/blob/5dbae3a18c14a225d2d993b9effd16147fef420e/kube-runtime/src/watcher.rs#L815

After 0.92 the "InitDone" always leads to None - https://github.com/kube-rs/kube/blob/0f6cb6f0ac695444f6789f98fa07073f4980a127/kube-runtime/src/watcher.rs#L830

Possible solution

Use "scan" to track whether or not the object was seen for each round of Init events. If the object was seen InitDone will return None otherwise it should pass Ok(None).

Additional context

No response

Environment

N/A

Configuration and features

No response

Affected crates

kube-runtime

Would you like to work on fixing this bug?

yes