Merge ~cjwatson/launchpad-layers:turnip-base-nagios-avoid-comma into launchpad-layers:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 42d39a9565fbf35212d684684f5265e86591d4c0
Proposed branch: ~cjwatson/launchpad-layers:turnip-base-nagios-avoid-comma
Merge into: launchpad-layers:main
Diff against target: 24 lines (+10/-1)
1 file modified
turnip-base/lib/charms/turnip/base.py (+10/-1)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Ines Almeida Approve
Review via email: mp+449429@code.launchpad.net

Commit message

turnip-base: Avoid comma in Nagios service description

Description of the change

On production, the comma caused Nagios to fail to parse the collected configuration with errors such as:

  Error: Could not find a service matching host name 'lp-prodstack-git-juju-f2a69b-prod-launchpad-git-17' and description 'Git E2E git://git.launchpad.net/launchpad - hint: check nfs-ganesha.service if all appservers are bad' (config file '/etc/nagios3/conf.d/servicegroups/prompt-critical.cfg', starting on line 2)
  Error: Could not expand member services specified in servicegroup (config file '/etc/nagios3/conf.d/servicegroups/prompt-critical.cfg', starting on line 2)

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

What an odd peculiarity. LGTM

review: Approve
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

Nice catch!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/turnip-base/lib/charms/turnip/base.py b/turnip-base/lib/charms/turnip/base.py
2index 7eb96c6..55fc056 100644
3--- a/turnip-base/lib/charms/turnip/base.py
4+++ b/turnip-base/lib/charms/turnip/base.py
5@@ -340,9 +340,18 @@ def add_nagios_e2e_checks(nagios):
6 nagios.add_check(
7 [os.path.join(nrpe_dir(), "check_git_refs"), url],
8 name=f"check_turnip_git_refs_{i}",
9+ # This ends up in service_description, and
10+ # https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectdefinitions.html#service
11+ # mentions some restrictions on allowed characters here: "This
12+ # directive is used to define the description of the service,
13+ # which may contain spaces, dashes, and colons (semicolons,
14+ # apostrophes, and quotation marks should be avoided)." Commas
15+ # aren't explicitly mentioned either way, but Nagios seems to
16+ # fail to parse the configuration when we include them, so take
17+ # care to avoid them.
18 description=(
19 "Git E2E {} - hint: check nfs-ganesha.service if all "
20- "appservers are bad, otherwise check "
21+ "appservers are bad or otherwise check "
22 "srv-turnip-data.mount"
23 ).format(url),
24 context=config["nagios_context"],

Subscribers

People subscribed via source and target branches