Skip to content

Commit

Permalink
[DPE-3700] Add check before scrape is configured (#195)
Browse files Browse the repository at this point in the history
Closes #194
  • Loading branch information
phvalguima authored Mar 8, 2024
1 parent 99103c5 commit ecb0d45
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/charms/opensearch/v0/opensearch_base_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,13 @@ def _check_certs_expiration(self, event: UpdateStatusEvent) -> None:

def _scrape_config(self) -> List[Dict]:
"""Generates the scrape config as needed."""
app_secrets = self.secrets.get_object(Scope.APP, CertType.APP_ADMIN.val)
ca = app_secrets.get("ca-cert")
pwd = self.secrets.get(Scope.APP, self.secrets.password_key(COSUser))
if (
not (app_secrets := self.secrets.get_object(Scope.APP, CertType.APP_ADMIN.val))
or not (ca := app_secrets.get("ca-cert"))
or not (pwd := self.secrets.get(Scope.APP, self.secrets.password_key(COSUser)))
):
# Not yet ready, waiting for certain values to be set
return []
return [
{
"metrics_path": "/_prometheus/metrics",
Expand Down

0 comments on commit ecb0d45

Please sign in to comment.