~hloeung/ubuntu-repository-cache/cache-memory-tuning-fix

« back to all changes in this revision

Viewing changes to reactive/ubuntu-repository-cache.py

  • Committer: mergebot at canonical
  • Author(s): "Haw Loeung"
  • Date: 2020-08-11 05:13:51 UTC
  • mfrom: (280.1.3 ubuntu-repository-cache-charm)
  • Revision ID: mergebot@juju-139df4-prod-is-toolbox-0.canonical.com-20200811051351-bphbnypj22ng5j36
Only ship out the nagios checks when nrpe related

By default, checks are configured and updated even if nrpe relation isn't available (or service related to nrpe). This fixes that and also adds extra logging as to when function to update checks and restart/reload nrpe fires.

Reviewed-on: https://code.launchpad.net/~hloeung/ubuntu-repository-cache/nagios-checks-only-when-nrpe-related/+merge/389056
Reviewed-by: Paul Collins <paul.collins@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
    LOG('Config changed for %s' % SERVICE)
39
39
    reactive.clear_flag('ubuntu-repository-cache.configured')
 
40
    reactive.clear_flag('nagios-nrpe.configured')
40
41
 
41
42
 
42
43
@reactive.when('ubuntu-repository-cache.installed')
43
44
@reactive.when_not('ubuntu-repository-cache.configured')
44
45
def configure_services():
45
46
    service.render_configs()
46
 
    service.update_checks()
47
47
 
48
48
    # We should always do this anyway, but currently,
49
49
    # due to LP#1626318, following a reboot, the ephemeral
62
62
 
63
63
    LOG('Upgrading %s' % SERVICE)
64
64
    reactive.clear_flag('ubuntu-repository-cache.configured')
 
65
    reactive.clear_flag('nagios-nrpe.configured')
65
66
 
66
67
 
67
68
@reactive.hook('start')
173
174
@reactive.hook('nrpe-external-master-relation-changed')
174
175
@reactive.hook('local-monitors-relation-changed')
175
176
def update_checks():
 
177
    reactive.clear_flag('nagios-nrpe.configured')
 
178
 
 
179
 
 
180
@reactive.when('ubuntu-repository-cache.configured')
 
181
@reactive.when('nrpe-external-master.available')
 
182
@reactive.when_not('nagios-nrpe.configured')
 
183
def configure_nagios():
176
184
    '''Update Nagios checks for all services'''
177
185
 
178
186
    service.update_checks()
 
187
    reactive.set_flag('nagios-nrpe.configured')
179
188
 
180
189
 
181
190
@reactive.hook('leader-elected')