-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(kubernetes_logs source): Handle OK response from api_watcher with embedded desync elegantly #6053
Conversation
Cc @tustvold in case you want to review. |
@eeyun does this close an issue? |
fb89e62
to
9126be5
Compare
9126be5
to
5cae347
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good, but we need more tests cases at API Watcher to cover the rest of the input kinds, as discussed.
- non-desync status error
- invalid json
- unexpected resource kind (i.e. Pod expected but Namespace was sent)
Also, ideally:
- network error at the stream level
- network error at the invocation level
let cases: Vec<( | ||
Box<dyn FnOnce(When, Then)>, | ||
Vec<Box<dyn FnOnce(Result<WatchResponse<Pod>, watcher::stream::Error<stream::Error>>)>>, | ||
)> = vec![ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to be able to trigger and test more of the possible stream item variants.
What's already covered:
Ok(WatchResponse::Ok(WatchEvent::Added { ... }))
Err(watcher::stream::Error::Desync { ... }))
- should assert the underlying value (the...
should be a concrete value matching the test input to assert the data is porperly passed)Err(watcher::stream::Error::Other { ... }))
- same as aboveOk(WatchResponse::Ok(WatchEvent::ErrorStatus(Status { ... })))
(covered by the non-desync status error case)
What we probably should cover as well:
Ok(WatchResponse::Ok(WatchEvent::ErrorOther(RawExtension { ... })))
- pass the response event with some non-standardtype
(i.e.extension_test
)Ok(WatchResponse::Other(Ok(Some(serde_json::Value { ... })))
- pass a valid JSON that is not a validWatchResponse
- sth like{"a":"b"}
should doOk(WatchResponse::Other(Ok(None))
- pass nothing?Ok(WatchResponse::Other(Err(...))
- I presume this should be the value when passing an invalid JSON? It would be great to add a test that illustrates how to trigger this error
What we don't care about:
- other "heppy"
WatchEvent
variants:WatchEvent:: Deleted
,WatchEvent::Modified
,WatchEvent:: Bookmark
- although, for completeness, we could add them too.
With this, we'll have pretty good test coverage.
2ab7ba3
to
1415ba8
Compare
This is ready to be tested! @tustvold (or anyone interested in testing this case) if you're curious to test I've created a docker image from this PR that can be pulled down like so:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
b93f7e3
to
61d2444
Compare
Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
Signed-off-by: MOZGIII <mike-n@narod.ru>
Signed-off-by: MOZGIII <mike-n@narod.ru>
Signed-off-by: MOZGIII <mike-n@narod.ru>
Signed-off-by: MOZGIII <mike-n@narod.ru>
Signed-off-by: MOZGIII <mike-n@narod.ru>
…cted resource type Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
Signed-off-by: Ian Henry <ianjhenry00@gmail.com>
61d2444
to
06d2061
Compare
Hello, Thanks a lot for the correction. But anyone can tell me when the new release including this is planed please ? |
Handles the case where a watcher desync response returns embedded inside a 200 OK.
We've refactored our API here to remove the
k8s_openapi::WatchResponse
type as in our investigation it became clear that the extra abstraction was unnecessary for us. In removing that type we've provider our own internalResponse
type which allows us to simplify the redirection here.Closes #5877
Closes #5846
Signed-off-by: Ian Henry ianjhenry00@gmail.com