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

fix scale with windows nodes in cluster issue 4908 #5917

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions pkg/scalers/selenium_grid_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type seleniumSession struct {
ID string `json:"id"`
Capabilities string `json:"capabilities"`
NodeID string `json:"nodeId"`
PlatformName string `json:"platformName"`
}

type capability struct {
Expand Down Expand Up @@ -152,7 +153,7 @@ func (s *seleniumGridScaler) GetMetricSpecForScaling(context.Context) []v2.Metri

func (s *seleniumGridScaler) getSessionsCount(ctx context.Context, logger logr.Logger) (int64, error) {
body, err := json.Marshal(map[string]string{
"query": "{ grid { maxSession, nodeCount }, sessionsInfo { sessionQueueRequests, sessions { id, capabilities, nodeId } } }",
"query": "{ grid { maxSession, nodeCount }, sessionsInfo { sessionQueueRequests, sessions { id, capabilities, nodeId, platformName } } }",
})

if err != nil {
Expand Down Expand Up @@ -199,10 +200,9 @@ func getCountFromSeleniumResponse(b []byte, browserName string, browserVersion s
var capability = capability{}
if err := json.Unmarshal([]byte(sessionQueueRequest), &capability); err == nil {
if capability.BrowserName == browserName {
var platformNameMatches = capability.PlatformName == "" || strings.EqualFold(capability.PlatformName, platformName)
if strings.HasPrefix(capability.BrowserVersion, browserVersion) && platformNameMatches {
if strings.HasPrefix(capability.BrowserVersion, browserVersion) && strings.EqualFold(capability.PlatformName, platformName) {
count++
} else if len(strings.TrimSpace(capability.BrowserVersion)) == 0 && browserVersion == DefaultBrowserVersion && platformNameMatches {
} else if len(strings.TrimSpace(capability.BrowserVersion)) == 0 && browserVersion == DefaultBrowserVersion && strings.EqualFold(capability.PlatformName, platformName) {
count++
}
}
Expand All @@ -215,11 +215,10 @@ func getCountFromSeleniumResponse(b []byte, browserName string, browserVersion s
for _, session := range sessions {
var capability = capability{}
if err := json.Unmarshal([]byte(session.Capabilities), &capability); err == nil {
var platformNameMatches = capability.PlatformName == "" || strings.EqualFold(capability.PlatformName, platformName)
if capability.BrowserName == sessionBrowserName {
if strings.HasPrefix(capability.BrowserVersion, browserVersion) && platformNameMatches {
if strings.HasPrefix(capability.BrowserVersion, browserVersion) && strings.EqualFold(capability.PlatformName, platformName) {
count++
} else if browserVersion == DefaultBrowserVersion && platformNameMatches {
} else if browserVersion == DefaultBrowserVersion && strings.EqualFold(capability.PlatformName, platformName) {
count++
}
}
Expand Down
Loading