Skip to content
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

core: fix node reservation scoring #7730

Merged
merged 5 commits into from
Apr 30, 2020
Merged

core: fix node reservation scoring #7730

merged 5 commits into from
Apr 30, 2020

Commits on Apr 15, 2020

  1. core: fix node reservation scoring

    The BinPackIter accounted for node reservations twice when scoring nodes
    which could bias scores toward nodes with reservations.
    
    Pseudo-code for previous algorithm:
    ```
    	proposed  = reservedResources + sum(allocsResources)
    	available = nodeResources - reservedResources
    	score     = 1 - (proposed / available)
    ```
    
    The node's reserved resources are added to the total resources used by
    allocations, and then the node's reserved resources are later
    substracted from the node's overall resources.
    
    The new algorithm is:
    ```
    	proposed  = sum(allocResources)
    	available = nodeResources - reservedResources
    	score     = 1 - (proposed / available)
    ```
    
    The node's reserved resources are no longer added to the total resources
    used by allocations.
    
    My guess as to how this bug happened is that the resource utilization
    variable (`util`) is calculated and returned by the `AllocsFit` function
    which needs to take reserved resources into account as a basic
    feasibility check.
    
    To avoid re-calculating alloc resource usage (because there may be a
    large number of allocs), we reused `util` in the `ScoreFit` function.
    `ScoreFit` properly accounts for reserved resources by subtracting them
    from the node's overall resources. However since `util` _also_ took
    reserved resources into account the score would be incorrect.
    
    Prior to the fix the added test output:
    ```
    Node: reserved     Score: 1.0000
    Node: reserved2    Score: 1.0000
    Node: no-reserved  Score: 0.9741
    ```
    
    The scores being 1.0 for *both* nodes with reserved resources is a good
    hint something is wrong as they should receive different scores. Upon
    further inspection the double accounting of reserved resources caused
    their scores to be >1.0 and clamped.
    
    After the fix the added test outputs:
    ```
    Node: no-reserved  Score: 0.9741
    Node: reserved     Score: 0.9480
    Node: reserved2    Score: 0.8717
    ```
    schmichael committed Apr 15, 2020
    Configuration menu
    Copy the full SHA
    2781717 View commit details
    Browse the repository at this point in the history
  2. docs: add #7730 to changelog

    schmichael committed Apr 15, 2020
    Configuration menu
    Copy the full SHA
    68aca51 View commit details
    Browse the repository at this point in the history

Commits on Apr 23, 2020

  1. Configuration menu
    Copy the full SHA
    df4af4d View commit details
    Browse the repository at this point in the history

Commits on Apr 30, 2020

  1. Update website/pages/docs/upgrade/upgrade-specific.mdx

    Co-authored-by: Alex Dadgar <alex@hashicorp.com>
    schmichael and dadgar committed Apr 30, 2020
    Configuration menu
    Copy the full SHA
    26d34f0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e3cba0c View commit details
    Browse the repository at this point in the history