-
Notifications
You must be signed in to change notification settings - Fork 27
[DPE-3349] Handle S3 relation in primary non-leader unit #375
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
Conversation
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
…tanza-on-primary Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
if self.charm.unit.is_leader(): | ||
self.charm.app_peer_data.update( | ||
{"stanza": self.stanza_name, "init-pgbackrest": "True"} | ||
) |
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.
If we have to check the unit databags anyway, would it make sense to not set the app data at all? that way we should be able to have a single flow using the unit data, instead of having to check two places.
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.
Good point. Let me try to recall if there is any reason for this approach.
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.
I remembered the reason I have chosen the approach with both application and unit relation databags: using only the unit relation databag, if we scale down the application and the primary unit is removed, we need to handle the transfer of the stanza name to one of the remaining units in something like the relation departed event or keep the stanza name in all the units, which seems not so good as keeping it in the application relation databag.
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 is perfect! Wow!
…tanza-on-primary Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
* Handle S3 relation in primary non-leader unit Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Fix relation data removal Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Update integration test Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Fix existing unit tests Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Add extra unit tests Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Add unit test for peer relation changed event handler Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Handle pgBackRest service check when the primary was not elected yet Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Speedup the new check on test Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Add log call Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Speed up events Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Issue
The stanza can only be initialised in the PostgreSQL primary unit if it's the Juju leader unit.
Otherwise, the unit fails with an error, as shown in #370.
Solution
Allow the non-leader unit (when it's the PostgreSQL primary) to initialise the stanza.
For that, all checks for the unit being the Juju leader unit were changed to check whether the unit is the PostgreSQL primary.
Also, some coordination is now made in the relation databags to share the stanza name and the
init-pgbackrest
flag.The current flow doesn't change if the PostgreSQL primary unit is also the Juju leader unit.
If they are different units, then:
init-pgbackres
flag are set in the primary unit relation databag.pgbackrest check
command is executed in the primary unit, which clears theinit-pgbackrest
flag from the unit relation databag.init-pgbackrest
flag from the application relation databag.Both unit and integration tests were added/updated to ensure we keep this flow intact.
Also, a test for #273 was added through this PR, as it was also related to backups/restores.