-
Notifications
You must be signed in to change notification settings - Fork 20
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
TLS implementation #36
Conversation
src/charm.py
Outdated
enable_tls = False | ||
key, ca, cert = self.tls.get_tls_files() | ||
if None not in [key, ca, cert]: | ||
enable_tls = 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.
nit, but I wonder if it's more explicit having a:
enable_tls = all(self.tls.get_tls_files())
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 catch! I will change it here. Thanks Marc!
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.
Updated on 9e4d481.
if not self._patroni.member_started: | ||
return | ||
|
||
restart_postgresql = enable_tls != self.postgresql.is_tls_enabled() |
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.
nit, I think it would be more obviously parsable to have boring if
's here.
if self.postgresql.is_tls_enabled() != enable_tls:
self.on[self.restart_manager.name].acquire_lock.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.
In this specific part of the code, the check must be made before self._patroni.reload_patroni_configuration()
is called (because it enables TLS, which is a step needed before restarting PostgreSQL).
self._patroni.reload_patroni_configuration()
is called before the if because it is also needed when other configuration change.
Is it ok to keep the check this way due to that needs?
Co-authored-by: Will Fitch <WRFitch@outlook.com>
* Import files * Add TLS implementation * Update tests/unit/test_postgresql_tls.py Co-authored-by: Will Fitch <WRFitch@outlook.com> * Add required functions and variable for regex * Improve TLS check Co-authored-by: Will Fitch <WRFitch@outlook.com>
Issue
Solution
Context
FOCUS
your review on:src/charm.py
(ignoring the changes toget_secret
andset_secret
methods, which was only a refactor needed to use them outside the class, like in lib/charms/postgresql_k8s/v0/postgresql_tls.py; FOCUS on the other methods, that push TLS files to the container and later enable/disable TLS, also performing a rolling restart, which is needed for the other instances to start to use TLS in the replication connection)templates/patroni.yml.j2
(changes to enable/disable SSL in the client and other instances connections; this is something specific to PostgreSQL/Patroni)Testing
tests/unit/test_charm.py
andtests/unit/test_patroni.py
.tests/unit/test_postgresql_tls.py
.Release Notes