-
Notifications
You must be signed in to change notification settings - Fork 0
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
[DPE-5964] - TLS certificate renewal #17
base: DPE-5962-tls-implement-basic-flow
Are you sure you want to change the base?
[DPE-5964] - TLS certificate renewal #17
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.
Thanks Smail! No major concerns, I left some small questions.
# write certificates to disk | ||
self.charm.tls_manager.write_certificate(cert, private_key) | ||
|
||
# Updating certificates no need to do a rolling restart | ||
if self.charm.state.unit_server.tls_state == TLSState.TLS: |
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.
what of the case where the peer-cert was issued but this hook was invoked for the client-cert? what would the state of tls be?
if self.charm.state.unit_server.certs_ready: | ||
self.charm.set_status(Status.TLS_NOT_READY) |
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.
Left a comment on the other PR about this
# check if all units have been added to the cluster | ||
endpoints = get_cluster_endpoints(ops_test, APP_NAME, tls_enabled=True) | ||
leader_unit = await get_juju_leader_unit_name(ops_test, APP_NAME) | ||
assert leader_unit |
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.
was there a case when this was false?
|
||
# make sure data can be written to the cluster | ||
secret = await get_secret_by_label(ops_test, label=f"{PEER_RELATION}.{APP_NAME}.app") | ||
assert secret |
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 messages to your assertion for when they fail.
e.g
assert secret, f"Secret: {PEER_RELATION}.{APP_NAME}.app" missing.
# wait for certificate to expire | ||
logger.info(f"Waiting for the certificate to expire {EXPIRATION_WAITING_TIME}s") | ||
sleep(EXPIRATION_WAITING_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.
Can we add a test on the status of the application / units? Does it change?
This PR handeled the TLS certificate renewal.
Enhancements to TLS Handling:
Status
enum insrc/literals.py
to update the message forTLS_NOT_READY
to "enabling/disabling TLS" for better clarity._on_certificate_available
method insrc/events/tls.py
to only write the certificates to disk if TLS has already been enabled.Improvements to Tests:
tests/integration/test_tls.py
to ensure that the leader unit and secrets are correctly retrieved. [1] [2] [3] [4] [5]test_certificate_expiration
intests/integration/test_tls.py
to verify that the system correctly handles certificate expiration and renewal.Code Refinements:
tests/integration/helpers.py
to improve code readability and maintainability. [1] [2]CertType
frommanagers/tls
intests/integration/helpers.py
andtests/integration/test_tls.py
to support the new test case and helper function. [1] [2]Dependency Update:
pydantic
version 2.9.1 to integration dependencies.