Skip to content

Commit

Permalink
K8s: Update KEDA patch version in default chart
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Jan 18, 2025
1 parent a195077 commit 1dedde7
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .keda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ You can involve to review and discuss the pull requests to help us early detect

[kedacore/keda](https://github.com/kedacore/keda)

- https://github.com/kedacore/keda/pull/6477

- ~~https://github.com/kedacore/keda/pull/6437 (merged, v2.16.1)~~

- ~~https://github.com/kedacore/keda/pull/6368 (merged, v2.16.1)~~
Expand All @@ -57,6 +59,8 @@ You can involve to review and discuss the pull requests to help us early detect

[kedacore/keda-docs](https://github.com/kedacore/keda-docs)

- https://github.com/kedacore/keda-docs/pull/1522

- https://github.com/kedacore/keda-docs/pull/1515

- ~~https://github.com/kedacore/keda-docs/pull/1468 (merged, v2.16.0)~~
Expand Down
6 changes: 4 additions & 2 deletions .keda/scalers/selenium-grid-scaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ triggers:
url: 'http://selenium-hub:4444/graphql' # Required. Can be ommitted if specified via TriggerAuthentication/ClusterTriggerAuthentication.
browserName: '' # Optional. Required to be matched with the request in queue and Node stereotypes (Similarly for `browserVersion` and `platformName`).
browserVersion: '' # Optional.
platformName: 'linux' # Optional.
platformName: '' # Optional.
unsafeSsl : 'false' # Optional.
activationThreshold: 0 # Optional.
```
Expand All @@ -35,7 +35,7 @@ triggers:
- `browserVersion` - Version of browser that usually gets passed in the browser capability. Refer to the [Selenium Grid's](https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/) and [WebdriverIO's](https://webdriver.io/docs/options/#capabilities) documentation for more info. (Optional)
- `unsafeSsl` - Skip certificate validation when connecting over HTTPS. (Values: `true`, `false`, Default: `false`, Optional)
- `activationThreshold` - Target value for activating the scaler. Learn more about activation [here](./../concepts/scaling-deployments.md#activating-and-scaling-thresholds). (Default: `0`, Optional)
- `platformName` - Name of the browser platform. Refer to the [Selenium Grid's](https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/) and [WebdriverIO's](https://webdriver.io/docs/options/#capabilities) documentation for more info. (Default: `Linux`, Optional)
- `platformName` - Name of the browser platform. Refer to the [Selenium Grid's](https://www.selenium.dev/documentation/en/getting_started_with_webdriver/browsers/) and [WebdriverIO's](https://webdriver.io/docs/options/#capabilities) documentation for more info. (Optional)
- `nodeMaxSessions` - Number of maximum sessions that can run in parallel on a Node. Update this parameter align with node config `--max-sessions` (`SE_NODE_MAX_SESSIONS`) to have the correct scaling behavior. (Default: `1`, Optional).

**Trigger Authentication**
Expand Down Expand Up @@ -66,6 +66,8 @@ spec:
env:
- name: SE_NODE_BROWSER_VERSION
value: ''
- name: SE_NODE_PLATFORM_NAME
value: 'Linux'
---
Expand Down
19 changes: 9 additions & 10 deletions .keda/scalers/selenium_grid_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,35 +251,34 @@ func countMatchingSessions(sessions Sessions, browserName string, browserVersion
// This function checks if the request capabilities match the scaler metadata
func checkRequestCapabilitiesMatch(request Capability, browserName string, browserVersion string, _ string, platformName string) bool {
// Check if browserName matches
browserNameMatch := request.BrowserName == "" && browserName == "" ||
browserNameMatch := (request.BrowserName == "" && browserName == "") ||
strings.EqualFold(browserName, request.BrowserName)

// Check if browserVersion matches
browserVersionMatch := (request.BrowserVersion == "" && browserVersion == "") ||
(request.BrowserVersion == "stable" && browserVersion == "") ||
(strings.HasPrefix(browserVersion, request.BrowserVersion) && request.BrowserVersion != "" && browserVersion != "")
(request.BrowserVersion != "" && strings.HasPrefix(browserVersion, request.BrowserVersion))

// Check if platformName matches
platformNameMatch := request.PlatformName == "" && platformName == "" ||
strings.EqualFold(platformName, request.PlatformName)
platformNameMatch := (request.PlatformName == "" || strings.EqualFold("any", request.PlatformName) || strings.EqualFold(platformName, request.PlatformName)) &&
(platformName == "" || platformName == "any" || strings.EqualFold(platformName, request.PlatformName))

return browserNameMatch && browserVersionMatch && platformNameMatch
}

// This function checks if Node stereotypes or ongoing sessions match the scaler metadata
func checkStereotypeCapabilitiesMatch(capability Capability, browserName string, browserVersion string, sessionBrowserName string, platformName string) bool {
// Check if browserName matches
browserNameMatch := capability.BrowserName == "" && browserName == "" ||
browserNameMatch := (capability.BrowserName == "" && browserName == "") ||
strings.EqualFold(browserName, capability.BrowserName) ||
strings.EqualFold(sessionBrowserName, capability.BrowserName)

// Check if browserVersion matches
browserVersionMatch := capability.BrowserVersion == "" && browserVersion == "" ||
(strings.HasPrefix(browserVersion, capability.BrowserVersion) && capability.BrowserVersion != "" && browserVersion != "")
browserVersionMatch := (capability.BrowserVersion == "" && browserVersion == "") ||
(capability.BrowserVersion != "" && strings.HasPrefix(browserVersion, capability.BrowserVersion))

// Check if platformName matches
platformNameMatch := capability.PlatformName == "" && platformName == "" ||
strings.EqualFold(platformName, capability.PlatformName)
platformNameMatch := (capability.PlatformName == "" || strings.EqualFold("any", capability.PlatformName) || strings.EqualFold(platformName, capability.PlatformName)) &&
(platformName == "" || platformName == "any" || strings.EqualFold(platformName, capability.PlatformName))

return browserNameMatch && browserVersionMatch && platformNameMatch
}
Expand Down
68 changes: 68 additions & 0 deletions .keda/scalers/selenium_grid_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,74 @@ func Test_getCountFromSeleniumResponse(t *testing.T) {
wantOnGoingSessions: 2,
wantErr: false,
},
{
name: "1 queue request without platformName and scaler metadata without platfromName should return 1 new node and 1 ongoing session",
args: args{
b: []byte(`{
"data": {
"grid": {
"sessionCount": 2,
"maxSession": 2,
"totalSlots": 2
},
"nodesInfo": {
"nodes": [
{
"id": "node-1",
"status": "UP",
"sessionCount": 1,
"maxSession": 1,
"slotCount": 1,
"stereotypes": "[{\"slots\": 1, \"stereotype\": {\"browserName\": \"chrome\", \"platformName\": \"any\"}}]",
"sessions": [
{
"id": "session-1",
"capabilities": "{\"browserName\": \"chrome\", \"platformName\": \"any\"}",
"slot": {
"id": "9ce1edba-72fb-465e-b311-ee473d8d7b64",
"stereotype": "{\"browserName\": \"chrome\", \"platformName\": \"any\"}"
}
}
]
},
{
"id": "node-2",
"status": "UP",
"sessionCount": 1,
"maxSession": 1,
"slotCount": 1,
"stereotypes": "[{\"slots\": 1, \"stereotype\": {\"browserName\": \"chrome\", \"platformName\": \"linux\"}}]",
"sessions": [
{
"id": "session-2",
"capabilities": "{\"browserName\": \"chrome\", \"browserVersion\": \"91.0\", \"platformName\": \"linux\"}",
"slot": {
"id": "9ce1edba-72fb-465e-b311-ee473d8d7b64",
"stereotype": "{\"browserName\": \"chrome\", \"platformName\": \"linux\"}"
}
}
]
}
]
},
"sessionsInfo": {
"sessionQueueRequests": [
"{\"browserName\": \"chrome\", \"platformName\": \"linux\"}",
"{\"browserName\": \"chrome\"}",
"{\"browserName\": \"chrome\", \"platformName\": \"any\"}"
]
}
}
}`),
browserName: "chrome",
sessionBrowserName: "chrome",
browserVersion: "",
platformName: "",
},
wantNewRequestNodes: 2,
wantOnGoingSessions: 1,
wantErr: false,
},
{
name: "1 active session with matching browsername and version should return count as 2",
args: args{
Expand Down
26 changes: 13 additions & 13 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1976,19 +1976,19 @@ customLabels: {}
keda:
# enabled: false
# -- Specify image for KEDA components
# image:
# keda:
# registry: selenium
# repository: keda
# tag: "2.16.1-selenium-grid-20250101"
# metricsApiServer:
# registry: selenium
# repository: keda-metrics-apiserver
# tag: "2.16.1-selenium-grid-20250101"
# webhooks:
# registry: selenium
# repository: keda-admission-webhooks
# tag: "2.16.1-selenium-grid-20250101"
image:
keda:
registry: selenium
repository: keda
tag: "2.16.1-selenium-grid-20250101"
metricsApiServer:
registry: selenium
repository: keda-metrics-apiserver
tag: "2.16.1-selenium-grid-20250101"
webhooks:
registry: selenium
repository: keda-admission-webhooks
tag: "2.16.1-selenium-grid-20250101"
# -- Annotations for KEDA resources
additionalAnnotations:
http:
Expand Down

0 comments on commit 1dedde7

Please sign in to comment.