-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: Selenium Grid in case multiple scaler triggers are activate #6437
Conversation
0153063
to
8615239
Compare
…sion triggers are active Signed-off-by: Viet Nguyen Duc <[email protected]>
Signed-off-by: Viet Nguyen Duc <[email protected]>
Signed-off-by: Viet Nguyen Duc <[email protected]>
/run-e2e selenium |
/run-e2e selenium |
Can you try e2e run one more time, I guess pull image could take time or reach pull limit rate...Here is result in my local EXECUTION SUMMARY
##############################################
##############################################
Passed tests:
Execution of tests/scalers/selenium/selenium_test.go, has passed after "one" attempts |
It looks like issue reaching the hub ->
I'm checking another issue in my local, once I finish I'll try to check this too |
@JorTurFer, I also done other tests in downstream repos. Let's rerun the e2e job here to see any luck :) |
/run-e2e selenium |
Thanks for your info, I am checking it in local again now |
The cluster can be accessed, right? how about when |
let me check |
I've added a print, and this is the content of the Hub response's body (the missing 2 are most probably because when I started the pod manually, they were processed) {
"data": {
"grid": {
"sessionCount": 0,
"maxSession": 0,
"totalSlots": 0
},
"nodesInfo": {
"nodes": [
]
},
"sessionsInfo": {
"sessionQueueRequests": [
"{\n \"acceptInsecureCerts\": true,\n \"browserName\": \"firefox\",\n \"moz:firefoxOptions\": {\n \"args\": [\n \"-remote-debugging-port\",\n \"40627\"\n ]\n }\n}",
"{\n \"acceptInsecureCerts\": true,\n \"browserName\": \"chrome\"\n}",
"{\n \"acceptInsecureCerts\": true,\n \"browserName\": \"firefox\",\n \"moz:firefoxOptions\": {\n \"args\": [\n \"-remote-debugging-port\",\n \"40947\"\n ]\n }\n}",
"{\n \"acceptInsecureCerts\": true,\n \"browserName\": \"chrome\"\n}"
]
}
}
} |
Now I'm debugging this function: // 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 == "" ||
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 != "")
// Check if platformName matches
platformNameMatch := request.PlatformName == "" && platformName == "" ||
strings.EqualFold(platformName, request.PlatformName)
return browserNameMatch && browserVersionMatch && platformNameMatch
} And the platformName doesn't match // Check if platformName matches
platformNameMatch := request.PlatformName == "" && platformName == "" ||
strings.EqualFold(platformName, request.PlatformName) So the result of the function is // Check if platformName matches
platformNameMatch := request.PlatformName == "" ||
strings.EqualFold(platformName, request.PlatformName) WDYT? I've tested that change locally and it works |
Yes, that is reason I also updated in deployment container env
To override the Node stereotypes be aligned with scaler metadata |
Signed-off-by: Viet Nguyen Duc <[email protected]>
Does it make sense to update the logic to not check the platform/browser/version if the request doesn't specify it? I mean, from my naive pov, if the request doesn't define those values it's because any node can handle that request. |
I changed |
/run-e2e selenium |
I'm checking it locally right now |
The problem that I see is that the nodes aren't starting, so any change applied in nodes isn't taken into account, at least until the node starts. As all the nodes are deployed scaled to 0, any configuration in the node won't be reflected in the hub |
Without set platfromName as EMPTY in Node config, it looks like it assumes as Windows by default in Grid...then the scaler scale it down to 0, due to mismatch with metadata |
Give me some time, I will fix the test need to enforce |
I've written you by Slack, maybe it'll be faster :) |
Signed-off-by: Viet Nguyen Duc <[email protected]>
/run-e2e selenium |
…acore#6437) * fix: Selenium Grid scaler avoids overlapping when multiple browserVersion triggers are active Signed-off-by: Viet Nguyen Duc <[email protected]> * Update CHANGELOG Signed-off-by: Viet Nguyen Duc <[email protected]> * Fix e2e template test Signed-off-by: Viet Nguyen Duc <[email protected]> * Change imagePullPolicy to Always to take latest change Signed-off-by: Viet Nguyen Duc <[email protected]> * Update platformName default value as empty Signed-off-by: Viet Nguyen Duc <[email protected]> --------- Signed-off-by: Viet Nguyen Duc <[email protected]> Signed-off-by: Jorge Turrado <[email protected]>
Implement strictly the condition to trigger the scaler in complex cases that Selenium Grid includes autoscaling Nodes (with multiple scaledObject with different triggers metadata), non-autoscaling Nodes, relay Nodes, and so on.
In general, update the scaler logic should be aligned with Selenium Grid core in
DefaultSlotMatcher
- which can be inspected https://github.com/SeleniumHQ/selenium/blob/trunk/java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.javaIt is also recommended to set the
browserName
,browserVersion
, andplatformName
to align across request capabilities, Node stereotype and scaler trigger params to have correct scaling behavior.In terms of
SlotMatcher
in Grid, there is no valuelatest
for the capabilitybrowserVersion
. So, remove that valuelatest
and keep the default value EMPTY.For example, client sends the request (in Python binding)
It is equivalent to scaler trigger params.
For example, client sends the request
The scaler trigger param should be aligned as
Most people are using the popular browser node image from the project docker-selenium. In default Node stereotype, the short browser version is set for
browserVersion
, it might cause breaking backward compatiblity, or request withoutbrowserVersion
could not trigger scaler anymore. Via SeleniumHQ/docker-selenium#2520, you can setSE_NODE_BROWSER_VERSION
as empty to unset the default version (take newer docker image tag from that project, which contains the change onwards).This also avoids multiple scalers, for example same
browserName
combines multiplebrowserVersion
could have issue with overlapping in counting number of ongoing and pending sessions belonging to each scaler trigger.In terms of Selenium Grid v4, it has a kind of Relay Node, which has capabilities to forward commands to the Appium instance. With this Node type, the
browserName
is optional. So, updating the trigger parambrowserName
to optional.Checklist
Fixes #
Relates to #