Use background context rather than cancelled context #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug
Turing's dependency on Kubernetes API was updated in #183 and most Kubernetes APIs now require context to be passed which caused a regression. When ctx.Done() is called, the context was cancelled and ctx.Err() returns a non-nil error. Thus, when passed to ListPods API, when the ctx.Err() value is first checked, the call exits given a non-nil error and pods that satisfy the provided labels are never returned, causing termination logs to NOT be propagated to the user.
Fix
The fix uses a new empty context via context.Background(), which will not be cancelled and that allows Kubernetes Go Client ListPods API to retrieve the correct pods based on provided labels. Then, the container error logs from Terminated state can be propagated as event logs to the user.
Enhancements
In addition, this PR standardizes how context is being used for the following workflows:
metav1.DeleteOptions{}
is optional