Skip to content

Selenium Grid Scaler | Max Sessions implementation issue #3061

Closed
@Wolfe1

Description

Report

The MaxSessions implementation in #2774 is producing incorrect results. I ran into this while trying to create a fix for #2709.

Expected Behavior

We need to take into consideration the count of the nodes we have in this calculation.

Something like:
count = count / (gridMaxSession / nodeCount)

  1. 2 sessions running on 2 nodes, 3 sessions in the queue, each node accepts 1 session max:
    a. count = 5 / (2 / 2)
    b. This equals out to be 5 which is how many nodes we need.
  2. 10 sessions running on 2 nodes, 7 sessions in the queue, each node accepts 5 sessions max:
    a. count = 17 / (10 / 2)
    b. This equals out to be 3.4 (rounded to 4 I assume?) which is what we need.

Actual Behavior

https://github.com/kedacore/keda/blob/main/pkg/scalers/selenium_grid_scaler.go#L252 :
count = (count + gridMaxSession - 1) / gridMaxSession is the current equation.

This equation does not take into account the number of nodes available and thus will consistently produce an incorrect result, for example:

  1. 2 sessions running on 2 nodes, 3 sessions in the queue, each node accepts 1 session max:
    a. count = (5 + 2 - 1) / 2
    b. This equals out to be 3 when it should be 5
  2. 10 sessions running on 2 nodes, 7 sessions in the queue, each node accepts 5 sessions max:
    a. count = (17 + 10 - 1) / 10
    b. This equals out to be 2.6 (rounded to 3 I assume?) when it should be 4

Steps to Reproduce the Problem

Simply using the scaler with a version higher than 2.6.1 will suffice. Items will be left in the queue while we still have room to scale.

Logs from KEDA operator

No response

KEDA Version

2.7.1

Kubernetes Version

1.23

Platform

Microsoft Azure

Scaler Details

Selenium Grid

Anything else?

No response

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions