-
Notifications
You must be signed in to change notification settings - Fork 27
[DPE-8320] Fix backups with internal certificates #1162
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
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (64.51%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## 16/edge #1162 +/- ##
===========================================
- Coverage 64.57% 64.51% -0.07%
===========================================
Files 17 17
Lines 4328 4337 +9
Branches 669 671 +2
===========================================
+ Hits 2795 2798 +3
- Misses 1351 1357 +6
Partials 182 182 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ff8127c to
847d51a
Compare
|
|
||
| if not self.get_secret(APP_SCOPE, "internal-ca"): | ||
| self.tls.generate_internal_peer_ca() | ||
| self.tls.generate_internal_peer_cert() |
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 the internal cert generates before the IP is set to the peer data, the hostname will be used as common name. It also causes issues on Juju 4.
| None, | ||
| None, | ||
| None, |
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.
Test on microceph with the internal certs, without using a TLS operator.
| def _get_peer_common_name(self) -> str: | ||
| return self.charm.unit_peer_data.get("database-peers-address") or self.host |
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 think we should use the peers address here, in case it's different from the relation address.
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.
Makes sense, as we might have different Juju spaces and for the purpose of using the certificates for backup on replicas, what makes sense is the peer address.
| try: | ||
| if raw_cert := self.get_secret(UNIT_SCOPE, "internal-cert"): | ||
| cert = load_pem_x509_certificate(raw_cert.encode()) | ||
| if ( | ||
| cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value | ||
| != self._unit_ip | ||
| ): | ||
| self.tls.generate_internal_peer_cert() | ||
| except Exception: | ||
| logger.exception("Unable to check or update internal cert") |
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.
Regenerate the cert if the common name is not the IP before the upgrade.
taurus-forever
left a comment
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, please add one more message as we are going to regenerate cert.
| cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value | ||
| != self._unit_ip | ||
| ): | ||
| self.tls.generate_internal_peer_cert() |
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.
Please add INFO-like message to log to see when cert is regenerated (to simplify production troubleshooting). Warning is also fine.
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.
Added info log inside generate_internal_peer_cert().
| def _get_peer_common_name(self) -> str: | ||
| return self.charm.unit_peer_data.get("database-peers-address") or self.host |
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.
Makes sense, as we might have different Juju spaces and for the purpose of using the certificates for backup on replicas, what makes sense is the peer address.
* Wait for ip to generate leader cert * Regenerate cert if common name is host * Add info message on internal cert generation
* Wait for ip to generate leader cert * Regenerate cert if common name is host * Add info message on internal cert generation
Checklist