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

Support for custom AMQP protocol and external INVENIO_SEARCH_HOSTS #125

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

fradeve
Copy link
Contributor

@fradeve fradeve commented Aug 16, 2024

Description

This PR solves 3 issues with the Helm chart

RabbitMQ protocol can't be customized

The default protocol for RabbitMQ is amqp and can't be edited -- this is probably fine when running RabbitMQ locally, but most hosted RMQ instances will only accept connections on amqps; this PR adds support for a custom protocol when using .Values.rabbitmqExternal; in any other case, amqp is used as a default.

Files affected:

Impossible to define custom Search username, password or port

The easiest way to use an external {Open/Elastic}Search instance is to pass INVENIO_SEARCH_HOSTS in the environment; however, the way INVENIO_SEARCH_HOSTS is set in the Configmap:

INVENIO_SEARCH_HOSTS: {{ printf "[{'host': '%s'}]" (include "invenio.opensearch.hostname" .) | quote }}

means that only the hostname can be configured, without port, user or password; this is of course unworkable when using an hosted {Elastic/Open}Search that needs proper authentication to be passed to the application.

A possible way around this is to add the INVENIO_SEARCH_HOSTS string into Values.invenio.extra_config; this will however force Helm to have 2 INVENIO_SEARCH_HOSTS in the Configmap -- which won't work either.

In this PR, if INVENIO_SEARCH_HOSTS is set in extra_config, it is removed from the Configmap so we don't get this defined twice, avoiding clashes and allowing the app to connect to an externally hosted search engine.

Files affected:

Web service type cannot be changed

service.type defaults to ClusterIP, however when using some cloud reverse proxies like Traefik, this should be set to NodePort and currently there is no way to change it.
I have added Values.web.service.type; if not specified, it defaults to ClusterIP -- which is the current default anyway.

Files affected

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

charts/invenio/values.yaml Outdated Show resolved Hide resolved
* It explicitly set the default as `ClusterIP` inside `values.yaml`.
@egabancho egabancho force-pushed the custom-amqp-protocol branch from 0d30e68 to 4c2318d Compare November 21, 2024 09:37
@egabancho egabancho requested review from lindhe and Samk13 November 21, 2024 09:39
@Samk13
Copy link
Member

Samk13 commented Nov 21, 2024

Thank you for your contribution. However, there's a PR introducing changes where the application constructs connection strings from environment variables.
If merged, this might make the modifications in this PR redundant or require adjustments to align with the new approach. @lindhe could you please take a look at this?

@lindhe
Copy link
Contributor

lindhe commented Nov 21, 2024

You are right that our planned changes to connection strings would change things relating to this PR. But I don't think it's worth waiting for that.

If we merge this first, it's just a little more work for our future improvement. But if we wait for that first, than it risks delaying these improvements unnecessarily.

So I think we should not block this PR, but it's worth a heads-up that related changes are coming. And that may or may not be breaking changes in the Helm chart, depending on how easy it is for me to be backwards compatible with the change.

Copy link
Contributor

@lindhe lindhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is looking very promising. I don't see the issue, but when I run helm template foo ./charts/invenio -f ~/tmp/invenio-foo-values.yaml it crashes. Here are the values I use:

invenio:
  hostname: foo
  secret_key: foo
  security_login_salt: foo
  csrf_secret_salt: foo
postgresql:
  auth:
    password: foo
rabbitmq:
  enabled: true
  auth:
    password: foo

I'll try to debug later, but I don't have time right now. Please see if you can find the bug before I do. 🙃

@egabancho
Copy link
Member

🤔 We are running these changes already in our test instance with no issues.
I'll take a look and see if I can reproduce it locally.

@lindhe
Copy link
Contributor

lindhe commented Nov 21, 2024

I think I found the issues, I posted suggestions. Currently untested, I'll get back later.

@lindhe
Copy link
Contributor

lindhe commented Nov 22, 2024

I finally got around to testing my changes. Having bare strings will break things if rabbitmq.enabled=true. But if we wrap them in template strings according to my suggestions, it works. If you fix that, I'll approve. :)

@egabancho egabancho force-pushed the custom-amqp-protocol branch from 4c2318d to d77b78d Compare November 24, 2024 20:48
Copy link
Contributor

@lindhe lindhe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good now, thank you for your contribution!

Next time it would be great if you created one PR per logical change. Despite you doing exemplary work by creating three logically separate commits, GitHub's review system really only lets us review the aggregate changes. Also there's only a single PR title that people can search for, while your PR has three changes. So one PR per logical change would be even more helpful.

But that's for next time. This time: well done! 👍

@lindhe lindhe merged commit 1c25dd7 into inveniosoftware:master Nov 25, 2024
@egabancho egabancho deleted the custom-amqp-protocol branch November 25, 2024 09:14
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 this pull request may close these issues.

4 participants