-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix handling of tls config #524
Conversation
@PietroPasotti, check-libs complains:
Haven't checked but might be a LIBPATCH bump issue. |
given #523 , the lib should be up to date? If the issue persists we could try deleting it manually and re-fetching it? Maybe the linter did some minor change to it? |
src/charm.py
Outdated
@@ -539,7 +554,11 @@ def _configure(self, _): | |||
|
|||
self.remote_write_provider.update_endpoint() | |||
self.grafana_source_provider.update_source(self.external_url) | |||
self.unit.status = ActiveStatus() | |||
|
|||
if self._is_tls_enabled() and not self.container.exists(CERT_PATH): |
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 it would be more clear if we abstracted this to a self._is_tls_ready()
method.
Enabled but not ready -> push cert to container, then restart. Regardless of how we got there, this should be the reasonable course of action. Or what am I missing?
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'm thinking of writing the cert only on cert-changed
event, and:
Relation present | Cert file on disk | Hypothetical is_tls_ready() -> bool |
|
---|---|---|---|
Isolated charm | No | No | No |
tls-cert rel just joined | Yes | No | No |
on-cert-changed (after rel join) | Yes | Yes | Yes |
cert revoked/expired | Yes | Yes (keep on disk even if expired) | Yes |
relation departed / broken | Yes | ? | No (how? code ordering...) |
any event after rel-broken | No | No | No |
Wdyt?
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.
seems reasonable. I think departed/broken should immediately remove the cert from disk and from that moment onwards is_tls_ready should return false (assuming it checks the file presence synchronously).
Or we refactor to use manifests, but I'm not convinced that will make code ordering less of a headache
@@ -77,4 +77,4 @@ resources: | |||
prometheus-image: | |||
type: oci-image | |||
description: Container image for Prometheus | |||
upstream-source: ghcr.io/canonical/prometheus:latest | |||
upstream-source: ghcr.io/canonical/prometheus:dev |
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 needed until canonical/oci-factory#58 is applied.
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 was a local change that I reverted:
Library charms.tempo_k8s.v0.charm_tracing has local changes, cannot be updated.
Issue
TLS config is written and workload restarted, before the cert is written to disk.
Solution
update-ca-certificates
machinerystop()
, have_scheme
returnhttp
and_is_tls_enabled
returnFalse
until the cert is in place.Depends on:
Fixes #521
Testing Instructions
Release Notes
Fix handling of tls config.