-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Requests sent to terminating pods #15211
Comments
Hi @skonto. I posted testing code here The app folder has the knative service, the tester folder sends simultaneous requests, and the knative operator config is here To replicate the issue. Send a job with 200 requests, watch for the pods to start to terminate then send job-2 and observe 502 bad gateway errors in the response. It does not happen every time. I have also noticed it does not happen if the pod runs for a short time (10 seconds, 30 seconds). It occurs on long requests like 5 minutes. The below error is from the queue proxy when this happens. We see the same behavior on Google Cloud GKE and on an on-premise Kubernetes Cluster.
Below are similar issues I have found: Thanks for your help! Please let me know anything else you need. |
Here is another related issue. #9355 |
@skonto - checking in. |
Hi @dspeck1 would you mind checking if this is related to the graceful shutdown in Python #12865 (comment)? |
Thanks! I was away on vacation and am back now. Testing python container with dumb-init for SIGTERM handling and will let you know. |
We are still receiving 502 bad gateway messages with dumb-init. |
I think that's unrelated... The Our team has been having the same issue as @dspeck1 for a long time. We tried so many things including using nginx unit (which seemed to reduce the frequency of the errors, for some reason), but it still occurs. We get the error sometimes when services are scaled to zero and we send a few requests. Edit: Actually, it seems like more similar issues have been popping up, and one of them mentions a simple potential fix (don't know if it would work for our cases), so I'll try it, and maybe you could as well: #15352 (comment) Edit 2: setting |
@dspeck1 hi, could you verify that no activator pods are being scaled up and down, or failed, preempted, during your test (there are hpa resources installed by default by the operator), so requests might be affected by activator killing the request due to termination grace period (you set TBC=-1 so activator is always on the path). The setting there needs to be increased if |
@dspeck1 gentle ping. |
@skonto I set |
Hi @ashrafguitoni I am off. I did a quick check, I will take a look again when back. Assuming you face the same issue as @dspeck1. Could you verify that you don't suffer from no proper signal handling from the app (user container) as I describe here? If you don't do a graceful shutdown of your server in python or any other language, handling SIGTERM, draining the connections, and then you just run the app as PID=1, you will get an EOF (502 bad gateway) error as QP will not wait. @dspeck1's code seems to handle signals (due to
When I run that Python app on K8s with SLEEP_TIME=90 and kill the pod fast enough I see (empty error maps to 502):
This is not the case if I use the example in here. In order to fix the code you just need to add a graceful timeout (note that setting to zero/infinite as for --timeout will not work), default is only 30s:
Note here that the above is not proper, docker complains
Now requests are handled as expected.
In any case you have a different problem could you provide logs from the QP, activator side, kourier, envoy gateway etc. |
What version of Knative?
1.14.0
Expected Behavior
Being able to send groups of 200 requests and knative service those requests.
The requests not to be scheduled to terminating pods.
Actual Behavior
Sending in groups of 200 requests to knative. The processing takes 5 minutes on knative to run. All the pods will finish with 200 return code. When a second groups of 200 requests is sent in and pods are terminating many of the requests will return 502 bad gateway errors. The requests are getting scheduled to pods that are terminating.
Steps to Reproduce the Problem
Watch for pods to terminate and send in requests. kourier is the ingress and using the knative autoscaler.
The text was updated successfully, but these errors were encountered: