Repository navigation
feat(keda): add ArtemisQueue scaler mapping - #6893
dhvani7014 wants to merge 4 commits into
Conversation
squakez
left a comment
There was a problem hiding this comment.
I think the main goal is to be able to discover the endpoint automatically. I think you can use a Pipe and see how it converts into an Integration DSL. From the Integration you can verify the camel parameters and map them into the scaler accordingly.
|
Thanks @squakez! I checked the Pipe → Integration conversion: the ArkMQ binding produces A few questions before I push:
|
It could be a good idea to also use application properties to extract mapping configuration. However it may require some change in the original architecture to pass a new map to the scaler. Feel free to provide some proposal. The host should be the one coming from the configuration (mind that it could even be an Integration, not only a Pipe). Any other parameter has to be recovered automatically from the Integration as well as credential if they are present. However, given this is a first implementation you may let the credentials setting out of the implementation. A good sample to get some inspiration is in the e2e Kafka scaler test. We should try to replicate the same logic, but using the new scaler instead. |
|
Thanks a lot for the review @squakez! Here's a proposal before I change the code:
Does this direction look okay before I implement it? |
|
@dhvani7014 the previous assessment sounds good.
No, the scaler should not be aware of that resource. |
|
Thanks @squakez! I'll go with that: default the management port to 8161, take brokerName from autoMetadata, and not touch the CR. I'll push the changes soon. |
|
Hi @squakez, pushed the changes: the scaler now gets the camel.component.amqp.* properties and derives managementEndpoint from broker-url, and brokerName comes from autoMetadata. I also added a plain Integration e2e test and updated the contributor guide. Could you approve the workflow runs when you get a chance? |
squakez
left a comment
There was a problem hiding this comment.
I think this is taking the right direction. There are a few points that require a bit of attention.
| maxReplicaCount: 1 | ||
| autoMetadata: | ||
| artemis-queue: | ||
| brokerName: amq-broker No newline at end of file |
There was a problem hiding this comment.
Is there any possible to derive this param instead?
There was a problem hiding this comment.
I couldn't find a way to derive it. brokerName isn't part of the Camel/Integration config (broker-url only has the host and the AMQP port), and since the scaler shouldn't read the ActiveMQArtemis resource, I kept it in autoMetadata. Happy to change it if you kno of another source.
| g.Expect(scaledObj.Spec.Triggers[0].Metadata["managementEndpoint"]).To(Equal("my-broker-hdls-svc.arkmq.svc:8161")) | ||
| // Merged from autoMetadata | ||
| g.Expect(scaledObj.Spec.Triggers[0].Metadata["brokerName"]).To(Equal("amq-broker")) | ||
|
|
There was a problem hiding this comment.
We miss a check to verify the application is running and scaled to zero properly. I think you can get the very same behavior we're testing in Kafka test.
There was a problem hiding this comment.
makes sense. ill add the check that the app runs and scales to zero like the Kafka test
| } | ||
| if brokerURL, ok := props["broker-url"]; ok { | ||
| if u, err := url.Parse(brokerURL); err == nil && u.Hostname() != "" { | ||
| metadata["managementEndpoint"] = net.JoinHostPort(u.Hostname(), "8161") |
There was a problem hiding this comment.
I think we can derive the port as well from the "broker-url". Can you verify if that is expected to be part of the parameter?
There was a problem hiding this comment.
I checked: the port in broker-url (61616) is the AMQP messaging port while KEDA's managementEndpoint needs the web console port (8161 by default). So it cant come from broker-url. If the console runs on a different port, users can override managementEndpoint through autoMetadata.
| return nil, nil | ||
| } | ||
| kedaType, metadata := mapper.Map(pathValue, params) | ||
| prefix := "camel.component." + scheme + "." |
There was a problem hiding this comment.
Why don't we provide instead the full map? Each scaler can filter the specific fields on its own. If we keep this generic we enable potentially other scalers with more capability.
There was a problem hiding this comment.
Good point. I'll pass the full map and let each scaler filter what it needs.
| return nil | ||
| } | ||
|
|
||
| func integrationProperties(e *Environment) map[string]string { |
There was a problem hiding this comment.
nitpick. We should move this func into trait.go or other generic file as it can be reused in theory. It still needs to be private though.
There was a problem hiding this comment.
okay. ill move it to trait and and keep it private
|
@squakez pushed the changes from your review. let me know if you need anything else to be changed |
Fixes #6890
Adds a KEDA scaler mapping for ActiveMQ Artemis queues, following the keda-scaler contributing guide.
pkg/trait/keda/scalers/artemis.go: registers a mapper for theamqpcomponent (the URI ArkMQ bindings produce,amqp:queue:<name>). It maps the queue name toqueueNameandbrokerAddressfor the KEDAartemis-queuescaler. Topics are not mapped.managementEndpointandbrokerNamecan't be derived from the URI, so they are provided viakeda.autoMetadata.artemis_test.go: unit tests for registration, mapping, andMapToKedaTrigger, modelled onkafka_test.go.my-queuewithautoMetadata), and installed KEDA in the ArkMQ setup script.Tested locally with
go test ./pkg/trait/keda/... ./pkg/trait,gofmt, andgo vet -tags integration ./e2e/arkmq/. I couldn't run the e2e test locally.The e2e test checks the generated ScaledObject (auto-discovery + metadata merge), like the Kafka auto-discovery test. Happy to extend it to a full scale-up/scale-down test if you'd like.