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

Service Binding should follow standard CAP behaviour #264

Open
gregorwolf opened this issue Dec 28, 2024 · 5 comments · May be fixed by #265
Open

Service Binding should follow standard CAP behaviour #264

gregorwolf opened this issue Dec 28, 2024 · 5 comments · May be fixed by #265

Comments

@gregorwolf
Copy link

gregorwolf commented Dec 28, 2024

Hello Event Queue Team,

the SAP BTP redis service can only be reached via an SSH tunnel (see: Access a Redis-cache Instance from Redis-cli). Because of that Hybrid Testing is not directly possible. I've solved this by creating a User Provided Service named redis-cache with the following data:

{
    "credentials": {
        "hostname": "127.0.0.1",
        "port": 6379,
        "uri": "redis://127.0.0.1:6379",
        "cluster_mode": false
    }
}

This UPS can be bound to the local CAP environment using:

cds bind redis-cache --to redis-cache

with this adjustment of redisCredentialsFromEnv() that uses @sap/xsenv instead of a hard read for redis-cache in VCAP_SERVICES I was then able to connect to a local redis running in a container:

docker run -p 6379:6379 --name redis-cache -d redis

I would think that the plugin should be improved to follow the CAP best practice for Service Bindings. Maybe @chgeo or @oklemenz can give some guidance about the best way for the service binding.

Best Regards
Gregor

@soccermax
Copy link
Contributor

Hi @gregorwolf,

thanks for reporting this. Yes hybrid testing with cds bind should be supported. I'll provide a fix.

Best regards,
Max

@soccermax soccermax linked a pull request Dec 29, 2024 that will close this issue
@soccermax
Copy link
Contributor

@gregorwolf can you lock at the attached PR? Would that work for you?
As long as your binding hybrid or not has the label redis-cache it should work. You can even redefine the vcap section of cds.requires["eventqueue-redis-cache"]. But I think for most use cases this should not be needed.
I prefer to rely on the CAP implementation of reading service credentials over the use of xssev.

@gregorwolf
Copy link
Author

Hi @soccermax,

thank you for the quick fix. This works great when providing redis local via a docker container. But as the SAP BTP redis service can only be reached via an SSH tunnel (see: Access a Redis-cache Instance from Redis-cli) and also requires TLS it would be great if you can provide an option to set the TLS options. My workaround for the moment is to add an entry for the BTP redis service hostname in my local hosts file and point to localhost.

Best regards,
Gregor

@soccermax
Copy link
Contributor

Hi @gregorwolf,

Thanks for the feedback.
Can you check if the already available parameter redisOptions is enough for your use case? See documentation: https://cap-js-community.github.io/event-queue/setup/#initialization-parameters

Note: this will only work for non-cluster clients. I need to check again for cluster-clients next week. Implementation for the creation of redis clients is in src/shared/redis

Best,
Max

@gregorwolf
Copy link
Author

Hi @soccermax ,

thank you for the quick response. For the moment I've adjusted my instructions: using the redis service from the provider subaccount to add an entry for the BTP redis service hostname in my local hosts file and point to localhost. This allows to run in hybrid mode without any other change.

CU
Gregor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants