Skip to content

Commit

Permalink
Start the exporter in on_config_change
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Sep 12, 2023
1 parent 9bc6bb0 commit 2b61657
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ jobs:
echo "mark_expression=" >> $GITHUB_OUTPUT
else
echo Skipping unstable tests
echo "mark_expression=not unstable" >> $GITHUB_OUTPUT
echo "mark_expression=and not unstable" >> $GITHUB_OUTPUT
fi
- name: Run integration tests
run: tox run -e ${{ matrix.tox-environments }}-${{ env.libjuju }} -- -m 'not not${{ env.libjuju }} and ${{ steps.select-tests.outputs.mark_expression }}' --keep-models
run: tox run -e ${{ matrix.tox-environments }}-${{ env.libjuju }} -- -m 'not not${{ env.libjuju }} ${{ steps.select-tests.outputs.mark_expression }}' --keep-models
env:
AWS_ACCESS_KEY: "${{ secrets.AWS_ACCESS_KEY }}"
AWS_SECRET_KEY: "${{ secrets.AWS_SECRET_KEY }}"
Expand Down
16 changes: 5 additions & 11 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,16 +947,6 @@ def _on_start(self, event: StartEvent) -> None:

self.unit.set_workload_version(self._patroni.get_postgresql_version())

try:
# Set up the postgresql_exporter options.
# self._setup_exporter()
pass
except snap.SnapError:
logger.exception("failed to set up postgresql_exporter options")
self.unit.status = BlockedStatus("failed to set up postgresql_exporter options")
event.defer()
return

# Open port
try:
self.unit.open_port("tcp", 5432)
Expand Down Expand Up @@ -987,6 +977,7 @@ def _setup_exporter(self) -> None:
postgres_snap.start(services=[MONITORING_SNAP_SERVICE], enable=True)
else:
postgres_snap.restart(services=[MONITORING_SNAP_SERVICE])
self.unit_peer_data.update({"exporter-started": "True"})

def _start_primary(self, event: StartEvent) -> None:
"""Bootstrap the cluster."""
Expand Down Expand Up @@ -1400,7 +1391,10 @@ def update_config(self, is_creating_backup: bool = False) -> bool:
"Early exit update_config: Trying to reset metrics service with no configuration set"
)
return True
if snap_password != self.get_secret(APP_SCOPE, MONITORING_PASSWORD_KEY):
if (
snap_password != self.get_secret(APP_SCOPE, MONITORING_PASSWORD_KEY)
or "exporter-started" not in self.unit_peer_data
):
self._setup_exporter()

return True
Expand Down

0 comments on commit 2b61657

Please sign in to comment.