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

fix(kubernetes_logs source): Handle OK response from api_watcher with embedded desync elegantly #6053

Merged
merged 13 commits into from
Feb 10, 2021

Conversation

eeyun
Copy link
Contributor

@eeyun eeyun commented Jan 14, 2021

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 internal Response type which allows us to simplify the redirection here.

Closes #5877
Closes #5846
Signed-off-by: Ian Henry ianjhenry00@gmail.com

@eeyun eeyun added ci-condition: k8s e2e all targets Run Kubernetes E2E test suite for all targets (instead of just the essential subset) ci-condition: k8s e2e tests enable Run Kubernetes E2E test suite for this PR labels Jan 14, 2021
@binarylogic
Copy link
Contributor

Cc @tustvold in case you want to review.

@binarylogic
Copy link
Contributor

@eeyun does this close an issue?

@eeyun eeyun changed the title Handle OK response from api_watcher with embedded desync elegantly fix(kubernetes_logs): Handle OK response from api_watcher with embedded desync elegantly Jan 18, 2021
@eeyun eeyun changed the title fix(kubernetes_logs): Handle OK response from api_watcher with embedded desync elegantly fix(kubernetes_logs source): Handle OK response from api_watcher with embedded desync elegantly Jan 18, 2021
@eeyun eeyun force-pushed the eeyun/error_misfire branch from fb89e62 to 9126be5 Compare January 18, 2021 18:44
@eeyun eeyun marked this pull request as ready for review January 18, 2021 18:46
@eeyun eeyun requested a review from JeanMertz as a code owner January 18, 2021 18:46
@eeyun eeyun requested a review from a team January 18, 2021 18:46
@eeyun eeyun added this to the 2021-01-04 Xenomass Well milestone Jan 18, 2021
@eeyun eeyun self-assigned this Jan 18, 2021
@eeyun eeyun force-pushed the eeyun/error_misfire branch from 9126be5 to 5cae347 Compare January 18, 2021 21:34
Copy link
Contributor

@MOZGIII MOZGIII left a 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

@MOZGIII MOZGIII self-requested a review January 20, 2021 18:40
let cases: Vec<(
Box<dyn FnOnce(When, Then)>,
Vec<Box<dyn FnOnce(Result<WatchResponse<Pod>, watcher::stream::Error<stream::Error>>)>>,
)> = vec![
Copy link
Contributor

@MOZGIII MOZGIII Jan 23, 2021

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 above
  • Ok(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-standard type (i.e. extension_test)
  • Ok(WatchResponse::Other(Ok(Some(serde_json::Value { ... }))) - pass a valid JSON that is not a valid WatchResponse - sth like {"a":"b"} should do
  • Ok(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.

@eeyun eeyun requested review from a team January 26, 2021 22:56
@eeyun eeyun force-pushed the eeyun/error_misfire branch 3 times, most recently from 2ab7ba3 to 1415ba8 Compare January 27, 2021 16:24
@eeyun
Copy link
Contributor Author

eeyun commented Jan 29, 2021

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:

docker pull eeyun/vector-k8s-test:error_misfire

Copy link
Contributor

@MOZGIII MOZGIII left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

Cargo.toml Outdated Show resolved Hide resolved
@eeyun eeyun force-pushed the eeyun/error_misfire branch from b93f7e3 to 61d2444 Compare February 9, 2021 19:08
eeyun and others added 13 commits February 10, 2021 10:15
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>
@eeyun eeyun force-pushed the eeyun/error_misfire branch from 61d2444 to 06d2061 Compare February 10, 2021 15:15
@eeyun eeyun merged commit 066c22e into master Feb 10, 2021
@eeyun eeyun deleted the eeyun/error_misfire branch February 10, 2021 17:24
@uthng
Copy link

uthng commented Feb 15, 2021

Hello,

Thanks a lot for the correction. But anyone can tell me when the new release including this is planed please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-condition: k8s e2e all targets Run Kubernetes E2E test suite for all targets (instead of just the essential subset) ci-condition: k8s e2e tests enable Run Kubernetes E2E test suite for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubernetes Reflector Silently Drops Errors kubernetes_logs source doesn't detect new pods
5 participants