Skip to content

Initial Revisions (at least) with crash-looping pods take a long time to terminate/clean up Pods #12691

Closed

Description

@evankanderson

What version of Knative?

v1.0 at least

Expected Behavior

When creating a Revision with a pod which exits immediately, the Revision should (fairly quickly) report that Ready is False and terminate the Pods.

Actual Behavior

The pods stick around in CrashLoopBackOff for many restarts, and the Revision remains in "unknown" status for many minutes and eventually times out.

Steps to Reproduce the Problem

In one shell:

kn service create crasher --image nicolaka/netshoot  # or even a "bash" image

Watch this stall out, check on the pods with kubectl get po, etc

In a second shell:

kn service update crasher --image projects.registry.vmware.com/tanzu_serverless/hello-yeti

The first kn service create will complete, and the service will be ready to serve!

BUT

The first Revision will still be in unknown status, and the Pod will still be present in CrashLoopBackOff, even many minutes after the failure.

After approximately 10 minutes, the Pod will finally be cleaned up, but the reported status.desiredScale for the KPA resource is still -1 at the end of that time.

Activity

  1. added
    kind/bug
    on Mar 3, 2022
  2. evankanderson commented on Mar 3, 2022

    @evankanderson
    MemberAuthor

    (It seems to take about 10 minutes to fill in the spec.Reachability field, which I suspect is what is causing the scale back down to zero)

  3. evankanderson commented on Mar 3, 2022

    @evankanderson
    MemberAuthor

    /good-first-issue

  4. knative-prow-robot commented on Mar 3, 2022

    @knative-prow-robot
    Contributor

    @evankanderson:
    This request has been marked as suitable for new contributors.

    Please ensure the request meets the requirements listed here.

    If this request no longer meets these requirements, the label can be removed
    by commenting with the /remove-good-first-issue command.

    Details

    In response to this:

    /good-first-issue

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  5. added
    good first issue
    help wanted
    on Mar 3, 2022
  6. psschwei commented on Mar 3, 2022

    @psschwei
    Member

    Poked around at this a bit, using Serving 1.2. Here's what I saw:

    It looks like the initial revision gets set to Ready: False pretty quickly (almost simultaneous with the second revision getting ready).

    The long time to remove the pod comes from the default ProgressDeadline, which is set to 10m by default. Once that is hit, QP gets a TERM signal and goes through it's usual shutdown process.

    I think KPA want stayed at -1 until I curled the working service (I don't remember if I curled it or not right when the second revision came up).

    (also tried Serving 1.0 and also saw Ready: False pretty quick)

    Assuming I'm understanding what's going on here correctly (insert usual caveat about assuming 😄 ), would this be a fix to a special case where revision 1 is replaced by revision 2 before rev1 becomes ready?

  7. evankanderson commented on Mar 4, 2022

    @evankanderson
    MemberAuthor

    I haven't tested, but I think this also happens when you deploy a crashing version after a successful version is installed.

    I suspect that there is a special case here (since initialization is a bit of a special case already).

  8. changed the title [-]Initial Revisions (at least) with crash-looping pods never terminate/clean up Pods[/-] [+]Initial Revisions (at least) with crash-looping pods take a long time to terminate/clean up Pods[/+] on Mar 11, 2022
  9. muhammedanaskhan commented on Mar 20, 2022

    @muhammedanaskhan

    hey @evankanderson I am a beginner in devops and learned linux, docker and kubernetes beginners course on Go and Python basics. Am I eligible with this much knowledge to be able to contribute to the tools. If not then could you suggest what all things I should learn more in order to get started.

  10. evankanderson commented on Mar 20, 2022

    @evankanderson
    MemberAuthor

    Hi @muhammedanaskhan,

    I think this could be a good first issue for you.

    I'd start out by figuring out how to get a dev build of Knative serving running in your environment. (Just built from main or a branch with no changes.)

    After that, I'd try to reproduce the issue on your cluster without making any code changes. Once you can do that, I'd start making the changes suggested earlier in this thread (maybe start by initializing the serverlessservice scale to 1 rather than -1). Once you think you have the problem solved, I'd push the change to a branch on your fork and send a PR which references this issue.

  11. evankanderson commented on Mar 20, 2022

    @evankanderson
    MemberAuthor

    If you can figure out how, a unit test would also be a good addition to your PR. If you can't figure out the best test scenario, we can certainly help with that - - mention it in your PR.

  12. evankanderson commented on Apr 14, 2022

    @evankanderson
    MemberAuthor

    @muhammedanaskhan -- if you're still interested, I think I saw an interesting hint in #9531 (comment); I suspect that we should be connecting how long a Configuration takes to give up on a Revision with the ProgressDeadlineSeconds of the Deployment underlying the Revision.

  13. psschwei commented on Apr 14, 2022

    @psschwei
    Member

    A couple of extra details, in case they help.

    Here's the KPA status changes over the course of the steps that Evan described:

    $ k get kpa -w
    NAME            DESIREDSCALE   ACTUALSCALE   READY     REASON
    crasher-00001   -1             0             Unknown   Queued
    crasher-00002                                          
    crasher-00002   -1             0             Unknown   Queued
    crasher-00002   -1             0             Unknown   Queued
    crasher-00002   -1             1             Unknown   NotReady
    crasher-00002   -1             1             Unknown   NotReady
    crasher-00002   -1             1             True      
    crasher-00002   -1             1             True      
    crasher-00002   -1             1             True      
    crasher-00001   -1             0             Unknown   Queued
    crasher-00001   -1             0             Unknown   Queued
    crasher-00002   1              1             True      
    

    Final state:

    $ k get kpa 
    NAME            DESIREDSCALE   ACTUALSCALE   READY     REASON
    crasher-00001   -1             0             Unknown   Queued
    crasher-00002   1              1             True      
    

    Also, desired scale remains at -1 for the first KPA, even after the progress-deadline period:

    $ k get kpa crasher-00001 
    NAME            DESIREDSCALE   ACTUALSCALE   READY   REASON
    crasher-00001   -1             0             False   NoTraffic
    
    $ k get revision crasher-00001
    NAME            CONFIG NAME   K8S SERVICE NAME   GENERATION   READY   REASON                     ACTUAL REPLICAS   DESIRED REPLICAS
    crasher-00001   crasher                          1            False   ProgressDeadlineExceeded   0                 
    
  14. github-actions commented on Jul 14, 2022

    @github-actions

    This issue is stale because it has been open for 90 days with no
    activity. It will automatically close after 30 more days of
    inactivity. Reopen the issue with /reopen. Mark the issue as
    fresh by adding the comment /remove-lifecycle stale.

  15. 35 remaining items

  16. msiyaj commented on Aug 21, 2023

    @msiyaj

    /assign

  17. lizzzcai commented on Sep 20, 2023

    @lizzzcai

    Hi, we noticed the KNative service is stuck when there is a Init:CrashLoopBackOff in init container, not sure if it fits the discussion here.

    knative version: 1.9.3

    ❯ k get po -n kserve-test-twz
    NAME                                                              READY   STATUS                  RESTARTS         AGE
    sklearn-iris-predictor-default-00006-deployment-6d4b56fddbxtltw   0/3     Init:CrashLoopBackOff   34 (3m40s ago)   3h44m
    sklearn-iris-predictor-default-00006-deployment-76967cc4cbrq46s   0/3     Init:CrashLoopBackOff   33 (51s ago)     3h33m
    sklearn-iris-predictor-default-00007-deployment-5464495fb6bt85k   0/3     Init:CrashLoopBackOff   33 (60s ago)     3h33m
    sklearn-iris-predictor-default-00007-deployment-749b69b9-4qkpg    0/3     Init:1/2                33 (7m2s ago)    3h33m
    
    ❯ k get revision -n kserve-test-twz
    NAME                                   CONFIG NAME                      K8S SERVICE NAME   GENERATION   READY   REASON            ACTUAL REPLICAS   DESIRED REPLICAS
    sklearn-iris-predictor-default-00006   sklearn-iris-predictor-default                      6            False   PodInitializing   0                 1
    sklearn-iris-predictor-default-00007   sklearn-iris-predictor-default                      7            False   PodInitializing   0                 1

    I would like to check if there is any solution for it as it consumes resources.

  18. delphamk commented on Nov 9, 2023

    @delphamk

    /assign

  19. dprotaso commented on Nov 21, 2023

    @dprotaso
    Member

    /unassign @msiyaj

  20. modified the milestones: v1.12.0, v1.13.0 on Nov 21, 2023
  21. dprotaso commented on Nov 22, 2023

    @dprotaso
    Member

    hey @andrew-delph so I retested the repro steps mentioned in the first comment - and I believe this was fixed in the latest release via the PR #14309

    It's resolved since we propagate reachability appropriately and don't do weird things like reading the Active conditions. Thus older revisions that aren't pointed to by a route will scale down correctly now.

    I'm going to close this one out - but if you're testing a similar scenario that you're trying to address can you create a new issue.

    Also a related issue that someone is working on is here - #13677

    That one is about requests coming in and timing out doesn't trigger scale down as quickly as they could

  22. delphamk commented on Nov 22, 2023

    @delphamk

    @dprotaso Thanks for the comments and feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good first issuehelp wantedkind/bugtriage/accepted

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions