control-service: logs endpoint doesn't hang #2370
Merged
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.
Why
Closes: #2041
if a job is running and we make a request for its logs the control service hangs and after a very long time returns an error.
What
The error was happening because we were reading the logs for kubernetes using an inputStream function.
Kuberenetes was streaming the logs to the control plane and doesn't close the input stream till the jobs is completed.
Prevoiusly we were using
Within this function Kubernetes calls
Instead of calling
PodLogs.streamNamespacedPodLog
instead I callCoreV1Api.readNamespacedPodLogCall
directly and I set follow=false.Now the function returns immediately.
How has this been tested
Integration test.
I have created a job that runs for 20 minutes. I query for its logs and make sure that it returns within 5 seconds.
Signed-off-by: murphp15 [email protected]