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

Version 2.14 - MongoDB Atlas scheme #5760

Closed
lsteinberg-r7 opened this issue May 1, 2024 · 5 comments · Fixed by #5773
Closed

Version 2.14 - MongoDB Atlas scheme #5760

lsteinberg-r7 opened this issue May 1, 2024 · 5 comments · Fixed by #5773
Labels
bug Something isn't working good first issue Good for newcomers help wanted Looking for support from community

Comments

@lsteinberg-r7
Copy link

Report

I'm trying to use the latest version's feature of MongoDB Atlas scheme support (mongodb+srv), and getting conflicting requirements -

Keda scale-handler requires a port to be given, otherwise it's failing with:
failed to parsing mongoDB metadata, because of missing required field in scaler config: no port given

But if I'm supplying a port, MongoDB driver itself is failing with the following message:
URI with srv must not include a port number
which comes from this piece of code -

if t.pollingRequired {
// sanity check before passing the hostname to resolver
if len(t.hosts) != 1 {
return fmt.Errorf("URI with SRV must include one and only one hostname")
}
_, _, err = net.SplitHostPort(t.hosts[0])
if err == nil {
// we were able to successfully extract a port from the host,
// but should not be able to when using SRV
return fmt.Errorf("URI with srv must not include a port number")
}
go t.pollSRVRecords(t.hosts[0])
t.pollingwg.Add(1)
}

Expected Behavior

Scaler defined with the +srv scheme should not require a port number.

Actual Behavior

Scaler defined with the +srv scheme requires a port number, even though it conflicts with the driver's requirements.

Steps to Reproduce the Problem

  1. Define a real Atlas host
  2. Define a scaler that uses the host, with a port number
  3. See the error event in the scaler definition in k8s.

Logs from KEDA operator

example

KEDA Version

2.14.0

Kubernetes Version

None

Platform

Google Cloud

Scaler Details

MongoDB

Anything else?

No response

@lsteinberg-r7 lsteinberg-r7 added the bug Something isn't working label May 1, 2024
@JorTurFer
Copy link
Member

Nice catch! Are you willing to open a PR with the fix?

@lsteinberg-r7
Copy link
Author

Nice catch! Are you willing to open a PR with the fix?

@JorTurFer I would love to but I'm not sure I have the time, many tasks ahead in my company 😅

@JorTurFer
Copy link
Member

no worries! Let's see if anyone wants to help here, I'd say that it should be easy

@JorTurFer JorTurFer added help wanted Looking for support from community good first issue Good for newcomers labels May 1, 2024
@Rishikesh01
Copy link
Contributor

Rishikesh01 commented May 1, 2024

Hi @JorTurFer I was able to replicate OP error in mongo_scaler_test.go,after doing the following changes. Will make PR shortly :)

