-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update NGINX configuration to work with horizontal scaling #268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, left some comments
src/charm.py
Outdated
"/etc/nginx/main_location.conf.template", | ||
"/etc/nginx/main_location.conf", | ||
], | ||
).wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a new one, I think previously we used some internal _exec function (that wraps container.exec) and I'm seeing a wait() for the first time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this is an experiment ;-)
I thought about not catching the error if something happens here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
harness.begin_with_initial_hooks() | ||
harness.charm.on.config_changed.emit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is not using the harness fixture so calling "begin_with_initial_hooks" would generate: "ops.pebble.APIError: execution handler not found, please register one using Harness.handle_exec"
So I changed to only call the config changed event.
Test coverage for 96c1b67
Static code analysis report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor nitpicky comments regarding file structure! Thank you!
Note: Integration test will be done in further story.
Overview
In Synapse, the main unit and workers handle different endpoints. This PR prepares NGINX to handle it while scaling by using template files that the charm will update with the proper main unit address.
Also, this PR changes Mjolnir to be enabled only in the main unit and redirecting abuse reports properly to it.
Flow
sed
to replace the string "main-unit" to the main unit address received.If the main unit is changed, the relation-changed event is emitted. The same process will happen there.
Why all this?
Any unit can correctly forward requests for the main unit if this is the case. Especially considering that only the main unit will run Mjolnir.
Otherwise, the unit itself will handle the request.
Rationale
Redirect requests as expected while horizontal scaling Synapse.
Juju Events Changes
NGINX pebble ready event.
_on_relation_changed event.
Module Changes
Library Changes
Checklist
src-docs
urgent
,trivial
,complex
)Charmhub doc will be updated once horizontal scaling is in place.