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

Return error from watcher when kinds do not support watch #1101

Merged
merged 3 commits into from Dec 9, 2022
Merged
Changes from 2 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
14 changes: 11 additions & 3 deletions kube-runtime/src/watcher.rs
Expand Up @@ -25,6 +25,8 @@ pub enum Error {
WatchError(#[source] kube_client::error::ErrorResponse),
#[error("watch stream failed: {0}")]
WatchFailed(#[source] kube_client::Error),
#[error("No metadata.resourceVersion in watch result (does kind support watch?)")]
clux marked this conversation as resolved.
Show resolved Hide resolved
NoResourceVersion,
#[error("too many objects matched search criteria")]
TooManyObjects,
}
Expand Down Expand Up @@ -139,9 +141,15 @@ async fn step_trampolined<K: Resource + Clone + DeserializeOwned + Debug + Send
) -> (Option<Result<Event<K>>>, State<K>) {
match state {
State::Empty => match api.list(list_params).await {
Ok(list) => (Some(Ok(Event::Restarted(list.items))), State::InitListed {
resource_version: list.metadata.resource_version.unwrap(),
}),
Ok(list) => {
if let Some(resource_version) = list.metadata.resource_version {
(Some(Ok(Event::Restarted(list.items))), State::InitListed {
resource_version,
})
} else {
(Some(Err(Error::NoResourceVersion)), State::Empty)
}
}
Err(err) => (Some(Err(err).map_err(Error::InitialListFailed)), State::Empty),
},
State::InitListed { resource_version } => match api.watch(list_params, &resource_version).await {
Expand Down