Skip to content

Rework PodAutoscaler conditions to better fit K8s readiness model #8540

Closed

Description

@markusthoemmes

Problem

Currently, the PodAutoscaler's readiness is determined by the Active condition. That means, that a PodAutoscaler of a revision that is scaled to 0 will be NotReady.

That creates a slew of problems to the system. Most importantly: This status propagates to the Revision, creating a race condition between PodAutoscaler and Revision readiness. If a revision fails to observe the PodAutoscaler while it's still being scaled up, it will never become ready as has been seen in #8539. This has also been pointed out in #5076.

Proposal

We should make PA's readiness not rely on its Active condition at all. Instead, we could piggyback on the work that has been done to determine HasBeenActive, which is a sticky state. I think we want the PA to remain ready after it has seen initialScale and/or minScale and only change that status explicitly if we need to.

As such, I'd propose this order of operations:

  1. Propagate InitiallyActive from an annotation to a condition.
  2. Remove Active from the set of conditions determining readiness.
  3. Fight off all the dragons that I forgot in this naive proposal and make the system work again 😅.

Activity

  1. added
    area/API
    kind/bug
    kind/cleanup
    on Jul 2, 2020
  2. markusthoemmes commented on Jul 7, 2020

    @markusthoemmes
    ContributorAuthor

    In terms of migration, I think we want to keep the Active condition, but just drop it from the set of terminal conditions eventually and lower the severity to Info.

  3. mattmoor commented on Jul 7, 2020

    @mattmoor
    Contributor

    I remember arguing with @vagababov about conditions at some point, but it may have been the split of logic between SKS and KPA.

    Either way, I'm game to at least try this. I think the main thing to think about is whether the change needs to be stages across a release, and if so what our logistics should be. I'd also like to land this early in a cycle in case we don't find all of 3. in presubmit or review.

    /assign @dprotaso @vagababov @taragu

    Would be good to get your eyeballs on this too.

  4. dprotaso commented on Jul 7, 2020

    @dprotaso
    Member

    Does anything key off of the Active condition besides revisions?

  5. dprotaso commented on Jul 7, 2020

    @dprotaso
    Member

    We should probably list out the scenarios/interaction between the PodAutoscaler and the Revision and their conditions

    As an example: I have a revision with minScale set, it's currently scaled to 0. Based on the changes above the Revision is 'Ready'. If I start scaling up do any conditions change?

    Does the activator look at conditions when triggering the scale up?

  6. markusthoemmes commented on Jul 7, 2020

    @markusthoemmes
    ContributorAuthor

    The activator doesn't care at all in this case.

    I think the invariant we want to have is that the revision only becomes ready if the PA has been ready once. Which takes into account minscale and whatnot.

    The Revision should not become unready, if the PA becomes Inactive, where Inactive means that there is no more traffic to it. We can still surface the active condition in the revision though, it's already an informative condition there. The PA should only become NotReady if there's really an issue there (i.e. the autoscaler breaks or whatnot). We don't have such a condition coded in at all currently though, which makes InitiallyReady (or HasBeenReady as it was actually named) a one way road currently.

  7. dprotaso commented on Jul 7, 2020

    @dprotaso
    Member

    So effectively the 'Ready' on revision means the machinery is in place to receive the request. Would we not want that for initialScale = 0 situations?

    The activator doesn't care at all in this case.

    This was me asking whether activator waits for minScale (potentially indirectly by observing conditions) prior to sending requests

  8. vagababov commented on Jul 7, 2020

    @vagababov
    Contributor

    I think Revision should be ready if PA has been able to attain initialScale and that should be a sticky condition. Once reached, we're good.

  9. 1 remaining item

  10. cdlliuy commented on Jul 8, 2020

    @cdlliuy

    @markusthoemmes , after reading more of the knative implementation and the above proposal , I want to confirm whether the proposal is suggesting to remove active from KPA's .status.condition completely. By removing this, whether kpa .status.condistion.ready output will be fixed?

    I am asking this since currently we noticed that KPA .status.condition.lastTransition always changes ... Then it is very hard to measure when KPA has its initial ready during a performance test.

  11. markusthoemmes commented on Jul 8, 2020

    @markusthoemmes
    ContributorAuthor

    @cdlliuy no Active won't be dropped from conditions completely but rather be moved to be just informational. Check #8569 for a first step. The new condition would be exactly what you'd need to, as its time would be set exactly once, when stuff became ready. After this change the time on the Ready condition should be stable too.

  12. vagababov commented on Jul 29, 2020

    @vagababov
    Contributor

    The SKS readiness is now its own condition and should be easier to deal with PA status.

  13. github-actions commented on Oct 29, 2020

    @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.

  14. added
    lifecycle/stale
    on Oct 29, 2020
  15. markusthoemmes commented on Nov 24, 2020

    @markusthoemmes
    ContributorAuthor

    /unassign

    My work piece here is done.

  16. dprotaso commented on Nov 24, 2020

    @dprotaso
    Member

    @markusthoemmes are there any relevant issues/PRs of yours to tag besides #8569 ?

  17. markusthoemmes commented on Nov 24, 2020

    @markusthoemmes
    ContributorAuthor

    @dprotaso no, I think that's it.

  18. vagababov commented on Nov 24, 2020

    @vagababov
    Contributor

    I'd go as far as to just close this for now.

  19. vagababov commented on Nov 24, 2020

    @vagababov
    Contributor

    If any additional work we're going to do it should in scope of v1 API

  20. removed
    lifecycle/stale
    on Jan 23, 2021
  21. evankanderson commented on Mar 22, 2021

    @evankanderson
    Member

    /close

  22. knative-prow-robot commented on Mar 22, 2021

    @knative-prow-robot
    Contributor

    @evankanderson: Closing this issue.

    Details

    In response to this:

    /close

    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.

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

Metadata

Metadata

Labels

area/APIarea/autoscalekind/bugkind/cleanup

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions