Cannot enable collect_iptables_metrics

Bug #2019283 reported by Haw Loeung
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Telegraf Charm
Invalid
Undecided
Unassigned

Bug Description

Hi,

I'm trying to enable `collect_iptables_metrics` on various models but that's failing.

It looks maybe to be with this bit of code:

| @hook("update-status")
| def update_status():
| changed = charms.reactive.helpers.data_changed(
| "detect_changes", get_base_inputs(), hash_type="sha256"
| )
| if changed:
| clear_flag("telegraf.configured")
| clear_flag("telegraf.apt.configured")
| clear_flag("telegraf.snap.configured")
| ...

So when you run `juju config telegraf-u-r-c collect_iptables_metrics=true`, a `config-changed` is fired but does nothing. You wait a bit for `update-status` to fire but by then, `detect_changes` returns false. This is from adding a bit of debug print:

2023-05-12 05:58:08 DEBUG unit.telegraf-u-r-c/5.update-status logger.go:60 HAW detect_changes False:

I think the logic should really change to rather than `update-status` to:

| @reactive.when('config.changed')
| def config_changed():
| clear_flag("telegraf.configured")
| clear_flag("telegraf.apt.configured")
| clear_flag("telegraf.snap.configured")
| ....
|
|
| @hook("update-status")
| def update_status():
| if is_flag_set("telegraf.configured"):
| service = get_service()
| if not host.service_running(service):
| hookenv.status_set("blocked", "Service not running: {}".format(service))
| else:
| hookenv.status_set(
| "active",
| "Monitoring {}{}".format(get_remote_unit_name(), get_revision()),

It also reduces the time from making a `juju config` change to when it's live.

Haw Loeung (hloeung)
Changed in charm-telegraf:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.