diff --git a/pkg/scalers/mongo_scaler_test.go b/pkg/scalers/mongo_scaler_test.go
index 02f1e947..fd9f54f8 100644
--- a/pkg/scalers/mongo_scaler_test.go
+++ b/pkg/scalers/mongo_scaler_test.go
@@ -73,7 +73,7 @@ var testMONGODBMetadata = []parseMongoDBMetadataTestData{
        // mongodb srv support
        {
                metadata:    map[string]string{"query": `{"name":"John"}`, "collection": "demo", "queryValue": "12"},
-               authParams:  map[string]string{"dbName": "test", "scheme": "mongodb+srv", "host": "localhost", "port": "1234", "username":$
+               authParams:  map[string]string{"dbName": "test", "scheme": "mongodb+srv", "host": "localhost", "port": "", "username": "sa$
                resolvedEnv: testMongoDBResolvedEnv,
                raisesError: false,
        },
@@ -90,7 +90,7 @@ var mongoDBConnectionStringTestDatas = []mongoDBConnectionStringTestData{
        {metadataTestData: &testMONGODBMetadata[2], connectionString: "mongodb://mongodb0.example.com:27017"},
        {metadataTestData: &testMONGODBMetadata[3], connectionString: "mongodb://sample:test%40password@localhost:1234/test"},
        {metadataTestData: &testMONGODBMetadata[4], connectionString: "mongodb://sample:sec%40ure@localhost:1234/test"},
-       {metadataTestData: &testMONGODBMetadata[5], connectionString: "mongodb+srv://sample:sec%40ure@localhost:1234/test"},
+       {metadataTestData: &testMONGODBMetadata[5], connectionString: "mongodb+srv://sample:sec%40ure@localhost/test"},
 }

 var mongoDBMetricIdentifiers = []mongoDBMetricIdentifier{

Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 1, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh <53863619+Rishikesh01@users.noreply.github.com>
Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 1, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh <53863619+Rishikesh01@users.noreply.github.com>
Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 1, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh <53863619+Rishikesh01@users.noreply.github.com>
Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 1, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh <53863619+Rishikesh01@users.noreply.github.com>
@Rishikesh01
Copy link
Contributor

Have opened an pr: #5773 please take a look when you have time :)

Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 2, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 2, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 4, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 4, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Rishikesh01 added a commit to Rishikesh01/keda that referenced this issue May 4, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
JorTurFer pushed a commit that referenced this issue May 4, 2024
This commit fixs issue #5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
JorTurFer pushed a commit to JorTurFer/keda that referenced this issue Jul 30, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
JorTurFer pushed a commit to JorTurFer/keda that referenced this issue Jul 30, 2024
This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
JorTurFer added a commit that referenced this issue Jul 31, 2024
* bump golang

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* chore: build with keda-tools:1.22.5 (#5971)

* chore: build with keda-tools:1.22.5
to resolve CVE-2024-24790, CVE-2024-24789, and CVE-2024-24791
bump github.com/Azure/azure-sdk-for-go/sdk/azidentity to resolve CVE-2024-35255

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>

* chore: use go install instead of go get and replacing deprecated tools

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>

* chore: vendor dependency cleanup

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>

* Update missing references to 1.21

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

---------

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* [BUG-5922] Report failing ScaledJob triggers in status (#5916)

Signed-off-by: Josef Karasek <josef@kedify.io>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* [BUG-5656] Annotate Jobs with parent ScaledJob generation (#5876)

* Annotate Jobs with parent ScaledJob generation

Signed-off-by: Josef Karasek <josef@kedify.io>

* fix tests

Signed-off-by: Josef Karasek <josef@kedify.io>

* fix lint

Signed-off-by: Josef Karasek <josef@kedify.io>

* fix log message

Signed-off-by: Josef Karasek <josef@kedify.io>

* update changelog

Signed-off-by: Josef Karasek <josef@kedify.io>

* update changelog

Signed-off-by: Josef Karasek <josef@kedify.io>

* update changelog

Signed-off-by: Josef Karasek <josef@kedify.io>

---------

Signed-off-by: Josef Karasek <josef@kedify.io>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix: `+srv` mongodb url scheme parsing bug (#5773)

This commit fixs issue #5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix: issue when GitHub organization contains more than 30 repos (#5746)

Signed-off-by: Simon Kobler <github@kobler.me>
Signed-off-by: Simon Kobler <32038731+KoblerS@users.noreply.github.com>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Simon Kobler <github@kobler.me>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Fix scaler leak during cache refresh (#5807)

Signed-off-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Prepare release v2.14.1

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* add missing change

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* update changelog

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix: e2e test regex check tag (#5831)

Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Validate regex before building image for e2e test (#5783)

* added regex pre check before building image

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* updated changelog

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* refactored

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* corrected

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* corrected changelog

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* updated the workflow

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* updated the workflow

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

---------

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix some pending tasks

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* use AAD-Pod-Identity always

Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

* use AAD-Pod-Identity always

Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

---------

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Paul Yu <paul.d.yu@gmail.com>
Signed-off-by: Josef Karasek <josef@kedify.io>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Signed-off-by: Simon Kobler <github@kobler.me>
Signed-off-by: Simon Kobler <32038731+KoblerS@users.noreply.github.com>
Signed-off-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>
Co-authored-by: Paul Yu <paul.d.yu@gmail.com>
Co-authored-by: Josef Karasek <josef@kedify.io>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Rishikesh <53863619+Rishikesh01@users.noreply.github.com>
Co-authored-by: Simon Kobler <32038731+KoblerS@users.noreply.github.com>
Co-authored-by: Simon Kobler <github@kobler.me>
Co-authored-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Co-authored-by: Yashveer <101015836+Yaxhveer@users.noreply.github.com>
jkyros pushed a commit to jkyros/keda that referenced this issue Aug 2, 2024
* bump golang

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* chore: build with keda-tools:1.22.5 (kedacore#5971)

* chore: build with keda-tools:1.22.5
to resolve CVE-2024-24790, CVE-2024-24789, and CVE-2024-24791
bump github.com/Azure/azure-sdk-for-go/sdk/azidentity to resolve CVE-2024-35255

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>

* chore: use go install instead of go get and replacing deprecated tools

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>

* chore: vendor dependency cleanup

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>

* Update missing references to 1.21

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

---------

Signed-off-by: Paul Yu <paul.d.yu@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* [BUG-5922] Report failing ScaledJob triggers in status (kedacore#5916)

Signed-off-by: Josef Karasek <josef@kedify.io>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* [BUG-5656] Annotate Jobs with parent ScaledJob generation (kedacore#5876)

* Annotate Jobs with parent ScaledJob generation

Signed-off-by: Josef Karasek <josef@kedify.io>

* fix tests

Signed-off-by: Josef Karasek <josef@kedify.io>

* fix lint

Signed-off-by: Josef Karasek <josef@kedify.io>

* fix log message

Signed-off-by: Josef Karasek <josef@kedify.io>

* update changelog

Signed-off-by: Josef Karasek <josef@kedify.io>

* update changelog

Signed-off-by: Josef Karasek <josef@kedify.io>

* update changelog

Signed-off-by: Josef Karasek <josef@kedify.io>

---------

Signed-off-by: Josef Karasek <josef@kedify.io>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix: `+srv` mongodb url scheme parsing bug (kedacore#5773)

This commit fixs issue kedacore#5760. where OP was facing problem with +srv schema

Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix: issue when GitHub organization contains more than 30 repos (kedacore#5746)

Signed-off-by: Simon Kobler <github@kobler.me>
Signed-off-by: Simon Kobler <32038731+KoblerS@users.noreply.github.com>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Simon Kobler <github@kobler.me>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Fix scaler leak during cache refresh (kedacore#5807)

Signed-off-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Prepare release v2.14.1

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* add missing change

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* update changelog

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix: e2e test regex check tag (kedacore#5831)

Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* Validate regex before building image for e2e test (kedacore#5783)

* added regex pre check before building image

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* updated changelog

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* refactored

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* corrected

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* corrected changelog

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* updated the workflow

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

* updated the workflow

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>

---------

Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* fix some pending tasks

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>

* use AAD-Pod-Identity always

Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

* use AAD-Pod-Identity always

Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>

---------

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
Signed-off-by: Paul Yu <paul.d.yu@gmail.com>
Signed-off-by: Josef Karasek <josef@kedify.io>
Signed-off-by: Zbynek Roubalik <zroubalik@gmail.com>
Signed-off-by: Rishikesh Betigeri <53863619+Rishikesh01@users.noreply.github.com>
Signed-off-by: Simon Kobler <github@kobler.me>
Signed-off-by: Simon Kobler <32038731+KoblerS@users.noreply.github.com>
Signed-off-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com>
Signed-off-by: Yaxhveer <yaxhcod@gmail.com>
Signed-off-by: Jorge Turrado <jorge.turrado@scrm.lidl>
Co-authored-by: Paul Yu <paul.d.yu@gmail.com>
Co-authored-by: Josef Karasek <josef@kedify.io>
Co-authored-by: Zbynek Roubalik <zroubalik@gmail.com>
Co-authored-by: Rishikesh <53863619+Rishikesh01@users.noreply.github.com>
Co-authored-by: Simon Kobler <32038731+KoblerS@users.noreply.github.com>
Co-authored-by: Simon Kobler <github@kobler.me>
Co-authored-by: Guillaume Jacquet <guillaume.jacquet@gmail.com>
Co-authored-by: Jan Wozniak <wozniak.jan@gmail.com>
Co-authored-by: Yashveer <101015836+Yaxhveer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Looking for support from community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants