Closed lsteinberg-r7 closed 6 months ago
Nice catch! Are you willing to open a PR with the fix?
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 😅
no worries! Let's see if anyone wants to help here, I'd say that it should be easy
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{
Have opened an pr: https://github.com/kedacore/keda/pull/5773 please take a look when you have time :)
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 - https://github.com/kedacore/keda/blob/c55e306af94bf41d69c4f3d43744398fa07a358e/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology.go#L390-L403Expected 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
Logs from KEDA operator
KEDA Version
2.14.0
Kubernetes Version
None
Platform
Google Cloud
Scaler Details
MongoDB
Anything else?
No response